Skip to content

Commit

Permalink
workqueue: fix worker management invocation without pending works
Browse files Browse the repository at this point in the history
When there's no pending work to do, worker_thread() goes back to sleep
after waking up without checking whether worker management is
necessary.  This means that idle worker exit requests can be ignored
if the gcwq stays empty.

Fix it by making worker_thread() always check whether worker
management is necessary before going to sleep.

Signed-off-by: Tejun Heo <tj@kernel.org>
  • Loading branch information
Tejun Heo committed Jul 2, 2010
1 parent a1e453d commit d313dd8
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions kernel/workqueue.c
Original file line number Diff line number Diff line change
Expand Up @@ -1832,10 +1832,10 @@ static int worker_thread(void *__worker)
} while (keep_working(gcwq));

worker_set_flags(worker, WORKER_PREP, false);

sleep:
if (unlikely(need_to_manage_workers(gcwq)) && manage_workers(worker))
goto recheck;
sleep:

/*
* gcwq->lock is held and there's no work to process and no
* need to manage, sleep. Workers are woken up only while
Expand Down

0 comments on commit d313dd8

Please sign in to comment.