* [PATCH v2] kthread_worker: Check all delayed works when destroy kthread worker
@ 2023-01-04 14:42 Zqiang
2023-01-04 20:42 ` Tejun Heo
2023-01-06 12:40 ` Petr Mladek
0 siblings, 2 replies; 3+ messages in thread
From: Zqiang @ 2023-01-04 14:42 UTC (permalink / raw)
To: akpm, pmladek, tj; +Cc: linux-kernel
This commit add a check for delayed works, when destroy kthread worker
if there are still some pending delayed works will trigger warnning,
this remind caller should clear all pending delayed works before destroy
kthread worker.
Signed-off-by: Zqiang <qiang1.zhang@intel.com>
---
v1->v2:
Only add WARN_ON() and function description
kernel/kthread.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/kernel/kthread.c b/kernel/kthread.c
index f97fd01a2932..7e6751b29101 100644
--- a/kernel/kthread.c
+++ b/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 kthread_worker *worker)
kthread_flush_worker(worker);
kthread_stop(task);
+ WARN_ON(!list_empty(&worker->delayed_work_list));
WARN_ON(!list_empty(&worker->work_list));
kfree(worker);
}
--
2.25.1
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH v2] kthread_worker: Check all delayed works when destroy kthread worker
2023-01-04 14:42 [PATCH v2] kthread_worker: Check all delayed works when destroy kthread worker Zqiang
@ 2023-01-04 20:42 ` Tejun Heo
2023-01-06 12:40 ` Petr Mladek
1 sibling, 0 replies; 3+ messages in thread
From: Tejun Heo @ 2023-01-04 20:42 UTC (permalink / raw)
To: Zqiang; +Cc: akpm, pmladek, linux-kernel
On Wed, Jan 04, 2023 at 10:42:30PM +0800, Zqiang wrote:
> This commit add a check for delayed works, when destroy kthread worker
> if there are still some pending delayed works will trigger warnning,
> this remind caller should clear all pending delayed works before destroy
> kthread worker.
>
> Signed-off-by: Zqiang <qiang1.zhang@intel.com>
Acked-by: Tejun Heo <tj@kernel.org>
Andrew, can you please pick up this one? If you'd prefer it to be routed
through the workqueue tree, please let me know.
Thanks.
--
tejun
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH v2] kthread_worker: Check all delayed works when destroy kthread worker
2023-01-04 14:42 [PATCH v2] kthread_worker: Check all delayed works when destroy kthread worker Zqiang
2023-01-04 20:42 ` Tejun Heo
@ 2023-01-06 12:40 ` Petr Mladek
1 sibling, 0 replies; 3+ messages in thread
From: Petr Mladek @ 2023-01-06 12:40 UTC (permalink / raw)
To: Zqiang; +Cc: akpm, tj, linux-kernel
On Wed 2023-01-04 22:42:30, Zqiang wrote:
> This commit add a check for delayed works, when destroy kthread worker
> if there are still some pending delayed works will trigger warnning,
> this remind caller should clear all pending delayed works before destroy
> kthread worker.
>
> Signed-off-by: Zqiang <qiang1.zhang@intel.com>
Reviewed-by: Petr Mladek <pmladek@suse.com>
Best Regards,
Petr
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2023-01-06 12:40 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-01-04 14:42 [PATCH v2] kthread_worker: Check all delayed works when destroy kthread worker Zqiang
2023-01-04 20:42 ` Tejun Heo
2023-01-06 12:40 ` Petr Mladek
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®