Skip to content

Commit 13b1d62

Browse files
Lai Jiangshanhtejun
authored andcommitted
workqueue: move rescuer pool detachment to the end
In 51697d3 ("workqueue: use generic attach/detach routine for rescuers"), The rescuer detaches itself from the pool before put_pwq() so that the put_unbound_pool() will not destroy the rescuer-attached pool. It is unnecessary. worker_detach_from_pool() can be used as the last statement to access to the pool just like the regular workers, put_unbound_pool() will wait for it to detach and then free the pool. So we move the worker_detach_from_pool() down, make it coincide with the regular workers. tj: Minor description update. Signed-off-by: Lai Jiangshan <[email protected]> Signed-off-by: Tejun Heo <[email protected]>
1 parent 051e185 commit 13b1d62

File tree

1 file changed

+6
-8
lines changed

1 file changed

+6
-8
lines changed

kernel/workqueue.c

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2253,15 +2253,10 @@ static int rescuer_thread(void *__rescuer)
22532253
move_linked_works(work, scheduled, &n);
22542254

22552255
process_scheduled_works(rescuer);
2256-
spin_unlock_irq(&pool->lock);
2257-
2258-
worker_detach_from_pool(rescuer, pool);
2259-
2260-
spin_lock_irq(&pool->lock);
22612256

22622257
/*
22632258
* Put the reference grabbed by send_mayday(). @pool won't
2264-
* go away while we're holding its lock.
2259+
* go away while we're still attached to it.
22652260
*/
22662261
put_pwq(pwq);
22672262

@@ -2274,8 +2269,11 @@ static int rescuer_thread(void *__rescuer)
22742269
wake_up_worker(pool);
22752270

22762271
rescuer->pool = NULL;
2277-
spin_unlock(&pool->lock);
2278-
spin_lock(&wq_mayday_lock);
2272+
spin_unlock_irq(&pool->lock);
2273+
2274+
worker_detach_from_pool(rescuer, pool);
2275+
2276+
spin_lock_irq(&wq_mayday_lock);
22792277
}
22802278

22812279
spin_unlock_irq(&wq_mayday_lock);

0 commit comments

Comments
 (0)