[PATCH wq/for-7.4 v2 0/3] workqueue: Keep max_active and percpu_max_active in sync

From: Breno Leitao

Date: Fri Sep 25 2026 - 09:13:48 EST


Commit 27db9dd7f84f3a ("workqueue: Give percpu workqueues their own
max_active") gave the percpu backend a limit of its own, so a workqueue
now carries both percpu_max_active and max cpu.

__alloc_workqueue() only ever sets the pair matching the backend the
workqueue is created on, so the other stays at zero for its lifetime.

Nothing reads "the other scope" max_active today, so this is groundwork
rather than a fix

Two patches. The first moves the initial limit setup out of
__alloc_workqueue() into wq_init_max_active()

The second sets both domains rather than one, according to tejun's
recommendation:

U = unbound max_active, the system-wide target
L = unbound min_active, the floor on each node
P = percpu_max_active, the limit on each CPU
N = online CPUs in the effective unbound mask, at least 1

Setting P:
U = min(P * N, WQ_MAX_ACTIVE)
L = P

Setting U:
L = min(L, U)
P = max(DIV_ROUND_UP(U, N), L)

Setting L:
L = clamp(L, 0, U)
P = max(DIV_ROUND_UP(U, N), L)

Also, add the flag for CM in the workqueue attributes, as discussed on
v1. This will help will enable the introduction of PERCPU affinity scope
later.

This shouldn't change the behaviour of workqueue for now, but, enable
the new PERCPU introduction.

Signed-off-by: Breno Leitao <leitao@xxxxxxxxxx>
---
Changes in v2:
- Cut the series down to the three patches that change nothing
observable. The runtime scaling, the affinity scopes, the backend
rework, the concurrency management attribute and the sysfs files are
all held back.
- Set both max_active domains instead of holding them equal, deriving
one from the other rather than duplicating the value (Tejun)
- Link to v1:
https://patch.msgid.link/20260918-wq_final-v1-0-5c43c08a26bc@xxxxxxxxxx

---
Breno Leitao (3):
workqueue: Move the initial max_active setup into a helper
workqueue: Keep the limits of both max_active domains current
workqueue: add a percpu_concurrency_managed workqueue attribute

include/linux/workqueue.h | 9 +++
kernel/workqueue.c | 173 ++++++++++++++++++++++++++++++++--------------
2 files changed, 132 insertions(+), 50 deletions(-)
---
base-commit: 9d4815c14f7faf789aeaa63515024168daf0390c
change-id: 20260914-wq_final-bcfbcd3b0f79

Best regards,
--
Breno Leitao <leitao@xxxxxxxxxx>