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 5/8] io_uring: optimise fixed rw rsrc node setting
Date: Fri, 15 Oct 2021 17:09:15 +0100	[thread overview]
Message-ID: <68c06f66d5aa9661f1e4b88d08c52d23528297ec.1634314022.git.asml.silence@gmail.com> (raw)
In-Reply-To: <[email protected]>

Move fixed rw io_req_set_rsrc_node() from rw prep into
io_import_fixed(), if we're using fixed buffers it will always be called
during submission as we save the state in advance,

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

diff --git a/fs/io_uring.c b/fs/io_uring.c
index a2514d2937c0..64ef04c9628d 100644
--- a/fs/io_uring.c
+++ b/fs/io_uring.c
@@ -2874,12 +2874,7 @@ static int io_prep_rw(struct io_kiocb *req, const struct io_uring_sqe *sqe,
 		kiocb->ki_complete = io_complete_rw;
 	}
 
-	if (req->opcode == IORING_OP_READ_FIXED ||
-	    req->opcode == IORING_OP_WRITE_FIXED) {
-		req->imu = NULL;
-		io_req_set_rsrc_node(req, ctx);
-	}
-
+	req->imu = NULL;
 	req->rw.addr = READ_ONCE(sqe->addr);
 	req->rw.len = READ_ONCE(sqe->len);
 	req->buf_index = READ_ONCE(sqe->buf_index);
@@ -3008,13 +3003,15 @@ static int __io_import_fixed(struct io_kiocb *req, int rw, struct iov_iter *iter
 
 static int io_import_fixed(struct io_kiocb *req, int rw, struct iov_iter *iter)
 {
-	struct io_ring_ctx *ctx = req->ctx;
 	struct io_mapped_ubuf *imu = req->imu;
 	u16 index, buf_index = req->buf_index;
 
 	if (likely(!imu)) {
+		struct io_ring_ctx *ctx = req->ctx;
+
 		if (unlikely(buf_index >= ctx->nr_user_bufs))
 			return -EFAULT;
+		io_req_set_rsrc_node(req, ctx);
 		index = array_index_nospec(buf_index, ctx->nr_user_bufs);
 		imu = READ_ONCE(ctx->user_bufs[index]);
 		req->imu = imu;
-- 
2.33.0


  parent reply	other threads:[~2021-10-15 16:10 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-10-15 16:09 [PATCH for-next 0/8] further rw cleanups+optimisisation Pavel Begunkov
2021-10-15 16:09 ` [PATCH 1/8] io_uring: optimise req->ctx reloads Pavel Begunkov
2021-10-15 16:09 ` [PATCH 2/8] io_uring: kill io_wq_current_is_worker() in iopoll Pavel Begunkov
2021-10-15 16:09 ` [PATCH 3/8] io_uring: optimise io_import_iovec fixed path Pavel Begunkov
2021-10-15 16:09 ` [PATCH 4/8] io_uring: return iovec from __io_import_iovec Pavel Begunkov
2021-10-15 16:09 ` Pavel Begunkov [this message]
2021-10-15 16:09 ` [PATCH 6/8] io_uring: clean io_prep_rw() Pavel Begunkov
2021-10-15 16:09 ` [PATCH 7/8] io_uring: arm poll for non-nowait files Pavel Begunkov
2021-10-16 22:57   ` Noah Goldstein
2021-10-16 23:16     ` Pavel Begunkov
2021-10-15 16:09 ` [PATCH 8/8] io_uring: simplify io_file_supports_nowait() Pavel Begunkov
2021-10-16  3:36 ` [PATCH for-next 0/8] further rw cleanups+optimisisation 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=68c06f66d5aa9661f1e4b88d08c52d23528297ec.1634314022.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