Skip to contentSkip to conversation

workqueue: Initialize wq_isolated_cpumask in workqueue_init_early()

PATCH Applied Chuyi Zhou 3 participants 3 messages Jun 17, 2025 Workqueue

lore
Share & tools
lore

Chuyi Zhou

author
#0 lore raw

PATCH 1/1 workqueue: Initialize wq_isolated_cpumask in workqueue_init_early()

Now when isolcpus is enabled via the cmdline, wq_isolated_cpumask does not include these isolated CPUs, even wq_unbound_cpumask has already excluded them. It is only when we successfully configure an isolate cpuset partition that wq_isolated_cpumask gets overwritten by workqueue_unbound_exclude_cpumask(), including both the cmdline-specified isolated CPUs and the isolated CPUs within the cpuset partitions.

Fix this issue by initializing wq_isolated_cpumask properly in workqueue_init_early().

Fixes fe28f631fa94 ("workqueue: Add workqueue_unbound_exclude_cpumask() to exclude CPUs from wq_unbound_cpumask")
---
 kernel/workqueue.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
kernel/workqueue.c +2 -1
index 97f37b5bae669..9f91480758288 100644
@@ -7767,7 +7767,8 @@ void __init workqueue_init_early(void)
 		restrict_unbound_cpumask("workqueue.unbound_cpus", &wq_cmdline_cpumask);
 
 	cpumask_copy(wq_requested_unbound_cpumask, wq_unbound_cpumask);
-
+	cpumask_andnot(wq_isolated_cpumask, cpu_possible_mask,
+						housekeeping_cpumask(HK_TYPE_DOMAIN));
 	pwq_cache = KMEM_CACHE(pool_workqueue, SLAB_PANIC);
 
 	unbound_wq_update_pwq_attrs_buf = alloc_workqueue_attrs();
Signature · 1 line
2.20.1
Reviewed-by on v1 1/1
#1 lore raw
Quoted 21 lines · Chuyi Zhou

Now when isolcpus is enabled via the cmdline, wq_isolated_cpumask does not include these isolated CPUs, even wq_unbound_cpumask has already excluded them. It is only when we successfully configure an isolate cpuset partition that wq_isolated_cpumask gets overwritten by workqueue_unbound_exclude_cpumask(), including both the cmdline-specified isolated CPUs and the isolated CPUs within the cpuset partitions.

Fix this issue by initializing wq_isolated_cpumask properly in workqueue_init_early().

Fixes fe28f631fa94 ("workqueue: Add workqueue_unbound_exclude_cpumask() to exclude CPUs from wq_unbound_cpumask")
---
  kernel/workqueue.c | 3 ++-
  1 file changed, 2 insertions(+), 1 deletion(-)
kernel/workqueue.c +0 -0
index 97f37b5bae669..9f91480758288 100644

kernel/workqueue.c void __init workqueue_init_early(void) · line 7774

Quoted 9 lines
kernel/workqueue.c +2 -1
@@ -7767,7 +7767,8 @@ void __init workqueue_init_early(void)
  		restrict_unbound_cpumask("workqueue.unbound_cpus", &wq_cmdline_cpumask);
 
  	cpumask_copy(wq_requested_unbound_cpumask, wq_unbound_cpumask);
-
+	cpumask_andnot(wq_isolated_cpumask, cpu_possible_mask,
+						housekeeping_cpumask(HK_TYPE_DOMAIN));
  	pwq_cache = KMEM_CACHE(pool_workqueue, SLAB_PANIC);
 
  	unbound_wq_update_pwq_attrs_buf = alloc_workqueue_attrs();

Right, the wq_isolated_cpumask isn't initialized properly. Thank for fixing that.

maintainer Applied
#2 lore raw
In reply to Chuyi Zhou
Quoted 7 lines · Chuyi Zhou

Now when isolcpus is enabled via the cmdline, wq_isolated_cpumask does not include these isolated CPUs, even wq_unbound_cpumask has already excluded them. It is only when we successfully configure an isolate cpuset partition that wq_isolated_cpumask gets overwritten by workqueue_unbound_exclude_cpumask(), including both the cmdline-specified isolated CPUs and the isolated CPUs within the cpuset partitions.

Quoted 5 lines

Fix this issue by initializing wq_isolated_cpumask properly in workqueue_init_early().

Fixes fe28f631fa94 ("workqueue: Add workqueue_unbound_exclude_cpumask() to exclude CPUs from wq_unbound_cpumask")

Applied to wq/for-6.16-fixes.

Thanks.

Signature · 1 line
tejun