* [PATCH v2] workqueue: Better document teardown for delayed_work
@ 2025-04-04 10:15 Philipp Stanner
2025-04-04 18:48 ` Tejun Heo
0 siblings, 1 reply; 2+ messages in thread
From: Philipp Stanner @ 2025-04-04 10:15 UTC (permalink / raw)
To: Tejun Heo, Lai Jiangshan; +Cc: linux-kernel, Philipp Stanner
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.
Add a TODO for destroy_workqueue() to wait for all delayed_work.
Signed-off-by: Philipp Stanner <phasta@kernel.org>
---
Changes in v2:
- Make it explicit what the problem is and tell the user what to do to
work around it. (Tejun)
- Add a TODO for handling delayed_work in the future. (Me)
---
kernel/workqueue.c | 11 +++++++++++
1 file changed, 11 insertions(+)
diff --git a/kernel/workqueue.c b/kernel/workqueue.c
index bfe030b443e2..a4d23c102f9f 100644
--- a/kernel/workqueue.c
+++ b/kernel/workqueue.c
@@ -5837,6 +5837,17 @@ static bool pwq_busy(struct pool_workqueue *pwq)
* @wq: target workqueue
*
* Safely destroy a workqueue. All work currently pending will be done first.
+ *
+ * This function does NOT guarantee that non-pending work that has been
+ * submitted with queue_delayed_work() and similar functions will be done
+ * before destroying the workqueue. The fundamental problem is that, currently,
+ * the workqueue has no way of accessing non-pending delayed_work. delayed_work
+ * is only linked on the timer-side. All delayed_work must, therefore, be
+ * canceled before calling this function.
+ *
+ * TODO: It would be better if the problem described above wouldn't exist and
+ * destroy_workqueue() would cleanly cancel all pending and non-pending
+ * delayed_work.
*/
void destroy_workqueue(struct workqueue_struct *wq)
{
--
2.48.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH v2] workqueue: Better document teardown for delayed_work
2025-04-04 10:15 [PATCH v2] workqueue: Better document teardown for delayed_work Philipp Stanner
@ 2025-04-04 18:48 ` Tejun Heo
0 siblings, 0 replies; 2+ messages in thread
From: Tejun Heo @ 2025-04-04 18:48 UTC (permalink / raw)
To: Philipp Stanner; +Cc: Lai Jiangshan, linux-kernel
On Fri, Apr 04, 2025 at 12:15:44PM +0200, Philipp Stanner wrote:
> 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.
>
> Add a TODO for destroy_workqueue() to wait for all delayed_work.
>
> Signed-off-by: Philipp Stanner <phasta@kernel.org>
Applied to wq/for-6.15-fixes.
Thanks.
--
tejun
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2025-04-04 18:48 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-04-04 10:15 [PATCH v2] workqueue: Better document teardown for delayed_work Philipp Stanner
2025-04-04 18:48 ` Tejun Heo
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.