Re: [PATCH RFC 2/3] workqueue: Offload WQ_PREFER_PERCPU work from isolated CPUs
From: Marco Crivellari
Date: Tue Dec 01 2026 - 05:28:48 EST
Hello Tejun,
On Fri, Nov 27, 2026 at 9:54 PM Tejun Heo <tj@xxxxxxxxxx> wrote:
>
> Hello, Marco.
>
> On Thu, Nov 26, 2026 at 04:24:57PM +0100, Marco Crivellari wrote:
> > Many WQ_PERCPU users don't need per-cpu execution for correctness, they
> > only want cache locality. For them, running on an isolated CPU is just
> > noise for the isolated workload.
> >
> > WQ_PREFER_PERCPU covers this case. It implies WQ_PERCPU, so by default
> > the workqueue is a regular concurrency-managed per-cpu workqueue. When a
> > CPU is isolated, its pwq is backed by an unbound pool running on the
> > housekeeping CPUs instead.
>
> If the need is just affinity, wouldn't an unbound workqueue with
> WQ_AFFN_CPU do? The only material difference between WQ_AFFN_CPU and a
> percpu workqueue is concurrency management, and the pwqs that get switched
> to unbound pools here lose it. If concurrency management isn't needed, is
> there any point in this mechanism?
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.
> > - if (is_percpu_pool(pool)) {
> > + if (wq->flags & WQ_PERCPU) {
> > obtained = pwq->nr_active < READ_ONCE(wq->percpu_max_active);
> > goto out;
> > }
>
> Why does this switch from is_percpu_pool() to testing WQ_PERCPU?
> Concurrency management is tied to the pool, isn't it?
Yes, you're right.
But i did this for another reason; maybe it would have been better to
explain it instead of the
comment I put there.
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:
wq_node_nr_active(wq, pool->node);
Triggering the BUG_ON():
BUG_ON(!(wq->flags & WQ_UNBOUND));
With your suggested approach, this is no longer an issue anyhow.
I will drop Patch 2 for the next version.
Many thanks for your review!
--
Marco Crivellari
SUSE Labs