From: Tejun Heo <tj@kernel.org>
To: Marco Crivellari <marco.crivellari@suse.com>
Cc: linux-kernel@vger.kernel.org,
Lai Jiangshan <jiangshanlai@gmail.com>,
Frederic Weisbecker <frederic@kernel.org>,
Sebastian Andrzej Siewior <bigeasy@linutronix.de>,
Michal Hocko <mhocko@suse.com>, Breno Leitao <leitao@debian.org>
Subject: Re: [PATCH RFC 2/3] workqueue: Offload WQ_PREFER_PERCPU work from isolated CPUs
Date: Tue, 01 Dec 2026 04:28:44 -1000 [thread overview]
Message-ID: <8e5de3f34b131c469ca307486b9c9969@kernel.org> (raw)
In-Reply-To: <CAAofZF5X2rq0ZOE2vqo+hiCB_7b90QGVp3wwB_ZJnTHoX29HdQ@mail.gmail.com>
Hello, Marco.
On Tue, Dec 01, 2026 at 11:28:31AM +0100, Marco Crivellari wrote:
> Yes, that makes sense. So maybe we can use WQ_AFFN_CPU with strict affinity.
> Even without CM, users may prefer better locality when the CPU isn't isolated.
I wasn't suggesting WQ_AFFN_CPU. My point was that the description and
comments give locality as the only reason, and WQ_AFFN_CPU already covers
that. PREFER_PERCPU is for users which benefit from concurrency management
but don't depend on percpu for correctness. Can you update the description
and comments to say that?
That's also why I'm not sure about switching the pwqs of isolated CPUs to
unbound pools. Work items queued there lose concurrency management. How
about staying on the percpu pools and picking a different CPU when
queueing? When a work item is queued with WORK_CPU_UNBOUND on a CPU which
isn't in wq_unbound_cpumask, __queue_work() can pick a CPU in the mask and
use its percpu pwq, similar to what wq_select_unbound_cpu() does for
unbound workqueues. All work items stay concurrency managed and no pwq has
to be switched when the isolation changes.
For picking the CPU, maybe round-robin among the CPUs of the same NUMA
node which are in wq_unbound_cpumask, and fall back to the whole mask when
the node has none? queue_work_on() with a specific CPU should stay on that
CPU.
> The Workqueue marked with WQ_PREFER_PERCPU is also WQ_PERCPU. If the CPU
> is isolated, this workqueue is backed by an unbound pool, and
> node_nr_active[] isn't
> allocated there. So the "if" above wouldn't have been taken, which would call:
...
> With your suggested approach, this is no longer an issue anyhow.
> I will drop Patch 2 for the next version.
With the pwqs staying on percpu pools, is_percpu_pool() keeps working
there.
This is also where the discussion with Breno was heading:
https://lore.kernel.org/r/ec6c22eddc8ce0b1ef2434ed62acd560@kernel.org
PERCPU becomes its own scope and a WQ_PERCPU workqueue can't leave it. A
WQ_PREFER_PERCPU workqueue starts in the scope, follows the unbound
cpumask when selecting the queueing CPU, and can be switched to other
scopes. So this patch would be the queueing CPU selection part, and moving
a workqueue to an unbound scope can go through the scope change path.
I haven't tried any of this and these are suggestions. If you find a
better way while implementing, please go with that.
Thanks.
--
tejun
next prev parent reply other threads:[~2026-12-01 14:28 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-26 15:24 [PATCH RFC 0/3] workqueue: Add WQ_PREFER_PERCPU Marco Crivellari
2026-11-26 15:24 ` [PATCH RFC 1/3] workqueue: Add WQ_PREFER_PERCPU and system_prefer_percpu_wq Marco Crivellari
2026-11-26 15:24 ` [PATCH RFC 2/3] workqueue: Offload WQ_PREFER_PERCPU work from isolated CPUs Marco Crivellari
2026-11-27 20:54 ` Tejun Heo
2026-12-01 10:28 ` Marco Crivellari
2026-12-01 14:28 ` Tejun Heo [this message]
2026-11-26 15:24 ` [PATCH RFC 3/3] workqueue: doc: Document WQ_PREFER_PERCPU Marco Crivellari
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=8e5de3f34b131c469ca307486b9c9969@kernel.org \
--to=tj@kernel.org \
--cc=bigeasy@linutronix.de \
--cc=frederic@kernel.org \
--cc=jiangshanlai@gmail.com \
--cc=leitao@debian.org \
--cc=linux-kernel@vger.kernel.org \
--cc=marco.crivellari@suse.com \
--cc=mhocko@suse.com \
/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