From: Pavel Begunkov <[email protected]>
To: Jens Axboe <[email protected]>, [email protected]
Subject: [PATCH 1/1] io-wq: deduplicate destroying wq->manager
Date: Mon, 1 Mar 2021 20:15:55 +0000 [thread overview]
Message-ID: <d419494ff45686994526804a0b27e18f88da776b.1614629733.git.asml.silence@gmail.com> (raw)
Add a helper io_wq_destroy_manager(), for killing an io-wq manager and
not repeating it three times.
Signed-off-by: Pavel Begunkov <[email protected]>
---
fs/io-wq.c | 30 ++++++++++++------------------
1 file changed, 12 insertions(+), 18 deletions(-)
diff --git a/fs/io-wq.c b/fs/io-wq.c
index 9828722fdee9..c9d886d1a73c 100644
--- a/fs/io-wq.c
+++ b/fs/io-wq.c
@@ -1059,20 +1059,24 @@ struct io_wq *io_wq_create(unsigned bounded, struct io_wq_data *data)
return ERR_PTR(ret);
}
-static void io_wq_destroy(struct io_wq *wq)
+static void io_wq_destroy_manager(struct io_wq *wq)
{
- int node;
-
- cpuhp_state_remove_instance_nocalls(io_wq_online, &wq->cpuhp_node);
-
- set_bit(IO_WQ_BIT_EXIT, &wq->state);
if (wq->manager) {
wake_up_process(wq->manager);
wait_for_completion(&wq->exited);
put_task_struct(wq->manager);
wq->manager = NULL;
}
+}
+
+static void io_wq_destroy(struct io_wq *wq)
+{
+ int node;
+
+ cpuhp_state_remove_instance_nocalls(io_wq_online, &wq->cpuhp_node);
+ set_bit(IO_WQ_BIT_EXIT, &wq->state);
+ io_wq_destroy_manager(wq);
spin_lock_irq(&wq->hash->wait.lock);
for_each_node(node) {
struct io_wqe *wqe = wq->wqes[node];
@@ -1095,12 +1099,7 @@ void io_wq_put(struct io_wq *wq)
void io_wq_put_and_exit(struct io_wq *wq)
{
set_bit(IO_WQ_BIT_EXIT, &wq->state);
- if (wq->manager) {
- wake_up_process(wq->manager);
- wait_for_completion(&wq->exited);
- put_task_struct(wq->manager);
- wq->manager = NULL;
- }
+ io_wq_destroy_manager(wq);
io_wq_put(wq);
}
@@ -1146,12 +1145,7 @@ void io_wq_unshare(struct io_wq *wq)
{
refcount_inc(&wq->refs);
set_bit(IO_WQ_BIT_EXIT, &wq->state);
- if (wq->manager) {
- wake_up_process(wq->manager);
- wait_for_completion(&wq->exited);
- put_task_struct(wq->manager);
- wq->manager = NULL;
- }
+ io_wq_destroy_manager(wq);
clear_bit(IO_WQ_BIT_EXIT, &wq->state);
io_wq_put(wq);
}
--
2.24.0
next reply other threads:[~2021-03-01 20:24 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-03-01 20:15 Pavel Begunkov [this message]
2021-03-01 20:59 ` [PATCH 1/1] io-wq: deduplicate destroying wq->manager Jens Axboe
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=d419494ff45686994526804a0b27e18f88da776b.1614629733.git.asml.silence@gmail.com \
[email protected] \
[email protected] \
[email protected] \
/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