Path: blob/main/sys/contrib/openzfs/lib/libzpool/arc_os.c
48378 views
// SPDX-License-Identifier: CDDL-1.01/*2* CDDL HEADER START3*4* The contents of this file are subject to the terms of the5* Common Development and Distribution License (the "License").6* You may not use this file except in compliance with the License.7*8* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE9* or https://opensource.org/licenses/CDDL-1.0.10* See the License for the specific language governing permissions11* and limitations under the License.12*13* When distributing Covered Code, include this CDDL HEADER in each14* file and include the License file at usr/src/OPENSOLARIS.LICENSE.15* If applicable, add the following below this CDDL HEADER, with the16* fields enclosed by brackets "[]" replaced with your own identifying17* information: Portions Copyright [yyyy] [name of copyright owner]18*19* CDDL HEADER END20*/21/*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.27*/2829#include <sys/zfs_context.h>30#include <sys/arc_impl.h>3132/*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.35*/36uint64_t37arc_default_max(uint64_t min, uint64_t allmem)38{39uint64_t size;4041if (allmem >= 1 << 30)42size = allmem - (1 << 30);43else44size = min;45return (MAX(allmem * 5 / 8, size));46}4748int64_t49arc_available_memory(void)50{51int64_t lowest = INT64_MAX;5253/* Every 100 calls, free a small amount */54if (random_in_range(100) == 0)55lowest = -1024;5657return (lowest);58}5960int61arc_memory_throttle(spa_t *spa, uint64_t reserve, uint64_t txg)62{63(void) spa, (void) reserve, (void) txg;64return (0);65}6667uint64_t68arc_all_memory(void)69{70return (ptob(physmem) / 2);71}7273uint64_t74arc_free_memory(void)75{76return (random_in_range(arc_all_memory() * 20 / 100));77}7879void80arc_register_hotplug(void)81{82}8384void85arc_unregister_hotplug(void)86{87}888990