The Linux Kernel Mailing List
 help / color / mirror / Atom feed
From: Philipp Stanner <phasta@kernel.org>
To: Tejun Heo <tj@kernel.org>, Lai Jiangshan <jiangshanlai@gmail.com>
Cc: linux-kernel@vger.kernel.org, Philipp Stanner <phasta@kernel.org>
Subject: [PATCH] workqueue: Better document teardown for delayed_work
Date: Thu,  3 Apr 2025 10:31:56 +0200	[thread overview]
Message-ID: <20250403083155.37931-2-phasta@kernel.org> (raw)

destroy_workqueue() does not ensure that non-pending work submitted with
queue_delayed_work() gets cancelled. The caller has to ensure that
manually.

Add this information about delayed_work in destroy_workqueue()'s
docstring.

Signed-off-by: Philipp Stanner <phasta@kernel.org>
---
Hi,

I have seen this WARN_ON [1] fire in my code for testing the DRM GPU
Scheduler, where a (non-delayed) work_item from workqueue A submits
delayed_work to workqueue B [2].

From my experience so far and reading the documentation, I didn't expect
this to happen.

Assuming this is wanted behavior (?), I propose documenting this more
explicitly. Or could it be possible to modify destroy_workqueue() so
that it takes care of submitted delayed_work()?

Greetings,
P.

[1] https://elixir.bootlin.com/linux/v6.14-rc6/source/kernel/workqueue.c#L2257
[2] https://gitlab.freedesktop.org/pstanner/schedleaker/-/blob/goodmemmodell/schedleaker.c?ref_type=heads#L291
---
 kernel/workqueue.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/kernel/workqueue.c b/kernel/workqueue.c
index bfe030b443e2..5a30efe7ddeb 100644
--- a/kernel/workqueue.c
+++ b/kernel/workqueue.c
@@ -5837,6 +5837,9 @@ static bool pwq_busy(struct pool_workqueue *pwq)
  * @wq: target workqueue
  *
  * Safely destroy a workqueue. All work currently pending will be done first.
+ * This does not apply to non-pending work that was submitted with
+ * queue_delayed_work(). Such work must be cancelled manually before calling
+ * this function.
  */
 void destroy_workqueue(struct workqueue_struct *wq)
 {
-- 
2.48.1


             reply	other threads:[~2025-04-03  8:32 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-04-03  8:31 Philipp Stanner [this message]
2025-04-03 18:54 ` [PATCH] workqueue: Better document teardown for delayed_work 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=20250403083155.37931-2-phasta@kernel.org \
    --to=phasta@kernel.org \
    --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