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().
Showing the changes to kernel/workqueue.c (1 of 1 file). Show all
Unified · Split
| @@ -5467,12 +5467,6 @@ static int alloc_and_link_pwqs(struct workqueue_struct *wq) · 5466 unmodified lines | |||
| 5467 | } | 5467 | } |
| 5468 | cpus_read_unlock(); | 5468 | cpus_read_unlock(); |
| 5469 | 5469 | ||
| 5470 | /* for unbound pwq, flush the pwq_release_worker ensures that the | ||
| 5471 | * pwq_release_workfn() completes before calling kfree(wq). | ||
| 5472 | */ | ||
| 5473 | if (ret) | ||
| 5474 | kthread_flush_worker(pwq_release_worker); | ||
| 5475 | |||
| 5476 | return ret; | 5470 | return ret; |
| 5477 | 5471 | ||
| 5478 | enomem: | 5472 | enomem: |
| @@ -5705,8 +5699,15 @@ struct workqueue_struct *alloc_workqueue(const char *fmt, · 226 unmodified lines | |||
| 5705 | return wq; | 5699 | return wq; |
| 5706 | 5700 | ||
| 5707 | err_free_node_nr_active: | 5701 | err_free_node_nr_active: |
| 5708 | if (wq->flags & WQ_UNBOUND) | 5702 | /* |
| 5703 | * Failed alloc_and_link_pwqs() may leave pending pwq->release_work, | ||
| 5704 | * flushing the pwq_release_worker ensures that the pwq_release_workfn() | ||
| 5705 | * completes before calling kfree(wq). | ||
| 5706 | */ | ||
| 5707 | if (wq->flags & WQ_UNBOUND) { | ||
| 5708 | kthread_flush_worker(pwq_release_worker); | ||
| 5709 | free_node_nr_active(wq->node_nr_active); | 5709 | free_node_nr_active(wq->node_nr_active); |
| 5710 | } | ||
| 5710 | err_unreg_lockdep: | 5711 | err_unreg_lockdep: |
| 5711 | wq_unregister_lockdep(wq); | 5712 | wq_unregister_lockdep(wq); |
| 5712 | wq_free_lockdep(wq); | 5713 | wq_free_lockdep(wq); |