mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Lai Jiangshan <jiangshanlai@gmail.com>
To: linux-kernel@vger.kernel.org
Cc: Lai Jiangshan <jiangshan.ljs@antgroup.com>,
	Juri Lelli <juri.lelli@redhat.com>,
	Waiman Long <longman@redhat.com>, Tejun Heo <tj@kernel.org>,
	Lai Jiangshan <jiangshanlai@gmail.com>
Subject: [PATCH 2/3] workqueue: Let DISASSOCIATED workers follow unbound wq cpumask changes
Date: Mon, 17 Nov 2025 11:09:12 +0800	[thread overview]
Message-ID: <20251117030913.3084-3-jiangshanlai@gmail.com> (raw)
In-Reply-To: <20251117030913.3084-1-jiangshanlai@gmail.com>

From: Lai Jiangshan <jiangshan.ljs@antgroup.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@redhat.com>
Cc: Waiman Long <longman@redhat.com>
Signed-off-by: Lai Jiangshan <jiangshan.ljs@antgroup.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


  parent reply	other threads:[~2025-11-17  3:05 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-11-17  3:09 [PATCH 0/3] workqueue: Cleanup affnity for detached/DISASSOCIATED workers Lai Jiangshan
2025-11-17  3:09 ` [PATCH 1/3] workqueue: Update the rescuer's affinity only when it is detached Lai Jiangshan
2025-11-17  3:09 ` Lai Jiangshan [this message]
2025-11-17  3:09 ` [PATCH 3/3] workqueue: Init rescuer's affinities as wq_unbound_cpumask Lai Jiangshan
2025-11-20 20:32 ` [PATCH 0/3] workqueue: Cleanup affnity for detached/DISASSOCIATED workers Tejun Heo

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20251117030913.3084-3-jiangshanlai@gmail.com \
    --to=jiangshanlai@gmail.com \
    --cc=jiangshan.ljs@antgroup.com \
    --cc=juri.lelli@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=longman@redhat.com \
    --cc=tj@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®