From: Lai Jiangshan Date: Sat, 26 Jul 2014 04:03:59 +0000 (+0800) Subject: kthread_work: wake up worker only when the worker is idle X-Git-Url: http://git.maquefel.me/?a=commitdiff_plain;h=ed1403ec2bd463050e481cd29be40c504021676c;p=linux.git kthread_work: wake up worker only when the worker is idle 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 Signed-off-by: Tejun Heo --- diff --git a/kernel/kthread.c b/kernel/kthread.c index c2390f41307bc..ef483220e8556 100644 --- a/kernel/kthread.c +++ b/kernel/kthread.c @@ -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); }