Skip to content

Commit 24cdab5

Browse files
Philipp Stannerhtejun
authored andcommitted
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>
1 parent 8ffd015 commit 24cdab5

1 file changed

Lines changed: 11 additions & 0 deletions

File tree

kernel/workqueue.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5837,6 +5837,17 @@ static bool pwq_busy(struct pool_workqueue *pwq)
58375837
* @wq: target workqueue
58385838
*
58395839
* Safely destroy a workqueue. All work currently pending will be done first.
5840+
*
5841+
* This function does NOT guarantee that non-pending work that has been
5842+
* submitted with queue_delayed_work() and similar functions will be done
5843+
* before destroying the workqueue. The fundamental problem is that, currently,
5844+
* the workqueue has no way of accessing non-pending delayed_work. delayed_work
5845+
* is only linked on the timer-side. All delayed_work must, therefore, be
5846+
* canceled before calling this function.
5847+
*
5848+
* TODO: It would be better if the problem described above wouldn't exist and
5849+
* destroy_workqueue() would cleanly cancel all pending and non-pending
5850+
* delayed_work.
58405851
*/
58415852
void destroy_workqueue(struct workqueue_struct *wq)
58425853
{

0 commit comments

Comments
 (0)