Skip to content

Commit a489a03

Browse files
Lai Jiangshanhtejun
authored andcommitted
workqueue: remove an unneeded UNBOUND test before waking up the next worker
In process_one_work(): if ((worker->flags & WORKER_UNBOUND) && need_more_worker(pool)) wake_up_worker(pool); the first test is unneeded. Even if the first test is removed, it doesn't affect the wake-up logic for WORKER_UNBOUND, and it will not introduce any useless wake-ups for normal per-cpu workers since nr_running is always >= 1. It will introduce useless/redundant wake-ups for CPU_INTENSIVE, but this case is rare and the next patch will also remove this redundant wake-up. tj: Minor updates to the description and comment. Signed-off-by: Lai Jiangshan <[email protected]> Signed-off-by: Tejun Heo <[email protected]>
1 parent d8ca83e commit a489a03

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

kernel/workqueue.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2048,10 +2048,13 @@ __acquires(&pool->lock)
20482048
worker_set_flags(worker, WORKER_CPU_INTENSIVE, true);
20492049

20502050
/*
2051-
* Unbound pool isn't concurrency managed and work items should be
2052-
* executed ASAP. Wake up another worker if necessary.
2051+
* Wake up another worker if necessary. The condition is always
2052+
* false for normal per-cpu workers since nr_running would always
2053+
* be >= 1 at this point. This is used to chain execution of the
2054+
* pending work items for WORKER_NOT_RUNNING workers such as the
2055+
* UNBOUND ones.
20532056
*/
2054-
if ((worker->flags & WORKER_UNBOUND) && need_more_worker(pool))
2057+
if (need_more_worker(pool))
20552058
wake_up_worker(pool);
20562059

20572060
/*

0 commit comments

Comments
 (0)