lkml.org 
[lkml]   [2020]   [Dec]   [14]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH 03/10] workqueue: Manually break affinity on pool detachment
Date
From: Lai Jiangshan <laijs@linux.alibaba.com>

Don't rely on the scheduler to force break affinity for us -- it will
stop doing that for per-cpu-kthreads.

Fixes: 06249738a41a ("workqueue: Manually break affinity on hotplug")
Signed-off-by: Lai Jiangshan <laijs@linux.alibaba.com>
---
kernel/workqueue.c | 10 ++++++++++
1 file changed, 10 insertions(+)

diff --git a/kernel/workqueue.c b/kernel/workqueue.c
index 1f5b8385c0cf..1f6cb83e0bc5 100644
--- a/kernel/workqueue.c
+++ b/kernel/workqueue.c
@@ -1885,6 +1885,16 @@ static void worker_detach_from_pool(struct worker *worker)

if (list_empty(&pool->workers))
detach_completion = pool->detach_completion;
+
+ /*
+ * The cpus of pool->attrs->cpumask might all go offline after
+ * detachment, and the scheduler may not force break affinity
+ * for us, so we do it on our own and unbind this worker which
+ * can't be unbound by workqueue_offline_cpu() since it doesn't
+ * belong to any pool after it.
+ */
+ set_cpus_allowed_ptr(worker->task, cpu_possible_mask);
+
mutex_unlock(&wq_pool_attach_mutex);

/* clear leftover flags without pool->lock after it is detached */
--
2.19.1.6.gb485710b
\
 
 \ /
  Last update: 2020-12-14 15:58    [W:0.186 / U:0.316 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site