From: Breno Leitao <leitao@debian.org>
To: Tejun Heo <tj@kernel.org>
Cc: Lai Jiangshan <jiangshanlai@gmail.com>,
Marco Crivellari <marco.crivellari@suse.com>,
linux-kernel@vger.kernel.org, kernel-team@meta.com
Subject: Re: [PATCH wq/for-7.4 v2 2/3] workqueue: Keep the limits of both max_active domains current
Date: Tue, 29 Sep 2026 07:40:54 -0700 [thread overview]
Message-ID: <arvJTBx7L0oSuPDm@gmail.com> (raw)
In-Reply-To: <79e8fdf844e1aa9358dd4c2c3e5f888b@kernel.org>
Hello Tejun,
On Mon, Sep 28, 2026 at 10:15:31AM -1000, Tejun Heo wrote:
> 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.
yes, sorry, that is waht I meant.
> > + 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?
Very good point, and I've just tested it and reproduce the behaviour you
raised.
>
> > + } 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?
Ack!
> > } 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().
Ack!
> > 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.
Right, thanks for catching that. I'll change both setters to use
unbound_effective_cpumask() once the workqueue has a pwq installed, and
only fall back to wq_unbound_cpumask before that (percpu workqueues, or
unbound ones still being set up), so it lines up with what
wq_update_node_max_active() already does.
Thanks for the review,
--breno
next prev parent reply other threads:[~2026-09-29 14:41 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-25 13:09 [PATCH wq/for-7.4 v2 0/3] workqueue: Keep max_active and percpu_max_active in sync Breno Leitao
2026-09-25 13:09 ` [PATCH wq/for-7.4 v2 1/3] workqueue: Move the initial max_active setup into a helper Breno Leitao
2026-09-25 13:09 ` [PATCH wq/for-7.4 v2 2/3] workqueue: Keep the limits of both max_active domains current Breno Leitao
2026-09-28 20:15 ` Tejun Heo
2026-09-29 14:40 ` Breno Leitao [this message]
2026-09-25 13:09 ` [PATCH wq/for-7.4 v2 3/3] workqueue: add a percpu_concurrency_managed workqueue attribute Breno Leitao
2026-09-28 21:31 ` Tejun Heo
2026-09-29 13:51 ` Breno Leitao
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=arvJTBx7L0oSuPDm@gmail.com \
--to=leitao@debian.org \
--cc=jiangshanlai@gmail.com \
--cc=kernel-team@meta.com \
--cc=linux-kernel@vger.kernel.org \
--cc=marco.crivellari@suse.com \
--cc=tj@kernel.org \
/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
all inboxes | Powered by JetHome®