public inbox for [email protected]
 help / color / mirror / Atom feed
From: Pavel Begunkov <[email protected]>
To: [email protected]
Cc: Jens Axboe <[email protected]>, [email protected]
Subject: [PATCH for-next 8/9] io_uring: don't reinstall quiesce node for each tw
Date: Wed, 30 Nov 2022 15:21:58 +0000	[thread overview]
Message-ID: <3895d3344164cd9b3a0bbb24a6e357e20a13434b.1669821213.git.asml.silence@gmail.com> (raw)
In-Reply-To: <[email protected]>

There is no need to reinit data and install a new rsrc node every time
we get a task_work, it's detrimental, just execute it and conitnue
waiting.

Signed-off-by: Pavel Begunkov <[email protected]>
---
 io_uring/rsrc.c | 38 ++++++++++++++++++--------------------
 1 file changed, 18 insertions(+), 20 deletions(-)

diff --git a/io_uring/rsrc.c b/io_uring/rsrc.c
index b36d32534165..d25309400a45 100644
--- a/io_uring/rsrc.c
+++ b/io_uring/rsrc.c
@@ -309,22 +309,27 @@ __cold static int io_rsrc_ref_quiesce(struct io_rsrc_data *data,
 	/* As we may drop ->uring_lock, other task may have started quiesce */
 	if (data->quiesce)
 		return -ENXIO;
+	ret = io_rsrc_node_switch_start(ctx);
+	if (ret)
+		return ret;
+	io_rsrc_node_switch(ctx, data);
+
+	/* kill initial ref, already quiesced if zero */
+	if (atomic_dec_and_test(&data->refs))
+		return 0;
 
 	data->quiesce = true;
+	mutex_unlock(&ctx->uring_lock);
 	do {
-		ret = io_rsrc_node_switch_start(ctx);
-		if (ret)
-			break;
-		io_rsrc_node_switch(ctx, data);
-
-		/* kill initial ref, already quiesced if zero */
-		if (atomic_dec_and_test(&data->refs))
-			break;
-		mutex_unlock(&ctx->uring_lock);
-
 		ret = io_run_task_work_sig(ctx);
-		if (ret < 0)
-			goto reinit;
+		if (ret < 0) {
+			atomic_inc(&data->refs);
+			/* wait for all works potentially completing data->done */
+			flush_delayed_work(&ctx->rsrc_put_work);
+			reinit_completion(&data->done);
+			mutex_lock(&ctx->uring_lock);
+			break;
+		}
 
 		flush_delayed_work(&ctx->rsrc_put_work);
 		ret = wait_for_completion_interruptible(&data->done);
@@ -338,14 +343,7 @@ __cold static int io_rsrc_ref_quiesce(struct io_rsrc_data *data,
 			 */
 			mutex_unlock(&ctx->uring_lock);
 		}
-reinit:
-		atomic_inc(&data->refs);
-		/* wait for all works potentially completing data->done */
-		flush_delayed_work(&ctx->rsrc_put_work);
-		reinit_completion(&data->done);
-
-		mutex_lock(&ctx->uring_lock);
-	} while (ret >= 0);
+	} while (1);
 	data->quiesce = false;
 
 	return ret;
-- 
2.38.1


  parent reply	other threads:[~2022-11-30 15:23 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-11-30 15:21 [PATCH for-next 0/9] poll & rsrc quiesce improvements Pavel Begunkov
2022-11-30 15:21 ` [PATCH for-next 1/9] io_uring: kill io_poll_issue's PF_EXITING check Pavel Begunkov
2022-11-30 15:21 ` [PATCH for-next 2/9] io_uring: carve io_poll_check_events fast path Pavel Begunkov
2022-11-30 15:21 ` [PATCH for-next 3/9] io_uring: remove ctx variable in io_poll_check_events Pavel Begunkov
2022-11-30 15:21 ` [PATCH for-next 4/9] io_uring: imporve poll warning handling Pavel Begunkov
2022-11-30 15:21 ` [PATCH for-next 5/9] io_uring: combine poll tw handlers Pavel Begunkov
2022-11-30 15:21 ` [PATCH for-next 6/9] io_uring: don't raw spin unlock to match cq_lock Pavel Begunkov
2022-11-30 15:21 ` [PATCH for-next 7/9] io_uring: improve rsrc quiesce refs checks Pavel Begunkov
2022-11-30 15:21 ` Pavel Begunkov [this message]
2022-11-30 15:21 ` [PATCH for-next 9/9] io_uring: reshuffle issue_flags Pavel Begunkov
2022-11-30 18:07 ` [PATCH for-next 0/9] poll & rsrc quiesce improvements 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=3895d3344164cd9b3a0bbb24a6e357e20a13434b.1669821213.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