Re: [PATCH wq/for-7.4 v2 2/3] workqueue: Keep the limits of both max_active domains current
From: Tejun Heo
Date: Mon Sep 28 2026 - 16:17:06 EST
Hello, Breno.
On Fri, Sep 25, 2026 at 06:09:51AM -0700, Breno Leitao wrote:
> Given that we are introducing a WQ_AFFN_CPU which will be able to do CM,
> we want to keep both values set, so, the transition from scopes would be
> able to succeed.
This would be the new PERCPU scope rather than WQ_AFFN_CPU.
> + int nr_cpus = wq_nr_online_cpus(wq_unbound_cpumask);
Workqueues from workqueue_init_early() and early initcalls are created
before smp_init(), when only the boot CPU is online, so nr_cpus is 1 for
them. For example, system_dfl_wq ends up with percpu_max_active 2048 where
32 would be right on a 64 CPU machine, and nothing rederives it once all
CPUs are up. Maybe rederive the other domain in workqueue_init_topology(),
which already walks all workqueues to update node max_active?
> + } else if (wq->flags & WQ_BH) { /* BH implies !WQ_UNBOUND */
> + wq->max_active = effective_max_active;
> + wq->min_active = effective_max_active;
> + wq->percpu_max_active = effective_max_active;
Maybe set these in the WQ_BH branch at the top so that BH is handled in one
place?
> } else {
> wq->percpu_max_active = effective_max_active;
> + wq->max_active = wq_scale_to_unbound(effective_max_active,
> + nr_cpus);
> + wq->min_active = min(effective_max_active, wq->max_active);
max_active can't be lower than percpu_max_active here, so min_active can
just be percpu_max_active. Same in workqueue_set_max_active().
> max_active = wq_clamp_max_active(max_active, wq->flags, wq->name);
> + nr_cpus = wq_nr_online_cpus(wq_unbound_cpumask);
For unbound workqueues, nr_cpus should match what
wq_update_node_max_active() distributes max_active over, the online CPUs in
unbound_effective_cpumask(). With wq_unbound_cpumask, percpu_max_active
comes out too low for a workqueue with a narrowed cpumask, e.g. 8 instead of
64 for max_active 256 on 4 of 64 CPUs. Same in workqueue_set_min_active().
wq_unbound_cpumask is right for percpu workqueues.
Thanks.
--
tejun