public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Lai Jiangshan <jiangshanlai@gmail.com>
To: linux-kernel@vger.kernel.org
Cc: Lai Jiangshan <jiangshan.ljs@antgroup.com>,
	Juri Lelli <juri.lelli@redhat.com>,
	Waiman Long <longman@redhat.com>, Tejun Heo <tj@kernel.org>,
	Lai Jiangshan <jiangshanlai@gmail.com>
Subject: [PATCH V2 5/5] workqueue: Init rescuer's affinities as the wq's effective cpumask
Date: Thu,  4 Jul 2024 11:49:14 +0800	[thread overview]
Message-ID: <20240704034915.2164-6-jiangshanlai@gmail.com> (raw)
In-Reply-To: <20240704034915.2164-1-jiangshanlai@gmail.com>

From: Lai Jiangshan <jiangshan.ljs@antgroup.com>

Make it consistent with apply_wqattrs_commit().

Link: https://lore.kernel.org/lkml/20240203154334.791910-5-longman@redhat.com/
Cc: Juri Lelli <juri.lelli@redhat.com>
Cc: Waiman Long <longman@redhat.com>
Signed-off-by: Lai Jiangshan <jiangshan.ljs@antgroup.com>
---
 kernel/workqueue.c | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/kernel/workqueue.c b/kernel/workqueue.c
index 5129934f274f..8b2a0fe4a85e 100644
--- a/kernel/workqueue.c
+++ b/kernel/workqueue.c
@@ -5525,6 +5525,8 @@ static int init_rescuer(struct workqueue_struct *wq)
 	struct worker *rescuer;
 	int ret;
 
+	lockdep_assert_held(&wq_pool_mutex);
+
 	if (!(wq->flags & WQ_MEM_RECLAIM))
 		return 0;
 
@@ -5547,7 +5549,7 @@ static int init_rescuer(struct workqueue_struct *wq)
 
 	wq->rescuer = rescuer;
 	if (wq->flags & WQ_UNBOUND)
-		kthread_bind_mask(rescuer->task, wq_unbound_cpumask);
+		kthread_bind_mask(rescuer->task, unbound_effective_cpumask(wq));
 	else
 		kthread_bind_mask(rescuer->task, cpu_possible_mask);
 	wake_up_process(rescuer->task);
@@ -5711,10 +5713,10 @@ struct workqueue_struct *alloc_workqueue(const char *fmt,
 
 	list_add_tail_rcu(&wq->list, &workqueues);
 
-	apply_wqattrs_unlock();
-
 	if (wq_online && init_rescuer(wq) < 0)
-		goto err_destroy;
+		goto err_unlock_destroy;
+
+	apply_wqattrs_unlock();
 
 	if ((wq->flags & WQ_SYSFS) && workqueue_sysfs_register(wq))
 		goto err_destroy;
@@ -5739,6 +5741,8 @@ struct workqueue_struct *alloc_workqueue(const char *fmt,
 	free_workqueue_attrs(wq->unbound_attrs);
 	kfree(wq);
 	return NULL;
+err_unlock_destroy:
+	apply_wqattrs_unlock();
 err_destroy:
 	destroy_workqueue(wq);
 	return NULL;
-- 
2.19.1.6.gb485710b


  parent reply	other threads:[~2024-07-04  3:46 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-07-04  3:49 [PATCH V2 0/5] workqueue: Make the PWQ allocation and WQ enlistment atomic Lai Jiangshan
2024-07-04  3:49 ` [PATCH V2 1/5] workqueue: Register sysfs after the whole creation of the new wq Lai Jiangshan
2024-07-04  3:49 ` [PATCH V2 2/5] workqueue: Make rescuer initialization as the last step of the creation of a " Lai Jiangshan
2024-07-04  3:49 ` [PATCH V2 3/5] workqueue: Move kthread_flush_worker() out of alloc_and_link_pwqs() Lai Jiangshan
2024-07-04  3:49 ` [PATCH V2 4/5] workqueue: Put PWQ allocation and WQ enlistment in the same lock C.S Lai Jiangshan
2024-07-08  7:54   ` kernel test robot
2024-07-08 18:16     ` Tejun Heo
2024-07-09 14:55       ` Lai Jiangshan
2024-07-04  3:49 ` Lai Jiangshan [this message]
2024-07-05 19:15 ` [PATCH V2 0/5] workqueue: Make the PWQ allocation and WQ enlistment atomic Tejun Heo

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240704034915.2164-6-jiangshanlai@gmail.com \
    --to=jiangshanlai@gmail.com \
    --cc=jiangshan.ljs@antgroup.com \
    --cc=juri.lelli@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=longman@redhat.com \
    --cc=tj@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox