[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-Id: <20251117030913.3084-3-jiangshanlai@gmail.com>
Date: Mon, 17 Nov 2025 11:09:12 +0800
From: Lai Jiangshan <jiangshanlai@...il.com>
To: linux-kernel@...r.kernel.org
Cc: Lai Jiangshan <jiangshan.ljs@...group.com>,
Juri Lelli <juri.lelli@...hat.com>,
Waiman Long <longman@...hat.com>,
Tejun Heo <tj@...nel.org>,
Lai Jiangshan <jiangshanlai@...il.com>
Subject: [PATCH 2/3] workqueue: Let DISASSOCIATED workers follow unbound wq cpumask changes
From: Lai Jiangshan <jiangshan.ljs@...group.com>
When workqueue cpumask changes are committed, the DISASSOCIATED workers
affinity is not touched and this might be a problem down the line for
isolated setups when the DISASSOCIATED pools still have works to run
after the cpu is offline.
Make sure the workers' affinity is updated every time a workqueue cpumask
changes, so these workers can't break isolation.
Cc: Juri Lelli <juri.lelli@...hat.com>
Cc: Waiman Long <longman@...hat.com>
Signed-off-by: Lai Jiangshan <jiangshan.ljs@...group.com>
---
kernel/workqueue.c | 13 +++++++++++++
1 file changed, 13 insertions(+)
diff --git a/kernel/workqueue.c b/kernel/workqueue.c
index 9da679c621dc..ccf03a0ff122 100644
--- a/kernel/workqueue.c
+++ b/kernel/workqueue.c
@@ -6967,6 +6967,10 @@ static int workqueue_apply_unbound_cpumask(const cpumask_var_t unbound_cpumask)
}
if (!ret) {
+ int cpu;
+ struct worker_pool *pool;
+ struct worker *worker;
+
mutex_lock(&wq_pool_attach_mutex);
cpumask_copy(wq_unbound_cpumask, unbound_cpumask);
/* rescuer needs to respect cpumask changes when it is not attached */
@@ -6974,6 +6978,15 @@ static int workqueue_apply_unbound_cpumask(const cpumask_var_t unbound_cpumask)
if (wq->rescuer && !wq->rescuer->pool)
unbind_worker(wq->rescuer);
}
+ /* DISASSOCIATED worker needs to respect wq_unbound_cpumask */
+ for_each_possible_cpu(cpu) {
+ for_each_cpu_worker_pool(pool, cpu) {
+ if (!(pool->flags & POOL_DISASSOCIATED))
+ continue;
+ for_each_pool_worker(worker, pool)
+ unbind_worker(worker);
+ }
+ }
mutex_unlock(&wq_pool_attach_mutex);
}
return ret;
--
2.19.1.6.gb485710b
Powered by blists - more mailing lists