[PATCH v2] workqueue: respect isolated cpus when queueing an unbound work

From: Tal Shorer
Date: Sat Oct 21 2017 - 12:29:40 EST


Initialize wq_unbound_cpumask to exclude cpus that were isolated by
the cmdline's isolcpus parameter.

Signed-off-by: Tal Shorer <tal.shorer@xxxxxxxxx>
---
kernel/workqueue.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/kernel/workqueue.c b/kernel/workqueue.c
index ca937b0..0add5d4 100644
--- a/kernel/workqueue.c
+++ b/kernel/workqueue.c
@@ -4947,6 +4947,10 @@ int workqueue_set_unbound_cpumask(cpumask_var_t cpumask)
if (!zalloc_cpumask_var(&saved_cpumask, GFP_KERNEL))
return -ENOMEM;

+ /*
+ * Not excluding isolated cpus on purpose.
+ * If the user wishes to include them, we allow that.
+ */
cpumask_and(cpumask, cpumask, cpu_possible_mask);
if (!cpumask_empty(cpumask)) {
apply_wqattrs_lock();
@@ -5546,7 +5550,7 @@ int __init workqueue_init_early(void)
WARN_ON(__alignof__(struct pool_workqueue) < __alignof__(long long));

BUG_ON(!alloc_cpumask_var(&wq_unbound_cpumask, GFP_KERNEL));
- cpumask_copy(wq_unbound_cpumask, cpu_possible_mask);
+ cpumask_andnot(wq_unbound_cpumask, cpu_possible_mask, cpu_isolated_map);

pwq_cache = KMEM_CACHE(pool_workqueue, SLAB_PANIC);

--
2.7.4