public inbox for [email protected]
 help / color / mirror / Atom feed
* [PATCH] io_uring: reduce one unnecessary io_sqring_entries() call
@ 2021-01-08  8:36 Xiaoguang Wang
  2021-01-09 17:02 ` Pavel Begunkov
  0 siblings, 1 reply; 2+ messages in thread
From: Xiaoguang Wang @ 2021-01-08  8:36 UTC (permalink / raw)
  To: io-uring; +Cc: axboe, asml.silence, joseph.qi

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


^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2021-01-09 17:07 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-01-08  8:36 [PATCH] io_uring: reduce one unnecessary io_sqring_entries() call Xiaoguang Wang
2021-01-09 17:02 ` Pavel Begunkov

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox