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.
Showing the changes to kernel/workqueue.c (1 of 1 file). Show all
Unified · Split
| @@ -5001,7 +5001,10 @@ static void unbind_workers(int cpu) · 5000 unmodified lines | |||
| 5001 | 5001 | ||
| 5002 | for_each_pool_worker(worker, pool) { | 5002 | for_each_pool_worker(worker, pool) { |
| 5003 | kthread_set_per_cpu(worker->task, -1); | 5003 | kthread_set_per_cpu(worker->task, -1); |
| 5004 | WARN_ON_ONCE(set_cpus_allowed_ptr(worker->task, wq_unbound_cpumask) < 0); | 5004 | if (cpumask_intersects(wq_unbound_cpumask, cpu_active_mask)) |
| 5005 | WARN_ON_ONCE(set_cpus_allowed_ptr(worker->task, wq_unbound_cpumask) < 0); | ||
| 5006 | else | ||
| 5007 | WARN_ON_ONCE(set_cpus_allowed_ptr(worker->task, cpu_possible_mask) < 0); | ||
| 5005 | } | 5008 | } |
| 5006 | 5009 | ||
| 5007 | mutex_unlock(&wq_pool_attach_mutex); | 5010 | mutex_unlock(&wq_pool_attach_mutex); |