Commit 4e9a3738 authored by Lai Jiangshan's avatar Lai Jiangshan Committed by Tejun Heo

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: default avatarLai Jiangshan <jiangshan.ljs@antgroup.com>
Signed-off-by: default avatarTejun Heo <tj@kernel.org>
parent c5178e6c
...@@ -5467,12 +5467,6 @@ static int alloc_and_link_pwqs(struct workqueue_struct *wq) ...@@ -5467,12 +5467,6 @@ static int alloc_and_link_pwqs(struct workqueue_struct *wq)
} }
cpus_read_unlock(); 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; return ret;
enomem: enomem:
...@@ -5705,8 +5699,15 @@ struct workqueue_struct *alloc_workqueue(const char *fmt, ...@@ -5705,8 +5699,15 @@ struct workqueue_struct *alloc_workqueue(const char *fmt,
return wq; return wq;
err_free_node_nr_active: 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); free_node_nr_active(wq->node_nr_active);
}
err_unreg_lockdep: err_unreg_lockdep:
wq_unregister_lockdep(wq); wq_unregister_lockdep(wq);
wq_free_lockdep(wq); wq_free_lockdep(wq);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment