From: Lai Jiangshan <jiangshanlai@gmail.com>
To: linux-kernel@vger.kernel.org
Cc: Lai Jiangshan <jiangshan.ljs@antgroup.com>,
Tejun Heo <tj@kernel.org>, Lai Jiangshan <jiangshanlai@gmail.com>
Subject: [PATCH 3/6] workqueue: Separate out destroy_rescuer()
Date: Wed, 3 Jul 2024 11:38:52 +0800 [thread overview]
Message-ID: <20240703033855.3373-4-jiangshanlai@gmail.com> (raw)
In-Reply-To: <20240703033855.3373-1-jiangshanlai@gmail.com>
From: Lai Jiangshan <jiangshan.ljs@antgroup.com>
Separate out destroy_rescuer() to simplify destroy_workqueue() and
prepare of reusing it in alloc_workqueue().
Signed-off-by: Lai Jiangshan <jiangshan.ljs@antgroup.com>
---
kernel/workqueue.c | 29 +++++++++++++++++------------
1 file changed, 17 insertions(+), 12 deletions(-)
diff --git a/kernel/workqueue.c b/kernel/workqueue.c
index cf1a129eb547..0dd9a12befb5 100644
--- a/kernel/workqueue.c
+++ b/kernel/workqueue.c
@@ -5548,6 +5548,22 @@ static int init_rescuer(struct workqueue_struct *wq)
return 0;
}
+static void destroy_rescuer(struct workqueue_struct *wq)
+{
+ struct worker *rescuer = wq->rescuer;
+
+ if (rescuer) {
+ /* this prevents new queueing */
+ raw_spin_lock_irq(&wq_mayday_lock);
+ wq->rescuer = NULL;
+ raw_spin_unlock_irq(&wq_mayday_lock);
+
+ /* rescuer will empty maydays list before exiting */
+ kthread_stop(rescuer->task);
+ kfree(rescuer);
+ }
+}
+
/**
* wq_adjust_max_active - update a wq's max_active to the current setting
* @wq: target workqueue
@@ -5772,18 +5788,7 @@ void destroy_workqueue(struct workqueue_struct *wq)
drain_workqueue(wq);
/* kill rescuer, if sanity checks fail, leave it w/o rescuer */
- if (wq->rescuer) {
- struct worker *rescuer = wq->rescuer;
-
- /* this prevents new queueing */
- raw_spin_lock_irq(&wq_mayday_lock);
- wq->rescuer = NULL;
- raw_spin_unlock_irq(&wq_mayday_lock);
-
- /* rescuer will empty maydays list before exiting */
- kthread_stop(rescuer->task);
- kfree(rescuer);
- }
+ destroy_rescuer(wq);
/*
* Sanity checks - grab all the locks so that we wait for all
--
2.19.1.6.gb485710b
next prev parent reply other threads:[~2024-07-03 3:36 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-07-03 3:38 [PATCH 0/6] workqueue: Make the PWQ allocation and WQ enlistment atomic Lai Jiangshan
2024-07-03 3:38 ` [PATCH 1/6] workqueue: Register sysfs after the whole creation of the new wq Lai Jiangshan
2024-07-03 3:38 ` [PATCH 2/6] workqueue: Protect wq_unbound_cpumask with wq_pool_attach_mutex in init_rescuer() Lai Jiangshan
2024-07-03 15:14 ` Waiman Long
2024-07-03 18:28 ` Tejun Heo
2024-07-03 3:38 ` Lai Jiangshan [this message]
2024-07-03 3:38 ` [PATCH 4/6] workqueue: Init rescuer before alloc and link pwqs Lai Jiangshan
2024-07-03 3:38 ` [PATCH 5/6] workqueue: Move kthread_flush_worker() out of alloc_and_link_pwqs() Lai Jiangshan
2024-07-03 3:38 ` [PATCH 6/6] workqueue: Put PWQ allocation and WQ enlistment in the same lock C.S Lai Jiangshan
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=20240703033855.3373-4-jiangshanlai@gmail.com \
--to=jiangshanlai@gmail.com \
--cc=jiangshan.ljs@antgroup.com \
--cc=linux-kernel@vger.kernel.org \
--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
all inboxes | Powered by JetHome®