]> git.baikalelectronics.ru Git - kernel.git/commitdiff
workqueue: Avoid a false warning in unbind_workers()
authorLai Jiangshan <jiangshan.ljs@antgroup.com>
Fri, 29 Jul 2022 09:44:38 +0000 (17:44 +0800)
committerTejun Heo <tj@kernel.org>
Fri, 29 Jul 2022 17:49:02 +0000 (07:49 -1000)
Doing set_cpus_allowed_ptr() with wq_unbound_cpumask can be possible
fails and trigger the false warning.

Use cpu_possible_mask instead when wq_unbound_cpumask has no active CPUs.

It is very easy to trigger the warning:
  Set wq_unbound_cpumask to a small set of CPUs.
  Offline all the CPUs of wq_unbound_cpumask.
  Offline an extra CPU and trigger the warning.

Fixes: 264fd0e7caf0 ("workqueue: Restrict kworker in the offline CPU pool running on housekeeping CPUs")
Signed-off-by: Lai Jiangshan <jiangshan.ljs@antgroup.com>
Signed-off-by: Tejun Heo <tj@kernel.org>
kernel/workqueue.c

index 1ea50f6be843698965a14a13a7498834fc510e36..aa8a82bc673845f9798403c80c2cdac6900f2291 100644 (file)
@@ -5001,7 +5001,10 @@ static void unbind_workers(int cpu)
 
                for_each_pool_worker(worker, pool) {
                        kthread_set_per_cpu(worker->task, -1);
-                       WARN_ON_ONCE(set_cpus_allowed_ptr(worker->task, wq_unbound_cpumask) < 0);
+                       if (cpumask_intersects(wq_unbound_cpumask, cpu_active_mask))
+                               WARN_ON_ONCE(set_cpus_allowed_ptr(worker->task, wq_unbound_cpumask) < 0);
+                       else
+                               WARN_ON_ONCE(set_cpus_allowed_ptr(worker->task, cpu_possible_mask) < 0);
                }
 
                mutex_unlock(&wq_pool_attach_mutex);