[PATCH -tip V2 01/10] workqueue: restore unbound_workers' cpumask correctly

From: Lai Jiangshan
Date: Fri Dec 18 2020 - 11:09:38 EST


From: Lai Jiangshan <laijs@xxxxxxxxxxxxxxxxx>

When we restore workers' cpumask, we should restore them to the
designed pool->attrs->cpumask. And we need to only do it at
the first time.

Cc: Hillf Danton <hdanton@xxxxxxxx>
Reported-by: Hillf Danton <hdanton@xxxxxxxx>
Acked-by: Tejun Heo <tj@xxxxxxxxxx>
Signed-off-by: Lai Jiangshan <laijs@xxxxxxxxxxxxxxxxx>
---
kernel/workqueue.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/kernel/workqueue.c b/kernel/workqueue.c
index c71da2a59e12..aba71ab359dd 100644
--- a/kernel/workqueue.c
+++ b/kernel/workqueue.c
@@ -5031,9 +5031,13 @@ static void restore_unbound_workers_cpumask(struct worker_pool *pool, int cpu)

cpumask_and(&cpumask, pool->attrs->cpumask, cpu_online_mask);

+ /* is @cpu the first one onlined for the @pool? */
+ 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