[PATCH 1/5] workqueue: move the unbound-only attrs check to apply_workqueue_attrs()

From: Breno Leitao

Date: Wed Aug 19 2026 - 10:38:00 EST


apply_workqueue_attrs_locked() refuses any workqueue without WQ_UNBOUND.
That is the right rule for changing a workqueue's attributes, but it also
blocks the internal callers, and building a percpu workqueue's pwq table
through this path needs them.

Move the check into apply_workqueue_attrs(), the exported entry point,
which is the one that changes attributes on a live workqueue.

Signed-off-by: Breno Leitao <leitao@xxxxxxxxxx>
---
kernel/workqueue.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/kernel/workqueue.c b/kernel/workqueue.c
index 59b0106624e24..632d3f75f0c96 100644
--- a/kernel/workqueue.c
+++ b/kernel/workqueue.c
@@ -5568,10 +5568,6 @@ static int apply_workqueue_attrs_locked(struct workqueue_struct *wq,
{
struct apply_wqattrs_ctx *ctx;

- /* only unbound workqueues can change attributes */
- if (WARN_ON(!(wq->flags & WQ_UNBOUND)))
- return -EINVAL;
-
ctx = apply_wqattrs_prepare(wq, attrs, wq_unbound_cpumask);
if (IS_ERR(ctx))
return PTR_ERR(ctx);
@@ -5603,6 +5599,10 @@ int apply_workqueue_attrs(struct workqueue_struct *wq,
{
int ret;

+ /* only unbound workqueues can change attributes */
+ if (WARN_ON(!(wq->flags & WQ_UNBOUND)))
+ return -EINVAL;
+
mutex_lock(&wq_pool_mutex);
ret = apply_workqueue_attrs_locked(wq, attrs);
mutex_unlock(&wq_pool_mutex);

--
2.53.0-Meta