* [PATCH] kthread: work could not be queued when worker being destroyed
@ 2020-07-02 4:49 qiang.zhang
2020-07-03 8:11 ` Petr Mladek
0 siblings, 1 reply; 2+ messages in thread
From: qiang.zhang @ 2020-07-02 4:49 UTC (permalink / raw)
To: ben.dooks, bfields, cl, peterz, pmladek, tj; +Cc: linux-kernel
From: Zhang Qiang <qiang.zhang@windriver.com>
The queuing_blocked func should returns true when the worker
being destroyed.
Signed-off-by: Zhang Qiang <qiang.zhang@windriver.com>
---
kernel/kthread.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/kernel/kthread.c b/kernel/kthread.c
index 1166f2043e67..2ca711d0e78a 100644
--- a/kernel/kthread.c
+++ b/kernel/kthread.c
@@ -791,7 +791,7 @@ static inline bool queuing_blocked(struct kthread_worker *worker,
{
lockdep_assert_held(&worker->lock);
- return !list_empty(&work->node) || work->canceling;
+ return !list_empty(&work->node) || work->canceling || !worker->task;
}
static void kthread_insert_work_sanity_check(struct kthread_worker *worker,
--
2.24.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] kthread: work could not be queued when worker being destroyed
2020-07-02 4:49 [PATCH] kthread: work could not be queued when worker being destroyed qiang.zhang
@ 2020-07-03 8:11 ` Petr Mladek
0 siblings, 0 replies; 2+ messages in thread
From: Petr Mladek @ 2020-07-03 8:11 UTC (permalink / raw)
To: qiang.zhang; +Cc: ben.dooks, bfields, cl, peterz, tj, linux-kernel
On Thu 2020-07-02 12:49:46, qiang.zhang@windriver.com wrote:
> From: Zhang Qiang <qiang.zhang@windriver.com>
>
> The queuing_blocked func should returns true when the worker
> being destroyed.
Queuing work when the worker is not running usually means
a bad design on the API user side. The work is never done
and some job has not finished correctly. We should not go
over it quietly.
> Signed-off-by: Zhang Qiang <qiang.zhang@windriver.com>
> ---
> kernel/kthread.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/kernel/kthread.c b/kernel/kthread.c
> index 1166f2043e67..2ca711d0e78a 100644
> --- a/kernel/kthread.c
> +++ b/kernel/kthread.c
> @@ -791,7 +791,7 @@ static inline bool queuing_blocked(struct kthread_worker *worker,
> {
> lockdep_assert_held(&worker->lock);
A better solution would be:
if (WARN_ON(!worker->task)
return true;
> - return !list_empty(&work->node) || work->canceling;
> + return !list_empty(&work->node) || work->canceling || !worker->task;
> }
>
> static void kthread_insert_work_sanity_check(struct kthread_worker *worker,
Best Regards,
Petr
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2020-07-03 8:11 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-07-02 4:49 [PATCH] kthread: work could not be queued when worker being destroyed qiang.zhang
2020-07-03 8:11 ` Petr Mladek
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).