workqueue: Move kthread_flush_worker() out of alloc_and_link_pwqs()
kthread_flush_worker() can't be called with wq_pool_mutex held. Prepare for moving wq_pool_mutex and cpu hotplug lock out of alloc_and_link_pwqs(). Cc: Zqiang <qiang.zhang1211@gmail.com> Link: https://lore.kernel.org/lkml/20230920060704.24981-1-qiang.zhang1211@gmail.com/ Signed-off-by: Lai Jiangshan <jiangshan.ljs@antgroup.com> Signed-off-by: Tejun Heo <tj@kernel.org>
This commit is contained in:
parent
c5178e6ca6
commit
4e9a37389e
@ -5467,12 +5467,6 @@ static int alloc_and_link_pwqs(struct workqueue_struct *wq)
|
||||
}
|
||||
cpus_read_unlock();
|
||||
|
||||
/* for unbound pwq, flush the pwq_release_worker ensures that the
|
||||
* pwq_release_workfn() completes before calling kfree(wq).
|
||||
*/
|
||||
if (ret)
|
||||
kthread_flush_worker(pwq_release_worker);
|
||||
|
||||
return ret;
|
||||
|
||||
enomem:
|
||||
@ -5705,8 +5699,15 @@ struct workqueue_struct *alloc_workqueue(const char *fmt,
|
||||
return wq;
|
||||
|
||||
err_free_node_nr_active:
|
||||
if (wq->flags & WQ_UNBOUND)
|
||||
/*
|
||||
* Failed alloc_and_link_pwqs() may leave pending pwq->release_work,
|
||||
* flushing the pwq_release_worker ensures that the pwq_release_workfn()
|
||||
* completes before calling kfree(wq).
|
||||
*/
|
||||
if (wq->flags & WQ_UNBOUND) {
|
||||
kthread_flush_worker(pwq_release_worker);
|
||||
free_node_nr_active(wq->node_nr_active);
|
||||
}
|
||||
err_unreg_lockdep:
|
||||
wq_unregister_lockdep(wq);
|
||||
wq_free_lockdep(wq);
|
||||
|
Loading…
x
Reference in New Issue
Block a user