mirror of
https://git.proxmox.com/git/mirror_zfs.git
synced 2026-05-25 03:37:45 +03:00
Implement memory and CPU hotplug
ZFS currently doesn't react to hotplugging cpu or memory into the system in any way. This patch changes that by adding logic to the ARC that allows the system to take advantage of new memory that is added for caching purposes. It also adds logic to the taskq infrastructure to support dynamically expanding the number of threads allocated to a taskq. Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov> Co-authored-by: Matthew Ahrens <matthew.ahrens@delphix.com> Co-authored-by: Brian Behlendorf <behlendorf1@llnl.gov> Signed-off-by: Paul Dagnelie <pcd@delphix.com> Closes #11212
This commit is contained in:
+17
-7
@@ -7592,6 +7592,15 @@ arc_target_bytes(void)
|
||||
return (arc_c);
|
||||
}
|
||||
|
||||
void
|
||||
arc_set_limits(uint64_t allmem)
|
||||
{
|
||||
/* Set min cache to 1/32 of all memory, or 32MB, whichever is more. */
|
||||
arc_c_min = MAX(allmem / 32, 2ULL << SPA_MAXBLOCKSHIFT);
|
||||
|
||||
/* How to set default max varies by platform. */
|
||||
arc_c_max = arc_default_max(arc_c_min, allmem);
|
||||
}
|
||||
void
|
||||
arc_init(void)
|
||||
{
|
||||
@@ -7607,11 +7616,7 @@ arc_init(void)
|
||||
arc_lowmem_init();
|
||||
#endif
|
||||
|
||||
/* Set min cache to 1/32 of all memory, or 32MB, whichever is more. */
|
||||
arc_c_min = MAX(allmem / 32, 2ULL << SPA_MAXBLOCKSHIFT);
|
||||
|
||||
/* How to set default max varies by platform. */
|
||||
arc_c_max = arc_default_max(arc_c_min, allmem);
|
||||
arc_set_limits(allmem);
|
||||
|
||||
#ifndef _KERNEL
|
||||
/*
|
||||
@@ -7648,6 +7653,8 @@ arc_init(void)
|
||||
if (arc_c < arc_c_min)
|
||||
arc_c = arc_c_min;
|
||||
|
||||
arc_register_hotplug();
|
||||
|
||||
arc_state_init();
|
||||
|
||||
buf_init();
|
||||
@@ -7656,8 +7663,9 @@ arc_init(void)
|
||||
offsetof(arc_prune_t, p_node));
|
||||
mutex_init(&arc_prune_mtx, NULL, MUTEX_DEFAULT, NULL);
|
||||
|
||||
arc_prune_taskq = taskq_create("arc_prune", boot_ncpus, defclsyspri,
|
||||
boot_ncpus, INT_MAX, TASKQ_PREPOPULATE | TASKQ_DYNAMIC);
|
||||
arc_prune_taskq = taskq_create("arc_prune", 100, defclsyspri,
|
||||
boot_ncpus, INT_MAX, TASKQ_PREPOPULATE | TASKQ_DYNAMIC |
|
||||
TASKQ_THREADS_CPU_PCT);
|
||||
|
||||
arc_ksp = kstat_create("zfs", 0, "arcstats", "misc", KSTAT_TYPE_NAMED,
|
||||
sizeof (arc_stats) / sizeof (kstat_named_t), KSTAT_FLAG_VIRTUAL);
|
||||
@@ -7754,6 +7762,8 @@ arc_fini(void)
|
||||
buf_fini();
|
||||
arc_state_fini();
|
||||
|
||||
arc_unregister_hotplug();
|
||||
|
||||
/*
|
||||
* We destroy the zthrs after all the ARC state has been
|
||||
* torn down to avoid the case of them receiving any
|
||||
|
||||
Reference in New Issue
Block a user