From: Lai Jiangshan <la...@linux.alibaba.com> The commit d945b5e9f0e("workqueue: Fix setting affinity of unbound worker threads") fixed a problem of set_cpus_allowed_ptr() with online&!active cpumasks (more than one CPUs) when restore_unbound_workers_cpumask() in online callback.
But now the new online callback for unbound workqueue is called later than sched_cpu_activate(). So the cpu is set in cpu_active_mask and set_cpus_allowed_ptr() with pool->attrs->cpumask in the code won't cause such warning any more. The said commit also left comments outdated and causes confusing. It is better to change the code back. Cc: Hillf Danton <hdan...@sina.com> Reported-by: Hillf Danton <hdan...@sina.com> Acked-by: Tejun Heo <t...@kernel.org> Tested-by: Paul E. McKenney <paul...@kernel.org> Signed-off-by: Lai Jiangshan <la...@linux.alibaba.com> --- kernel/workqueue.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/kernel/workqueue.c b/kernel/workqueue.c index d7bdb7885e55..38628e2a622c 100644 --- a/kernel/workqueue.c +++ b/kernel/workqueue.c @@ -5039,11 +5039,15 @@ static void restore_unbound_workers_cpumask(struct worker_pool *pool, int cpu) if (!cpumask_test_cpu(cpu, pool->attrs->cpumask)) return; + /* is @cpu the only online CPU? */ cpumask_and(&cpumask, pool->attrs->cpumask, cpu_online_mask); + if (cpumask_weight(&cpumask) != 1) + return; /* as we're called from CPU_ONLINE, the following shouldn't fail */ for_each_pool_worker(worker, pool) - WARN_ON_ONCE(set_cpus_allowed_ptr(worker->task, &cpumask) < 0); + WARN_ON_ONCE(set_cpus_allowed_ptr(worker->task, + pool->attrs->cpumask) < 0); } int workqueue_prepare_cpu(unsigned int cpu) -- 2.19.1.6.gb485710b