Re: [RFC PATCH 0/2] Add queue_*() functions and prefer per-cpu workqueue and flag
From: Frederic Weisbecker
Date: Wed Jul 08 2026 - 09:59:12 EST
Le Wed, Jun 24, 2026 at 09:46:55AM -1000, Tejun Heo a écrit :
> Hello,
>
> On Tue, Jun 23, 2026 at 05:13:31PM +0200, Marco Crivellari wrote:
> > > - At boot time, allow selecting whether to back them with percpu wqs or
> > > WQ_AFFN_X unbound ones. Maybe we can even experiment with default to
> > > WQ_AFFN_CPU.
> >
> > You mentioned here "at boot time". What about making this also dynamic,
> > "moving" the WQs with WQ_PREFER_PERCPU away from CPU N when N is
> > isolated through a cgroup isolated partition?
>
> Yeah, being dynamic is better but switching dynamically between percpu and
> unbound workqueues feels like it's going to be complicated. I can't think of
> a simple way to do that. If you can, please be my guest.
I fear it's necessary to have dynamic isolation working correctly.
One way could be to make wq::cpu_pwq point to a pair of pwqs. One
for the isolated -> unbound configuration and another one for the
non_isolated -> per_cpu configuration.
Luckily it's fetched under RCU, so we can have that on one side:
housekeeping_update()
rcu_assign_pointer(housekeeping.cpumasks[HK_TYPE_DOMAIN], trial);
housekeeping.flags |= HK_FLAG_DOMAIN; // for housekeeping_enabled()
synchronize_rcu()
flush_workqueue(wq_prefer_percpu); // flush both wq->cpu_unbound_pwq and
wq->cpu_pwq
And that on the other side:
__queue_work()
rcu_read_lock()
unbound = false;
if (req_cpu == WORK_CPU_UNBOUND) {
if (wq->flags & WQ_UNBOUND || (housekeeping_enabled(HK_TYPE_DOMAIN) &&
wq->flags & WQ_PREFER_PERCPU)) {
unbound = true;
cpu = wq_select_unbound_cpu(raw_smp_processor_id());
} else {
cpu = raw_smp_processor_id();
}
}
if (unbound)
pwq = rcu_dereference(*per_cpu_ptr(wq->cpu_unbound_pwq, cpu));
else
pwq = rcu_dereference(*per_cpu_ptr(wq->cpu_pwq, cpu));
...
rcu_read_unlock()
Thanks.
--
Frederic Weisbecker
SUSE Labs