mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Breno Leitao <leitao@debian.org>
To: Tejun Heo <tj@kernel.org>, Lai Jiangshan <jiangshanlai@gmail.com>
Cc: linux-kernel@vger.kernel.org, marco.crivellari@suse.com,
	 Breno Leitao <leitao@debian.org>,
	kernel-team@meta.com
Subject: [PATCH 3/3] workqueue: BUG_ON() instead of returning NULL in wq_node_nr_active()
Date: Wed, 12 Aug 2026 09:03:20 -0700	[thread overview]
Message-ID: <20260812-wq_fix-v1-3-f7effcfa8d37@debian.org> (raw)
In-Reply-To: <20260812-wq_fix-v1-0-f7effcfa8d37@debian.org>

wq_node_nr_active() warns and returns NULL when @wq is not unbound, but
every caller dereferences the result right away, so the WARN_ON_ONCE()
only moves the oops one frame up, as raised by Tejun.

Fix it by BUGing_ON() instead of this silly WARN_ON_ONCE();

Fixes: b72fdc651056 ("workqueue: account nr_active by the backing pool")
Suggested-by: Tejun Heo <tj@kernel.org>
Signed-off-by: Breno Leitao <leitao@debian.org>
---
 kernel/workqueue.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/kernel/workqueue.c b/kernel/workqueue.c
index 83aced28523b5..cbc416147dcaa 100644
--- a/kernel/workqueue.c
+++ b/kernel/workqueue.c
@@ -1625,8 +1625,7 @@ static bool is_percpu_pool(struct worker_pool *pool)
 static struct wq_node_nr_active *wq_node_nr_active(struct workqueue_struct *wq,
 						   int node)
 {
-	if (WARN_ON_ONCE(!(wq->flags & WQ_UNBOUND)))
-		return NULL;
+	BUG_ON(!(wq->flags & WQ_UNBOUND));
 
 	if (node == NUMA_NO_NODE)
 		node = nr_node_ids;

-- 
2.53.0-Meta


  parent reply	other threads:[~2026-08-12 16:06 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-12 16:03 [PATCH 0/3] workqueue: sparse and wq_node_nr_active() fixes Breno Leitao
2026-08-12 16:03 ` [PATCH 1/3] workqueue: use rcu_dereference_sched() in workqueue_congested() Breno Leitao
2026-08-12 16:03 ` [PATCH 2/3] workqueue: use RCU accessors when populating wq->cpu_pwq Breno Leitao
2026-08-12 16:03 ` Breno Leitao [this message]
2026-08-12 17:18 ` [PATCH 0/3] workqueue: sparse and wq_node_nr_active() fixes 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=20260812-wq_fix-v1-3-f7effcfa8d37@debian.org \
    --to=leitao@debian.org \
    --cc=jiangshanlai@gmail.com \
    --cc=kernel-team@meta.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=marco.crivellari@suse.com \
    --cc=tj@kernel.org \
    /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®