Re: [PATCH RFC 2/3] workqueue: Offload WQ_PREFER_PERCPU work from isolated CPUs

From: Tejun Heo

Date: Fri Nov 27 2026 - 15:54:08 EST


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?

> - 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?

> +static void prefer_percpu_wq_update_pwq(struct workqueue_struct *wq, int cpu)
...
> +static void wq_update_prefer_percpu_pwqs(const struct cpumask *cpus)

These two names are too confusing.

Thanks.

--
tejun