Skip to contentSkip to conversation

kthread_work: wake up worker only when the worker is idle

PATCH Applied Lai Jiangshan 2 participants 2 messages Jul 26, 2014 – Jul 28, 2014

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 kthread_work: wake up worker only when the worker is idle

If the worker task is not idle, it may sleep on some conditions by the request of the work. Our unfriendly wakeup in the insert_kthread_work() may confuse the worker.

---
 kernel/kthread.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
kernel/kthread.c +1 -1
index c2390f4..ef48322 100644
@@ -591,7 +591,7 @@ static void insert_kthread_work(struct kthread_worker *worker,
 
 	list_add_tail(&work->node, pos);
 	work->worker = worker;
-	if (likely(worker->task))
+	if (!worker->current_work && likely(worker->task))
 		wake_up_process(worker->task);
 }
 
Signature · 1 line
1.7.4.4
Applied
#1 lore raw
Quoted 5 lines · Lai Jiangshan

If the worker task is not idle, it may sleep on some conditions by the request of the work. Our unfriendly wakeup in the insert_kthread_work() may confuse the worker.

Applied to wq/for-3.17.

Thanks.

Signature · 1 line
tejun