The patch titled Subject: kthread_worker: check all delayed works when destroy kthread worker has been added to the -mm mm-nonmm-unstable branch. Its filename is kthread_worker-check-all-delayed-works-when-destroy-kthread-worker.patch This patch will shortly appear at https://git.kernel.org/pub/scm/linux/kernel/git/akpm/25-new.git/tree/patches/kthread_worker-check-all-delayed-works-when-destroy-kthread-worker.patch This patch will later appear in the mm-nonmm-unstable branch at git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm Before you just go and hit "reply", please: a) Consider who else should be cc'ed b) Prefer to cc a suitable mailing list as well c) Ideally: find the original patch on the mailing list and do a reply-to-all to that, adding suitable additional cc's *** Remember to use Documentation/process/submit-checklist.rst when testing your code *** The -mm tree is included into linux-next via the mm-everything branch at git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm and is updated there every 2-3 working days ------------------------------------------------------ From: Zqiang <qiang1.zhang@xxxxxxxxx> Subject: kthread_worker: check all delayed works when destroy kthread worker Date: Wed, 4 Jan 2023 22:42:30 +0800 When destroying a kthread worker warn if there are still some pending delayed works. This indicates that the caller should clear all pending delayed works before destroying the kthread worker. Link: https://lkml.kernel.org/r/20230104144230.938521-1-qiang1.zhang@xxxxxxxxx Signed-off-by: Zqiang <qiang1.zhang@xxxxxxxxx> Acked-by: Tejun Heo <tj@xxxxxxxxxx> Cc: Petr Mladek <pmladek@xxxxxxxx> Signed-off-by: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx> --- kernel/kthread.c | 5 +++++ 1 file changed, 5 insertions(+) --- a/kernel/kthread.c~kthread_worker-check-all-delayed-works-when-destroy-kthread-worker +++ a/kernel/kthread.c @@ -1382,6 +1382,10 @@ EXPORT_SYMBOL_GPL(kthread_flush_worker); * Flush and destroy @worker. The simple flush is enough because the kthread * worker API is used only in trivial scenarios. There are no multi-step state * machines needed. + * + * Note that this function is not responsible for handling delayed work, so + * caller should be responsible for queuing or canceling all delayed work items + * before invoke this function. */ void kthread_destroy_worker(struct kthread_worker *worker) { @@ -1393,6 +1397,7 @@ void kthread_destroy_worker(struct kthre kthread_flush_worker(worker); kthread_stop(task); + WARN_ON(!list_empty(&worker->delayed_work_list)); WARN_ON(!list_empty(&worker->work_list)); kfree(worker); } _ Patches currently in -mm which might be from qiang1.zhang@xxxxxxxxx are kthread_worker-check-all-delayed-works-when-destroy-kthread-worker.patch