Skip to content

Commit 4356616

Browse files
committed
workqueue: add cmdline parameter workqueue.unbound_cpus to further constrain wq_unbound_cpumask at boot time
JIRA: https://issues.redhat.com/browse/RHEL-21798 Conflicts: A minor context diff in kernel/workqueue.c due to missing upstream commit 20bdeda ("workqueue: Warn attempt to flush system-wide workqueues."). commit ace3c54 Author: tiozhang <[email protected]> Date: Thu, 29 Jun 2023 11:50:50 +0800 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]> Signed-off-by: Waiman Long <[email protected]>
1 parent a9e6fcf commit 4356616

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
@@ -6799,6 +6799,13 @@
67996799
disables both lockup detectors. Default is 10
68006800
seconds.
68016801

6802+
workqueue.unbound_cpus=
6803+
[KNL,SMP] Specify to constrain one or some CPUs
6804+
to use in unbound workqueues.
6805+
Format: <cpu-list>
6806+
By default, all online CPUs are available for
6807+
unbound workqueues.
6808+
68026809
workqueue.watchdog_thresh=
68036810
If CONFIG_WQ_WATCHDOG is configured, workqueue can
68046811
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
@@ -327,6 +327,9 @@ static bool workqueue_freezing; /* PL: have wqs started freezing? */
327327
/* PL&A: allowable cpus for unbound wqs and work items */
328328
static cpumask_var_t wq_unbound_cpumask;
329329

330+
/* for further constrain wq_unbound_cpumask by cmdline parameter*/
331+
static struct cpumask wq_cmdline_cpumask __initdata;
332+
330333
/* CPU where unbound work was last round robin scheduled from this CPU */
331334
static DEFINE_PER_CPU(int, wq_rr_cpu_last);
332335

@@ -6106,6 +6109,9 @@ void __init workqueue_init_early(void)
61066109
cpumask_copy(wq_unbound_cpumask, housekeeping_cpumask(HK_TYPE_WQ));
61076110
cpumask_and(wq_unbound_cpumask, wq_unbound_cpumask, housekeeping_cpumask(HK_TYPE_DOMAIN));
61086111

6112+
if (!cpumask_empty(&wq_cmdline_cpumask))
6113+
cpumask_and(wq_unbound_cpumask, wq_unbound_cpumask, &wq_cmdline_cpumask);
6114+
61096115
pwq_cache = KMEM_CACHE(pool_workqueue, SLAB_PANIC);
61106116

61116117
/* initialize CPU pools */
@@ -6229,3 +6235,14 @@ void __init workqueue_init(void)
62296235
*/
62306236
void __warn_flushing_systemwide_wq(void) { }
62316237
EXPORT_SYMBOL(__warn_flushing_systemwide_wq);
6238+
6239+
static int __init workqueue_unbound_cpus_setup(char *str)
6240+
{
6241+
if (cpulist_parse(str, &wq_cmdline_cpumask) < 0) {
6242+
cpumask_clear(&wq_cmdline_cpumask);
6243+
pr_warn("workqueue.unbound_cpus: incorrect CPU range, using default\n");
6244+
}
6245+
6246+
return 1;
6247+
}
6248+
__setup("workqueue.unbound_cpus=", workqueue_unbound_cpus_setup);

0 commit comments

Comments
 (0)