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 03/10] io_uring/rsrc: refactor io_rsrc_ref_quiesce
Date: Thu, 13 Apr 2023 15:28:07 +0100	[thread overview]
Message-ID: <65bc876271fb16bf550a53a4c76c91aacd94e52e.1681395792.git.asml.silence@gmail.com> (raw)
In-Reply-To: <[email protected]>

Refactor io_rsrc_ref_quiesce() by moving the first mutex_unlock(),
so we don't have to have a second mutex_unlock() further in the loop.
It prepares us to the next patch.

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

diff --git a/io_uring/rsrc.c b/io_uring/rsrc.c
index 5fc9d10743e0..d7e7528f7159 100644
--- a/io_uring/rsrc.c
+++ b/io_uring/rsrc.c
@@ -272,8 +272,8 @@ __cold static int io_rsrc_ref_quiesce(struct io_rsrc_data *data,
 		return 0;
 
 	data->quiesce = true;
-	mutex_unlock(&ctx->uring_lock);
 	do {
+		mutex_unlock(&ctx->uring_lock);
 		ret = io_run_task_work_sig(ctx);
 		if (ret < 0) {
 			mutex_lock(&ctx->uring_lock);
@@ -285,18 +285,10 @@ __cold static int io_rsrc_ref_quiesce(struct io_rsrc_data *data,
 			}
 			break;
 		}
-		ret = wait_for_completion_interruptible(&data->done);
-		if (!ret) {
-			mutex_lock(&ctx->uring_lock);
-			if (!data->refs)
-				break;
-			/*
-			 * it has been revived by another thread while
-			 * we were unlocked
-			 */
-			mutex_unlock(&ctx->uring_lock);
-		}
-	} while (1);
+		wait_for_completion_interruptible(&data->done);
+		mutex_lock(&ctx->uring_lock);
+		ret = 0;
+	} while (data->refs);
 	data->quiesce = false;
 
 	return ret;
-- 
2.40.0


  parent reply	other threads:[~2023-04-13 14:29 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-04-13 14:28 [PATCH for-6.4 00/10] some rsrc fixes and clean ups Pavel Begunkov
2023-04-13 14:28 ` [PATCH 01/10] io_uring/rsrc: use nospec'ed indexes Pavel Begunkov
2023-04-13 14:28 ` [PATCH 02/10] io_uring/rsrc: remove io_rsrc_node::done Pavel Begunkov
2023-04-13 14:28 ` Pavel Begunkov [this message]
2023-04-13 14:28 ` [PATCH 04/10] io_uring/rsrc: use wq for quiescing Pavel Begunkov
2023-04-13 14:28 ` [PATCH 05/10] io_uring/rsrc: fix DEFER_TASKRUN rsrc quiesce Pavel Begunkov
2023-04-13 14:28 ` [PATCH 06/10] io_uring/rsrc: remove rsrc_data refs Pavel Begunkov
2023-04-13 14:28 ` [PATCH 07/10] io_uring/rsrc: inline switch_start fast path Pavel Begunkov
2023-04-13 14:28 ` [PATCH 08/10] io_uring/rsrc: clean up __io_sqe_buffers_update() Pavel Begunkov
2023-04-13 14:28 ` [PATCH 09/10] io_uring/rsrc: simplify single file node switching Pavel Begunkov
2023-04-13 14:28 ` [PATCH 10/10] io_uring/rsrc: refactor io_queue_rsrc_removal Pavel Begunkov
2023-04-15 20:46 ` [PATCH for-6.4 00/10] some rsrc fixes and clean ups 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=65bc876271fb16bf550a53a4c76c91aacd94e52e.1681395792.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