mirror of
				https://git.proxmox.com/git/mirror_zfs.git
				synced 2025-10-26 18:05:04 +03:00 
			
		
		
		
	Following the fix for 9018 (Replace kmem_cache_reap_now() with
kmem_cache_reap_soon), the arc_reclaim_thread() no longer blocks
while reaping.  However, the code is still confusing and error-prone,
because this thread has two responsibilities.  We should instead
separate this into two threads each with their own responsibility:
 1. keep `arc_size` under `arc_c`, by calling `arc_adjust()`, which
    improves `arc_is_overflowing()`
 2. keep enough free memory in the system, by calling
    `arc_kmem_reap_now()` plus `arc_shrink()`, which improves
    `arc_available_memory()`.
Furthermore, we can use the zthr infrastructure to separate the
"should we do something" from "do it" parts of the logic, and
normalize the start up / shut down of the threads.
Authored by: Brad Lewis <brad.lewis@delphix.com>
Reviewed by: Matt Ahrens <mahrens@delphix.com>
Reviewed by: Serapheim Dimitropoulos <serapheim@delphix.com>
Reviewed by: Pavel Zakharov <pavel.zakharov@delphix.com>
Reviewed by: Dan Kimmel <dan.kimmel@delphix.com>
Reviewed by: Paul Dagnelie <pcd@delphix.com>
Reviewed by: Dan McDonald <danmcd@joyent.com>
Reviewed by: Tim Kordas <tim.kordas@joyent.com>
Reviewed by: Tim Chase <tim@chase2k.com>
Reviewed by: Brian Behlendorf <behlendorf1@llnl.gov>
Ported-by:  Brad Lewis <brad.lewis@delphix.com>
Signed-off-by: Brad Lewis <brad.lewis@delphix.com>
OpenZFS-issue: https://www.illumos.org/issues/9284
OpenZFS-commit: https://github.com/openzfs/openzfs/commit/de753e34f9
Closes #8165
		
	
			
		
			
				
	
	
		
			56 lines
		
	
	
		
			1.4 KiB
		
	
	
	
		
			C
		
	
	
	
	
	
			
		
		
	
	
			56 lines
		
	
	
		
			1.4 KiB
		
	
	
	
		
			C
		
	
	
	
	
	
/*
 | 
						|
 * CDDL HEADER START
 | 
						|
 *
 | 
						|
 * This file and its contents are supplied under the terms of the
 | 
						|
 * Common Development and Distribution License ("CDDL"), version 1.0.
 | 
						|
 * You may only use this file in accordance with the terms of version
 | 
						|
 * 1.0 of the CDDL.
 | 
						|
 *
 | 
						|
 * A full copy of the text of the CDDL should have accompanied this
 | 
						|
 * source. A copy of the CDDL is also available via the Internet at
 | 
						|
 * http://www.illumos.org/license/CDDL.
 | 
						|
 *
 | 
						|
 * CDDL HEADER END
 | 
						|
 */
 | 
						|
 | 
						|
/*
 | 
						|
 * Copyright (c) 2017 by Delphix. All rights reserved.
 | 
						|
 */
 | 
						|
 | 
						|
#ifndef _SYS_ZTHR_H
 | 
						|
#define	_SYS_ZTHR_H
 | 
						|
 | 
						|
typedef struct zthr zthr_t;
 | 
						|
typedef int (zthr_func_t)(void *, zthr_t *);
 | 
						|
typedef boolean_t (zthr_checkfunc_t)(void *, zthr_t *);
 | 
						|
 | 
						|
struct zthr {
 | 
						|
	kthread_t	*zthr_thread;
 | 
						|
	kmutex_t	zthr_lock;
 | 
						|
	kcondvar_t	zthr_cv;
 | 
						|
	boolean_t	zthr_cancel;
 | 
						|
	hrtime_t	zthr_wait_time;
 | 
						|
 | 
						|
	zthr_checkfunc_t	*zthr_checkfunc;
 | 
						|
	zthr_func_t	*zthr_func;
 | 
						|
	void		*zthr_arg;
 | 
						|
	int		zthr_rc;
 | 
						|
};
 | 
						|
 | 
						|
extern zthr_t *zthr_create(zthr_checkfunc_t checkfunc,
 | 
						|
    zthr_func_t *func, void *arg);
 | 
						|
extern zthr_t *zthr_create_timer(zthr_checkfunc_t *checkfunc,
 | 
						|
    zthr_func_t *func, void *arg, hrtime_t nano_wait);
 | 
						|
 | 
						|
extern void zthr_exit(zthr_t *t, int rc);
 | 
						|
extern void zthr_destroy(zthr_t *t);
 | 
						|
 | 
						|
extern void zthr_wakeup(zthr_t *t);
 | 
						|
extern int zthr_cancel(zthr_t *t);
 | 
						|
extern void zthr_resume(zthr_t *t);
 | 
						|
 | 
						|
extern boolean_t zthr_iscancelled(zthr_t *t);
 | 
						|
extern boolean_t zthr_isrunning(zthr_t *t);
 | 
						|
 | 
						|
#endif /* _SYS_ZTHR_H */
 |