4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or https://opensource.org/licenses/CDDL-1.0.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
22 * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
23 * Copyright (c) 2018, Joyent, Inc.
24 * Copyright (c) 2011, 2019 by Delphix. All rights reserved.
25 * Copyright (c) 2014 by Saso Kiselkov. All rights reserved.
26 * Copyright 2017 Nexenta Systems, Inc. All rights reserved.
29 #include <sys/zfs_context.h>
30 #include <sys/arc_impl.h>
33 * Return a default max arc size based on the amount of physical memory.
34 * This may be overridden by tuning the zfs_arc_max module parameter.
37 arc_default_max(uint64_t min
, uint64_t allmem
)
41 if (allmem
>= 1 << 30)
42 size
= allmem
- (1 << 30);
45 return (MAX(allmem
* 5 / 8, size
));
49 arc_available_memory(void)
51 int64_t lowest
= INT64_MAX
;
53 /* Every 100 calls, free a small amount */
54 if (random_in_range(100) == 0)
61 arc_memory_throttle(spa_t
*spa
, uint64_t reserve
, uint64_t txg
)
63 (void) spa
, (void) reserve
, (void) txg
;
70 return (ptob(physmem
) / 2);
76 return (random_in_range(arc_all_memory() * 20 / 100));
80 arc_register_hotplug(void)
85 arc_unregister_hotplug(void)