Skip to contentSkip to conversation

kthread: work could not be queued when worker being destroyed

PATCH Superseded [email protected] 2 participants 2 messages Jul 3, 2020

v1 of 4 Superseded Latest is v4 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 kthread: work could not be queued when worker being destroyed

From: Zhang Qiang <[email protected]>

The queuing_blocked func should returns true when the worker being destroyed.

---
 kernel/kthread.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/kthread.c +1 -1
index 1166f2043e67..2ca711d0e78a 100644
@@ -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,
Signature · 1 line
2.24.1
#1 lore raw
Quoted 4 lines · On Thu 2020-07-02 12:49:46, [email protected] wrote:

From: Zhang Qiang <[email protected]>

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.

kernel/kthread.c static inline bool queuing_blocked(struct kthread_worker *worker, · line 792

Quoted 12 lines
---
 kernel/kthread.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/kthread.c +0 -0
index 1166f2043e67..2ca711d0e78a 100644
@@ -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;

kernel/kthread.c static inline bool queuing_blocked(struct kthread_worker *worker, · line 797

Quoted 5 lines
kernel/kthread.c +1 -1
-	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