[PATCH -tip V2 04/10] workqueue: don't set the worker's cpumask when kthread_bind_mask()

From: Lai Jiangshan
Date: Fri Dec 18 2020 - 11:10:17 EST


From: Lai Jiangshan <laijs@xxxxxxxxxxxxxxxxx>

There might be no online cpu in the pool->attrs->cpumask.
We will set the worker's cpumask later in worker_attach_to_pool().

Cc: Peter Zijlstra <peterz@xxxxxxxxxxxxx>
Acked-by: Tejun Heo <tj@xxxxxxxxxx>
Signed-off-by: Lai Jiangshan <laijs@xxxxxxxxxxxxxxxxx>
---
kernel/workqueue.c | 10 +++++++++-
1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/kernel/workqueue.c b/kernel/workqueue.c
index 4d7575311198..5f3c86eaed7a 100644
--- a/kernel/workqueue.c
+++ b/kernel/workqueue.c
@@ -1948,7 +1948,15 @@ static struct worker *create_worker(struct worker_pool *pool)
goto fail;

set_user_nice(worker->task, pool->attrs->nice);
- kthread_bind_mask(worker->task, pool->attrs->cpumask);
+
+ /*
+ * Set PF_NO_SETAFFINITY via kthread_bind_mask(). We use
+ * cpu_possible_mask instead of pool->attrs->cpumask, because
+ * there might not be any online cpu in the pool->attrs->cpumask.
+ * The cpumask of the worker will be set properly later in
+ * worker_attach_to_pool().
+ */
+ kthread_bind_mask(worker->task, cpu_possible_mask);

/* successful, attach the worker to the pool */
worker_attach_to_pool(worker, pool);
--
2.19.1.6.gb485710b