public inbox for [email protected]
 help / color / mirror / Atom feed
From: Xiaoguang Wang <[email protected]>
To: [email protected]
Cc: [email protected], [email protected], [email protected]
Subject: [PATCH] io_uring: reduce one unnecessary io_sqring_entries() call
Date: Fri,  8 Jan 2021 16:36:23 +0800	[thread overview]
Message-ID: <[email protected]> (raw)

In __io_sq_thread(), we have gotten the number of sqes to submit,
then in io_submit_sqes(), we can use this number directly, no need
to call io_sqring_entries() again in io_submit_sqes().

Signed-off-by: Xiaoguang Wang <[email protected]>
---
 fs/io_uring.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/fs/io_uring.c b/fs/io_uring.c
index ca46f314640b..200a9eb72788 100644
--- a/fs/io_uring.c
+++ b/fs/io_uring.c
@@ -6830,9 +6830,6 @@ static int io_submit_sqes(struct io_ring_ctx *ctx, unsigned int nr)
 			return -EBUSY;
 	}
 
-	/* make sure SQ entry isn't read before tail */
-	nr = min3(nr, ctx->sq_entries, io_sqring_entries(ctx));
-
 	if (!percpu_ref_tryget_many(&ctx->refs, nr))
 		return -EAGAIN;
 
@@ -9211,6 +9208,8 @@ SYSCALL_DEFINE6(io_uring_enter, unsigned int, fd, u32, to_submit,
 		if (unlikely(ret))
 			goto out;
 		mutex_lock(&ctx->uring_lock);
+		/* make sure SQ entry isn't read before tail */
+		to_submit = min3(to_submit, ctx->sq_entries, io_sqring_entries(ctx));
 		submitted = io_submit_sqes(ctx, to_submit);
 		mutex_unlock(&ctx->uring_lock);
 
-- 
2.17.2


             reply	other threads:[~2021-01-08  8:37 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-01-08  8:36 Xiaoguang Wang [this message]
2021-01-09 17:02 ` [PATCH] io_uring: reduce one unnecessary io_sqring_entries() call Pavel Begunkov

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=20210108083623.26400-1-xiaoguang.wang@linux.alibaba.com \
    [email protected] \
    [email protected] \
    [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