summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPhilipp Stanner <phasta@kernel.org>2025-04-04 12:15:44 +0200
committerTejun Heo <tj@kernel.org>2025-04-14 07:48:23 -1000
commit24cdab5787a0ae90260df1f8ac8284877a70b7b3 (patch)
treebb19f47a29462f023e9c4656c70d233705488f1b
parent8ffd015db85fea3e15a77027fda6c02ced4d2444 (diff)
workqueue: Better document teardown for delayed_work
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> Signed-off-by: Tejun Heo <tj@kernel.org>
-rw-r--r--kernel/workqueue.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/kernel/workqueue.c b/kernel/workqueue.c
index cf6203282737..2cb8276a27a9 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)
{