[PATCH 1/2] workqueue: Make alloc_workqueue() unbound by default

From: Marco Crivellari

Date: Thu Sep 03 2026 - 11:39:09 EST


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@xxxxxxxxxxxxx/
Suggested-by: Tejun Heo <tj@xxxxxxxxxx>
Signed-off-by: Marco Crivellari <marco.crivellari@xxxxxxxx>
---
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