diff options
author | Lai Jiangshan <jiangshan.ljs@antgroup.com> | 2024-07-04 11:49:12 +0800 |
---|---|---|
committer | Tejun Heo <tj@kernel.org> | 2024-07-05 09:14:40 -1000 |
commit | 4e9a37389ec2d062e02f6647d1d60c3d11150896 (patch) | |
tree | 73079fc53051442ab7546240d8762af497a3399b /kernel/workqueue.c | |
parent | c5178e6ca6c8063edc103b75f410add7e4565e63 (diff) |
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>
Diffstat (limited to 'kernel/workqueue.c')
-rw-r--r-- | kernel/workqueue.c | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/kernel/workqueue.c b/kernel/workqueue.c index af00e63182d0..ab0aca0ccc8f 100644 --- a/kernel/workqueue.c +++ b/kernel/workqueue.c @@ -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); |