mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Christoph Hellwig <hch@lst.de>
To: tj@kernel.org
Cc: jiangshanlai@gmail.com, linux-kernel@vger.kernel.org
Subject: [PATCH] workqueue: improve the draining/destroying warning in __queue_work
Date: Tue,  3 Nov 2026 15:33:45 +0100	[thread overview]
Message-ID: <20261103143345.3803307-1-hch@lst.de> (raw)

Tell which of the two conditions hit.  And to avoid makign the code even
harder to read, move the WARN_ONCE out of the condition triggering it.

Signed-off-by: Christoph Hellwig <hch@lst.de>
---
 kernel/workqueue.c | 14 +++++++++-----
 1 file changed, 9 insertions(+), 5 deletions(-)

diff --git a/kernel/workqueue.c b/kernel/workqueue.c
index f2e8071a6f4e..bea294b00d1f 100644
--- a/kernel/workqueue.c
+++ b/kernel/workqueue.c
@@ -2428,15 +2428,19 @@ static void __queue_work(int cpu, struct workqueue_struct *wq,
 	lockdep_assert_irqs_disabled();
 
 	/*
-	 * For a draining wq, only works from the same workqueue are
-	 * allowed. The __WQ_DESTROYING helps to spot the issue that
-	 * queues a new work item to a wq after destroy_workqueue(wq).
+	 * For a draining wq, only works from the same workqueue are allowed.
+	 * The __WQ_DESTROYING helps to spot the issue that queues a new work
+	 * item to a wq after destroy_workqueue(wq).
 	 */
 	if (unlikely(wq->flags & (__WQ_DESTROYING | __WQ_DRAINING) &&
-		     WARN_ONCE(!is_chained_work(wq), "workqueue: cannot queue %ps on wq %s\n",
-			       work->func, wq->name))) {
+			!is_chained_work(wq))) {
 		struct work_offq_data offqd;
 
+		WARN_ONCE(1, "workqueue: cannot queue %ps on %s wq %s\n",
+			work->func, (wq->flags & __WQ_DESTROYING) ?
+				"destroying" : "draining",
+			wq->name);
+
 		/*
 		 * State on entry: PENDING is set, work is off-queue (no
 		 * insert_work() has run).
-- 
2.53.0


                 reply	other threads:[~2026-11-03 14:33 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20261103143345.3803307-1-hch@lst.de \
    --to=hch@lst.de \
    --cc=jiangshanlai@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --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®