public inbox for [email protected]
 help / color / mirror / Atom feed
From: Pavel Begunkov <[email protected]>
To: Jens Axboe <[email protected]>, [email protected]
Subject: [PATCH v2 3/3] io_uring: briefly loose locks while reaping events
Date: Mon,  6 Jul 2020 17:59:31 +0300	[thread overview]
Message-ID: <e454be4ccca6059df91a691b64f4fd40578925de.1594047465.git.asml.silence@gmail.com> (raw)
In-Reply-To: <[email protected]>

It's not nice to hold @uring_lock for too long io_iopoll_reap_events().
For instance, the lock is needed to publish requests to @poll_list, and
that locks out tasks doing that for no good reason. Loose it
occasionally.

Signed-off-by: Pavel Begunkov <[email protected]>
---
 fs/io_uring.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/fs/io_uring.c b/fs/io_uring.c
index 020944a193d0..54756ae94bcd 100644
--- a/fs/io_uring.c
+++ b/fs/io_uring.c
@@ -2062,8 +2062,13 @@ static void io_iopoll_reap_events(struct io_ring_ctx *ctx)
 		/*
 		 * Ensure we allow local-to-the-cpu processing to take place,
 		 * in this case we need to ensure that we reap all events.
+		 * Also let task_work, etc. to progress by releasing the mutex
 		 */
-		cond_resched();
+		if (need_resched()) {
+			mutex_unlock(&ctx->uring_lock);
+			cond_resched();
+			mutex_lock(&ctx->uring_lock);
+		}
 	}
 	mutex_unlock(&ctx->uring_lock);
 }
-- 
2.24.0


  parent reply	other threads:[~2020-07-06 15:01 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-07-06 14:59 [PATCH v2 0/3] iopoll improvements Pavel Begunkov
2020-07-06 14:59 ` [PATCH v2 1/3] io_uring: don't delay iopoll'ed req completion Pavel Begunkov
2020-07-06 14:59 ` [PATCH v2 2/3] io_uring: fix stopping iopoll'ing too early Pavel Begunkov
2020-07-06 14:59 ` Pavel Begunkov [this message]
2020-07-06 15:44 ` [PATCH v2 0/3] iopoll 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=e454be4ccca6059df91a691b64f4fd40578925de.1594047465.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