]> www.infradead.org Git - users/hch/xfs.git/commitdiff
workqueue: Make rescuer initialization as the last step of the creation of a new wq
authorLai Jiangshan <jiangshan.ljs@antgroup.com>
Thu, 4 Jul 2024 03:49:11 +0000 (11:49 +0800)
committerTejun Heo <tj@kernel.org>
Fri, 5 Jul 2024 19:14:40 +0000 (09:14 -1000)
For early wq allocation, rescuer initialization is the last step of the
creation of a new wq.  Make the behavior the same for all allocations.

Prepare for initializing rescuer's affinities with the default pwq's
affinities.

Prepare for moving the whole workqueue initializing procedure into
wq_pool_mutex and cpu hotplug locks.

Cc: Juri Lelli <juri.lelli@redhat.com>
Cc: Waiman Long <longman@redhat.com>
Signed-off-by: Lai Jiangshan <jiangshan.ljs@antgroup.com>
Signed-off-by: Tejun Heo <tj@kernel.org>
kernel/workqueue.c

index 5cb1dd0a49fbcf19394307112b8cd83f7fabc5e8..af00e63182d0a9b9b84ab424d430360f356debae 100644 (file)
@@ -5681,9 +5681,6 @@ struct workqueue_struct *alloc_workqueue(const char *fmt,
        if (alloc_and_link_pwqs(wq) < 0)
                goto err_free_node_nr_active;
 
-       if (wq_online && init_rescuer(wq) < 0)
-               goto err_destroy;
-
        /*
         * wq_pool_mutex protects global freeze state and workqueues list.
         * Grab it, adjust max_active and add the new @wq to workqueues
@@ -5699,6 +5696,9 @@ struct workqueue_struct *alloc_workqueue(const char *fmt,
 
        mutex_unlock(&wq_pool_mutex);
 
+       if (wq_online && init_rescuer(wq) < 0)
+               goto err_destroy;
+
        if ((wq->flags & WQ_SYSFS) && workqueue_sysfs_register(wq))
                goto err_destroy;