* [PATCH 0/2] workqueue: Make WQ_UNBOUND the default behavior
@ 2026-09-03 15:22 Marco Crivellari
2026-09-03 15:22 ` [PATCH 1/2] workqueue: Make alloc_workqueue() unbound by default Marco Crivellari
2026-09-03 15:22 ` [PATCH 2/2] doc: Update WQ_UNBOUND documentation Marco Crivellari
0 siblings, 2 replies; 4+ messages in thread
From: Marco Crivellari @ 2026-09-03 15:22 UTC (permalink / raw)
To: linux-kernel
Cc: Tejun Heo, Lai Jiangshan, Frederic Weisbecker,
Sebastian Andrzej Siewior, Marco Crivellari, Michal Hocko,
Breno Leitao
Hi,
Currently alloc_workqueue() make sure one among WQ_UNBOUND or WQ_PERCPU is
present. This is enforced warning and setting WQ_PERCPU as default when
alloc_workqueue() without WQ_PERCPU or WQ_UNBOUND.
[ P1 ] change this behavior: if no flags are specified, WQ_UNBOUND is
set by default, changing the default behavior when flags are not present.
The WARN_ONCE() when neither flags are present has been removed and it has
been replaced by pr_warn_once(): from now on, every alloc_users()
without WQ_PERCPU will be considered unbound.
Q: I decided to pr_warn_once() just to make sure users are aware of the new
behavior. It makes sense or we can just drop it directly?
I don't think the WARN_ONCE() is appropriate now, for this specific path.
[ P2 ] updates the documentation accordingly.
Thanks!
Marco Crivellari (2):
workqueue: Make alloc_workqueue() unbound by default
doc: Update WQ_UNBOUND documentation
Documentation/core-api/workqueue.rst | 2 ++
kernel/workqueue.c | 14 +++++++-------
2 files changed, 9 insertions(+), 7 deletions(-)
--
2.55.0
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH 1/2] workqueue: Make alloc_workqueue() unbound by default
2026-09-03 15:22 [PATCH 0/2] workqueue: Make WQ_UNBOUND the default behavior Marco Crivellari
@ 2026-09-03 15:22 ` Marco Crivellari
2026-09-03 15:45 ` Marco Crivellari
2026-09-03 15:22 ` [PATCH 2/2] doc: Update WQ_UNBOUND documentation Marco Crivellari
1 sibling, 1 reply; 4+ messages in thread
From: Marco Crivellari @ 2026-09-03 15:22 UTC (permalink / raw)
To: linux-kernel
Cc: Tejun Heo, Lai Jiangshan, Frederic Weisbecker,
Sebastian Andrzej Siewior, Marco Crivellari, Michal Hocko,
Breno Leitao
Currently alloc_workqueue() ensure that one among WQ_PERCPU or WQ_UNBOUND
is present. Now every user has one among these two flags.
In order to achive the future goal of removing WQ_UNBOUND from the code,
start changing the default behavior making alloc_workqueue() act this way:
- if WQ_PERCPU and WQ_UNBOUND are present: remove WQ_PERCPU (as before)
- if neither are present: add WQ_UNBOUND
The WARN_ONCE() when neither flags are present has been removed and it has
been replaced by pr_warn_once(): from now on, every alloc_users()
without WQ_PERCPU will be considered unbound.
The pr_warn_once() will be removed along with WQ_UNBOUND in the future.
Link: https://lore.kernel.org/all/20250221112003.1dSuoGyc@linutronix.de/
Suggested-by: Tejun Heo <tj@kernel.org>
Signed-off-by: Marco Crivellari <marco.crivellari@suse.com>
---
kernel/workqueue.c | 14 +++++++-------
1 file changed, 7 insertions(+), 7 deletions(-)
diff --git a/kernel/workqueue.c b/kernel/workqueue.c
index 1ae3732a2c51..8681343597e8 100644
--- a/kernel/workqueue.c
+++ b/kernel/workqueue.c
@@ -5928,16 +5928,16 @@ static struct workqueue_struct *__alloc_workqueue(const char *fmt,
wq->name);
/*
- * One among WQ_PERCPU and WQ_UNBOUND must be set, but not both.
- * - If neither is set, default to WQ_PERCPU
- * - If both are set, default to WQ_UNBOUND
+ * Every caller that doesn't explicilty specify WQ_PERCPU will be
+ * unbound (WQ_UNBOUND) by default.
*
- * This code can be removed after workqueue are unbound by default
+ * If both flags are present at the same time, WQ_PERCPU will be
+ * removed.
*/
if (unlikely(!(flags & (WQ_UNBOUND | WQ_PERCPU)))) {
- WARN_ONCE(1, "workqueue: %s is using neither WQ_PERCPU or WQ_UNBOUND. "
- "Setting WQ_PERCPU.\n", wq->name);
- flags |= WQ_PERCPU;
+ pr_warn_once("workqueue: %s is using neither WQ_PERCPU or WQ_UNBOUND. "
+ "Setting WQ_UNBOUND.\n", wq->name);
+ flags |= WQ_UNBOUND;
} else if (unlikely((flags & WQ_PERCPU) && (flags & WQ_UNBOUND))) {
WARN_ONCE(1, "workqueue: %s uses both WQ_PERCPU and WQ_UNBOUND. "
"Dropped WQ_PERCPU, keeping WQ_UNBOUND.\n", wq->name);
--
2.55.0
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: [PATCH 1/2] workqueue: Make alloc_workqueue() unbound by default
2026-09-03 15:22 ` [PATCH 1/2] workqueue: Make alloc_workqueue() unbound by default Marco Crivellari
@ 2026-09-03 15:45 ` Marco Crivellari
0 siblings, 0 replies; 4+ messages in thread
From: Marco Crivellari @ 2026-09-03 15:45 UTC (permalink / raw)
To: linux-kernel
Cc: Tejun Heo, Lai Jiangshan, Frederic Weisbecker,
Sebastian Andrzej Siewior, Michal Hocko, Breno Leitao
Hi,
On Thu, Sep 3, 2026 at 5:22 PM Marco Crivellari
<marco.crivellari@suse.com> wrote:
> [...]
> if (unlikely(!(flags & (WQ_UNBOUND | WQ_PERCPU)))) {
> - WARN_ONCE(1, "workqueue: %s is using neither WQ_PERCPU or WQ_UNBOUND. "
> - "Setting WQ_PERCPU.\n", wq->name);
> - flags |= WQ_PERCPU;
> + pr_warn_once("workqueue: %s is using neither WQ_PERCPU or WQ_UNBOUND. "
> + "Setting WQ_UNBOUND.\n", wq->name);
> + flags |= WQ_UNBOUND;
> } else if (unlikely((flags & WQ_PERCPU) && (flags & WQ_UNBOUND))) {
> WARN_ONCE(1, "workqueue: %s uses both WQ_PERCPU and WQ_UNBOUND. "
> "Dropped WQ_PERCPU, keeping WQ_UNBOUND.\n", wq->name);
Please ignore the patch, I will send a v2.
This will cause issues because wq_size is calculated before:
5911 if (flags & WQ_UNBOUND)
5912 wq_size = struct_size(wq, node_nr_active, nr_node_ids + 1);
5913 else
5914 wq_size = sizeof(*wq);
5915
5916 wq = kzalloc_noprof(wq_size, GFP_KERNEL);
5917 if (!wq)
5918 return NULL;
Thanks, and sorry for the noise!
--
Marco Crivellari
SUSE Labs
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH 2/2] doc: Update WQ_UNBOUND documentation
2026-09-03 15:22 [PATCH 0/2] workqueue: Make WQ_UNBOUND the default behavior Marco Crivellari
2026-09-03 15:22 ` [PATCH 1/2] workqueue: Make alloc_workqueue() unbound by default Marco Crivellari
@ 2026-09-03 15:22 ` Marco Crivellari
1 sibling, 0 replies; 4+ messages in thread
From: Marco Crivellari @ 2026-09-03 15:22 UTC (permalink / raw)
To: linux-kernel
Cc: Tejun Heo, Lai Jiangshan, Frederic Weisbecker,
Sebastian Andrzej Siewior, Marco Crivellari, Michal Hocko,
Breno Leitao
When WQ_PERCPU is not present the default behavior is now WQ_UNBOUND,
so update the documentation, reflecting this change.
Link: https://lore.kernel.org/all/20250221112003.1dSuoGyc@linutronix.de/
Suggested-by: Tejun Heo <tj@kernel.org>
Signed-off-by: Marco Crivellari <marco.crivellari@suse.com>
---
Documentation/core-api/workqueue.rst | 2 ++
1 file changed, 2 insertions(+)
diff --git a/Documentation/core-api/workqueue.rst b/Documentation/core-api/workqueue.rst
index bb770f556568..3ca636e065ef 100644
--- a/Documentation/core-api/workqueue.rst
+++ b/Documentation/core-api/workqueue.rst
@@ -206,6 +206,8 @@ resources, scheduled and executed.
* Long running CPU intensive workloads which can be better
managed by the system scheduler.
+ Workqueue without ``WQ_PERCPU`` are unbound by default.
+
``WQ_FREEZABLE``
A freezable wq participates in the freeze phase of the system
suspend operations. Work items on the wq are drained and no
--
2.55.0
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2026-09-03 15:45 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-09-03 15:22 [PATCH 0/2] workqueue: Make WQ_UNBOUND the default behavior Marco Crivellari
2026-09-03 15:22 ` [PATCH 1/2] workqueue: Make alloc_workqueue() unbound by default Marco Crivellari
2026-09-03 15:45 ` Marco Crivellari
2026-09-03 15:22 ` [PATCH 2/2] doc: Update WQ_UNBOUND documentation Marco Crivellari
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®