public inbox for [email protected]
 help / color / mirror / Atom feed
From: Pavel Begunkov <[email protected]>
To: Jens Axboe <[email protected]>, [email protected]
Subject: [PATCH 06/11] io_uring: don't init req->work fully in advance
Date: Mon, 22 Mar 2021 01:58:29 +0000	[thread overview]
Message-ID: <16a059a4fbc00cd5021efd9722c4ddea921f8500.1616378197.git.asml.silence@gmail.com> (raw)
In-Reply-To: <[email protected]>

req->work is mostly unused unless it's punted, and io_init_req() is too
hot for fully initialising it. Fortunately, we can skip init work.next
as it's controlled by io-wq, and can not touch work.flags by moving
everything related into io_prep_async_work(). The only field left is
req->work.creds, but there is nothing can be done, keep maintaining it.

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

diff --git a/fs/io_uring.c b/fs/io_uring.c
index ff238dc503db..8609ca962dea 100644
--- a/fs/io_uring.c
+++ b/fs/io_uring.c
@@ -1199,6 +1199,8 @@ static void io_prep_async_work(struct io_kiocb *req)
 	if (!req->work.creds)
 		req->work.creds = get_current_cred();
 
+	req->work.list.next = NULL;
+	req->work.flags = 0;
 	if (req->flags & REQ_F_FORCE_ASYNC)
 		req->work.flags |= IO_WQ_WORK_CONCURRENT;
 
@@ -1209,6 +1211,18 @@ static void io_prep_async_work(struct io_kiocb *req)
 		if (def->unbound_nonreg_file)
 			req->work.flags |= IO_WQ_WORK_UNBOUND;
 	}
+
+	switch (req->opcode) {
+	case IORING_OP_SPLICE:
+	case IORING_OP_TEE:
+		/*
+		 * Splice operation will be punted aync, and here need to
+		 * modify io_wq_work.flags, so initialize io_wq_work firstly.
+		 */
+		if (!S_ISREG(file_inode(req->splice.file_in)->i_mode))
+			req->work.flags |= IO_WQ_WORK_UNBOUND;
+		break;
+	}
 }
 
 static void io_prep_async_link(struct io_kiocb *req)
@@ -3601,15 +3615,6 @@ static int __io_splice_prep(struct io_kiocb *req,
 	if (!sp->file_in)
 		return -EBADF;
 	req->flags |= REQ_F_NEED_CLEANUP;
-
-	if (!S_ISREG(file_inode(sp->file_in)->i_mode)) {
-		/*
-		 * Splice operation will be punted aync, and here need to
-		 * modify io_wq_work.flags, so initialize io_wq_work firstly.
-		 */
-		req->work.flags |= IO_WQ_WORK_UNBOUND;
-	}
-
 	return 0;
 }
 
@@ -6381,9 +6386,7 @@ static int io_init_req(struct io_ring_ctx *ctx, struct io_kiocb *req,
 	atomic_set(&req->refs, 2);
 	req->task = current;
 	req->result = 0;
-	req->work.list.next = NULL;
 	req->work.creds = NULL;
-	req->work.flags = 0;
 
 	/* enforce forwards compatibility on users */
 	if (unlikely(sqe_flags & ~SQE_VALID_FLAGS)) {
-- 
2.24.0


  parent reply	other threads:[~2021-03-22  2:03 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-03-22  1:58 [PATCH 5.13 00/11] yet another series of random 5.13 patches Pavel Begunkov
2021-03-22  1:58 ` [PATCH 01/11] io_uring: don't clear REQ_F_LINK_TIMEOUT Pavel Begunkov
2021-03-22  1:58 ` [PATCH 02/11] io_uring: don't do extra EXITING cancellations Pavel Begunkov
2021-03-22  1:58 ` [PATCH 03/11] io_uring: optimise out task_work checks on enter Pavel Begunkov
2021-03-22 13:45   ` Jens Axboe
2021-03-22 14:53     ` Pavel Begunkov
2021-03-22 14:58       ` Jens Axboe
2021-03-22  1:58 ` [PATCH 04/11] io_uring: remove tctx->sqpoll Pavel Begunkov
2021-03-22  1:58 ` [PATCH 05/11] io-wq: refactor *_get_acct() Pavel Begunkov
2021-03-22  1:58 ` Pavel Begunkov [this message]
2021-03-22  1:58 ` [PATCH 07/11] io_uring: kill unused REQ_F_NO_FILE_TABLE Pavel Begunkov
2021-03-22  1:58 ` [PATCH 08/11] io_uring: optimise kiocb_end_write for !ISREG Pavel Begunkov
2021-03-22  1:58 ` [PATCH 09/11] io_uring: don't alter iopoll reissue fail ret code Pavel Begunkov
2021-03-22  1:58 ` [PATCH 10/11] io_uring: hide iter revert in resubmit_prep Pavel Begunkov
2021-03-22  1:58 ` [PATCH 11/11] io_uring: optimise rw complete error handling Pavel Begunkov
2021-03-22  2:00 ` [PATCH 5.13 00/11] yet another series of random 5.13 patches Pavel Begunkov
2021-03-22 13:49 ` 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=16a059a4fbc00cd5021efd9722c4ddea921f8500.1616378197.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