mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Tejun Heo <tj@kernel.org>
To: Breno Leitao <leitao@debian.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: Mon, 28 Sep 2026 10:15:31 -1000	[thread overview]
Message-ID: <79e8fdf844e1aa9358dd4c2c3e5f888b@kernel.org> (raw)
In-Reply-To: <20260925-wq_final-v2-2-860ee052169e@debian.org>

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

  reply	other threads:[~2026-09-28 20:15 UTC|newest]

Thread overview: 6+ 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 [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

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=79e8fdf844e1aa9358dd4c2c3e5f888b@kernel.org \
    --to=tj@kernel.org \
    --cc=jiangshanlai@gmail.com \
    --cc=kernel-team@meta.com \
    --cc=leitao@debian.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=marco.crivellari@suse.com \
    /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®