mirror of
				https://git.proxmox.com/git/mirror_zfs.git
				synced 2025-10-26 18:05:04 +03:00 
			
		
		
		
	 8fc0beb66b
			
		
	
	
		8fc0beb66b
		
	
	
	
	
		
			
			The Linux arc_os.c carries userspace and kernel code, with very little overlap between the two. This lifts the userspace parts out into a separate arc_os.c for libzpool and removes it from the Linux side. Reviewed by: Brian Behlendorf <behlendorf1@llnl.gov> Reviewed-by: Alexander Motin <mav@FreeBSD.org> Signed-off-by: Rob Norris <robn@despairlabs.com> Sponsored-by: https://despairlabs.com/sponsor/ Closes #16492
		
			
				
	
	
		
			88 lines
		
	
	
		
			2.0 KiB
		
	
	
	
		
			C
		
	
	
	
	
	
			
		
		
	
	
			88 lines
		
	
	
		
			2.0 KiB
		
	
	
	
		
			C
		
	
	
	
	
	
| /*
 | |
|  * CDDL HEADER START
 | |
|  *
 | |
|  * The contents of this file are subject to the terms of the
 | |
|  * Common Development and Distribution License (the "License").
 | |
|  * You may not use this file except in compliance with the License.
 | |
|  *
 | |
|  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
 | |
|  * or https://opensource.org/licenses/CDDL-1.0.
 | |
|  * See the License for the specific language governing permissions
 | |
|  * and limitations under the License.
 | |
|  *
 | |
|  * When distributing Covered Code, include this CDDL HEADER in each
 | |
|  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
 | |
|  * If applicable, add the following below this CDDL HEADER, with the
 | |
|  * fields enclosed by brackets "[]" replaced with your own identifying
 | |
|  * information: Portions Copyright [yyyy] [name of copyright owner]
 | |
|  *
 | |
|  * CDDL HEADER END
 | |
|  */
 | |
| /*
 | |
|  * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
 | |
|  * Copyright (c) 2018, Joyent, Inc.
 | |
|  * Copyright (c) 2011, 2019 by Delphix. All rights reserved.
 | |
|  * Copyright (c) 2014 by Saso Kiselkov. All rights reserved.
 | |
|  * Copyright 2017 Nexenta Systems, Inc.  All rights reserved.
 | |
|  */
 | |
| 
 | |
| #include <sys/zfs_context.h>
 | |
| #include <sys/arc_impl.h>
 | |
| 
 | |
| /*
 | |
|  * Return a default max arc size based on the amount of physical memory.
 | |
|  * This may be overridden by tuning the zfs_arc_max module parameter.
 | |
|  */
 | |
| uint64_t
 | |
| arc_default_max(uint64_t min, uint64_t allmem)
 | |
| {
 | |
| 	uint64_t size;
 | |
| 
 | |
| 	if (allmem >= 1 << 30)
 | |
| 		size = allmem - (1 << 30);
 | |
| 	else
 | |
| 		size = min;
 | |
| 	return (MAX(allmem * 5 / 8, size));
 | |
| }
 | |
| 
 | |
| int64_t
 | |
| arc_available_memory(void)
 | |
| {
 | |
| 	int64_t lowest = INT64_MAX;
 | |
| 
 | |
| 	/* Every 100 calls, free a small amount */
 | |
| 	if (random_in_range(100) == 0)
 | |
| 		lowest = -1024;
 | |
| 
 | |
| 	return (lowest);
 | |
| }
 | |
| 
 | |
| int
 | |
| arc_memory_throttle(spa_t *spa, uint64_t reserve, uint64_t txg)
 | |
| {
 | |
| 	(void) spa, (void) reserve, (void) txg;
 | |
| 	return (0);
 | |
| }
 | |
| 
 | |
| uint64_t
 | |
| arc_all_memory(void)
 | |
| {
 | |
| 	return (ptob(physmem) / 2);
 | |
| }
 | |
| 
 | |
| uint64_t
 | |
| arc_free_memory(void)
 | |
| {
 | |
| 	return (random_in_range(arc_all_memory() * 20 / 100));
 | |
| }
 | |
| 
 | |
| void
 | |
| arc_register_hotplug(void)
 | |
| {
 | |
| }
 | |
| 
 | |
| void
 | |
| arc_unregister_hotplug(void)
 | |
| {
 | |
| }
 |