Skip to content

Commit ace3c54

Browse files
tiozhanghtejun
authored andcommitted
workqueue: add cmdline parameter workqueue.unbound_cpus to further constrain wq_unbound_cpumask at boot time
Motivation of doing this is to better improve boot times for devices when we want to prevent our workqueue works from running on some specific CPUs, e,g, some CPUs are busy with interrupts. Signed-off-by: tiozhang <[email protected]> Signed-off-by: Tejun Heo <[email protected]>
1 parent 20bdeda commit ace3c54

File tree

2 files changed

+24
-0
lines changed

2 files changed

+24
-0
lines changed

Documentation/admin-guide/kernel-parameters.txt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6964,6 +6964,13 @@
69646964
disables both lockup detectors. Default is 10
69656965
seconds.
69666966

6967+
workqueue.unbound_cpus=
6968+
[KNL,SMP] Specify to constrain one or some CPUs
6969+
to use in unbound workqueues.
6970+
Format: <cpu-list>
6971+
By default, all online CPUs are available for
6972+
unbound workqueues.
6973+
69676974
workqueue.watchdog_thresh=
69686975
If CONFIG_WQ_WATCHDOG is configured, workqueue can
69696976
warn stall conditions and dump internal state to

kernel/workqueue.c

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -368,6 +368,9 @@ static bool workqueue_freezing; /* PL: have wqs started freezing? */
368368
/* PL&A: allowable cpus for unbound wqs and work items */
369369
static cpumask_var_t wq_unbound_cpumask;
370370

371+
/* for further constrain wq_unbound_cpumask by cmdline parameter*/
372+
static struct cpumask wq_cmdline_cpumask __initdata;
373+
371374
/* CPU where unbound work was last round robin scheduled from this CPU */
372375
static DEFINE_PER_CPU(int, wq_rr_cpu_last);
373376

@@ -6455,6 +6458,9 @@ void __init workqueue_init_early(void)
64556458
cpumask_copy(wq_unbound_cpumask, housekeeping_cpumask(HK_TYPE_WQ));
64566459
cpumask_and(wq_unbound_cpumask, wq_unbound_cpumask, housekeeping_cpumask(HK_TYPE_DOMAIN));
64576460

6461+
if (!cpumask_empty(&wq_cmdline_cpumask))
6462+
cpumask_and(wq_unbound_cpumask, wq_unbound_cpumask, &wq_cmdline_cpumask);
6463+
64586464
pwq_cache = KMEM_CACHE(pool_workqueue, SLAB_PANIC);
64596465

64606466
/* initialize CPU pools */
@@ -6577,3 +6583,14 @@ void __warn_flushing_systemwide_wq(void)
65776583
dump_stack();
65786584
}
65796585
EXPORT_SYMBOL(__warn_flushing_systemwide_wq);
6586+
6587+
static int __init workqueue_unbound_cpus_setup(char *str)
6588+
{
6589+
if (cpulist_parse(str, &wq_cmdline_cpumask) < 0) {
6590+
cpumask_clear(&wq_cmdline_cpumask);
6591+
pr_warn("workqueue.unbound_cpus: incorrect CPU range, using default\n");
6592+
}
6593+
6594+
return 1;
6595+
}
6596+
__setup("workqueue.unbound_cpus=", workqueue_unbound_cpus_setup);

0 commit comments

Comments
 (0)