From 76a1232ee7f69372200a8ff9617f9203395d8749 Mon Sep 17 00:00:00 2001 From: DeHackEd Date: Wed, 20 May 2020 13:07:21 -0400 Subject: [PATCH] Use boot_ncpus in place of max_ncpus in taskq_create Due to hotplug support or BIOS bugs sometimes max_ncpus can be an absurdly high value. I have a system with 32 cores/threads but reports max_ncpus == 440. This many threads potentially cripples the system during arc_prune floods for example. boot_ncpus is the number of working CPUs when called so use that instead. Reviewed-by: Brian Behlendorf Signed-off-by: DHE Closes #10282 --- module/zfs/arc.c | 4 ++-- module/zfs/dsl_pool.c | 4 ++-- module/zfs/txg.c | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/module/zfs/arc.c b/module/zfs/arc.c index eebe8d249..ebbc89030 100644 --- a/module/zfs/arc.c +++ b/module/zfs/arc.c @@ -7878,8 +7878,8 @@ 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", max_ncpus, defclsyspri, - max_ncpus, INT_MAX, TASKQ_PREPOPULATE | TASKQ_DYNAMIC); + arc_prune_taskq = taskq_create("arc_prune", boot_ncpus, defclsyspri, + boot_ncpus, INT_MAX, TASKQ_PREPOPULATE | TASKQ_DYNAMIC); arc_ksp = kstat_create("zfs", 0, "arcstats", "misc", KSTAT_TYPE_NAMED, sizeof (arc_stats) / sizeof (kstat_named_t), KSTAT_FLAG_VIRTUAL); diff --git a/module/zfs/dsl_pool.c b/module/zfs/dsl_pool.c index d8cf4d209..a53a5f3e6 100644 --- a/module/zfs/dsl_pool.c +++ b/module/zfs/dsl_pool.c @@ -222,9 +222,9 @@ dsl_pool_open_impl(spa_t *spa, uint64_t txg) cv_init(&dp->dp_spaceavail_cv, NULL, CV_DEFAULT, NULL); dp->dp_iput_taskq = taskq_create("z_iput", max_ncpus, defclsyspri, - max_ncpus * 8, INT_MAX, TASKQ_PREPOPULATE | TASKQ_DYNAMIC); + boot_ncpus * 8, INT_MAX, TASKQ_PREPOPULATE | TASKQ_DYNAMIC); dp->dp_unlinked_drain_taskq = taskq_create("z_unlinked_drain", - max_ncpus, defclsyspri, max_ncpus, INT_MAX, + boot_ncpus, defclsyspri, boot_ncpus, INT_MAX, TASKQ_PREPOPULATE | TASKQ_DYNAMIC); return (dp); diff --git a/module/zfs/txg.c b/module/zfs/txg.c index 418315be8..bf6e7d769 100644 --- a/module/zfs/txg.c +++ b/module/zfs/txg.c @@ -453,7 +453,7 @@ txg_dispatch_callbacks(dsl_pool_t *dp, uint64_t txg) * Commit callback taskq hasn't been created yet. */ tx->tx_commit_cb_taskq = taskq_create("tx_commit_cb", - max_ncpus, defclsyspri, max_ncpus, max_ncpus * 2, + boot_ncpus, defclsyspri, boot_ncpus, boot_ncpus * 2, TASKQ_PREPOPULATE | TASKQ_DYNAMIC); }