Add missing parenthesis in VERIFYF()
[zfs.git] / lib / libzpool / arc_os.c
blobed99322ddb051b6ca824ca654dbaeed26d6ff955
1 /*
2 * CDDL HEADER START
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]
19 * CDDL HEADER END
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.
36 uint64_t
37 arc_default_max(uint64_t min, uint64_t allmem)
39 uint64_t size;
41 if (allmem >= 1 << 30)
42 size = allmem - (1 << 30);
43 else
44 size = min;
45 return (MAX(allmem * 5 / 8, size));
48 int64_t
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)
55 lowest = -1024;
57 return (lowest);
60 int
61 arc_memory_throttle(spa_t *spa, uint64_t reserve, uint64_t txg)
63 (void) spa, (void) reserve, (void) txg;
64 return (0);
67 uint64_t
68 arc_all_memory(void)
70 return (ptob(physmem) / 2);
73 uint64_t
74 arc_free_memory(void)
76 return (random_in_range(arc_all_memory() * 20 / 100));
79 void
80 arc_register_hotplug(void)
84 void
85 arc_unregister_hotplug(void)