kthread_work: wake up worker only when the worker is idle
authorLai Jiangshan <laijs@cn.fujitsu.com>
Sat, 26 Jul 2014 04:03:59 +0000 (12:03 +0800)
committerTejun Heo <tj@kernel.org>
Mon, 28 Jul 2014 18:07:52 +0000 (14:07 -0400)
If the worker is already executing a work item when another is queued,
we can safely skip wakeup without worrying about stalling queue thus
avoiding waking up the busy worker spuriously.  Spurious wakeups
should be fine but still isn't nice and avoiding it is trivial here.

tj: Updated description.

Signed-off-by: Lai Jiangshan <laijs@cn.fujitsu.com>
Signed-off-by: Tejun Heo <tj@kernel.org>
kernel/kthread.c

index c2390f41307bca58cdd9b14bb9530d8a16c20e6c..ef483220e85564670600c9a3951e66fe20672bed 100644 (file)
@@ -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);
 }
 
This page took 0.03953 seconds and 5 git commands to generate.