Skip to content

Commit b4ac938

Browse files
Lai Jiangshanhtejun
authored andcommitted
workqueue: Remove schedule() in unbind_workers()
The commit 6d25be5 ("sched/core, workqueues: Distangle worker accounting from rq lock") changed the schedule callbacks for workqueue and moved the schedule callback from the wakeup code to at end of schedule() in the worker's process context. It means that the callback wq_worker_running() is guaranteed that it sees the %WORKER_UNBOUND flag after scheduled since unbind_workers() is running on the same CPU that all the pool's workers bound to. Signed-off-by: Lai Jiangshan <[email protected]> Signed-off-by: Tejun Heo <[email protected]>
1 parent 11b45b0 commit b4ac938

File tree

1 file changed

+3
-8
lines changed

1 file changed

+3
-8
lines changed

kernel/workqueue.c

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4979,6 +4979,9 @@ static void unbind_workers(int cpu)
49794979
* We've blocked all attach/detach operations. Make all workers
49804980
* unbound and set DISASSOCIATED. Before this, all workers
49814981
* must be on the cpu. After this, they may become diasporas.
4982+
* And the preemption disabled section in their sched callbacks
4983+
* are guaranteed to see WORKER_UNBOUND since the code here
4984+
* is on the same cpu.
49824985
*/
49834986
for_each_pool_worker(worker, pool)
49844987
worker->flags |= WORKER_UNBOUND;
@@ -4994,14 +4997,6 @@ static void unbind_workers(int cpu)
49944997

49954998
mutex_unlock(&wq_pool_attach_mutex);
49964999

4997-
/*
4998-
* Call schedule() so that we cross rq->lock and thus can
4999-
* guarantee sched callbacks see the %WORKER_UNBOUND flag.
5000-
* This is necessary as scheduler callbacks may be invoked
5001-
* from other cpus.
5002-
*/
5003-
schedule();
5004-
50055000
/*
50065001
* Sched callbacks are disabled now. Zap nr_running.
50075002
* After this, nr_running stays zero and need_more_worker()

0 commit comments

Comments
 (0)