From: Pavel Begunkov <[email protected]>
To: [email protected]
Cc: Jens Axboe <[email protected]>, [email protected]
Subject: [PATCH 4/6] io_uring: optimise io_free_batch_list
Date: Mon, 21 Mar 2022 22:02:22 +0000 [thread overview]
Message-ID: <0fb493f73f2009aea395c570c2932fecaa4e1244.1647897811.git.asml.silence@gmail.com> (raw)
In-Reply-To: <[email protected]>
We do several req->flags checks in the fast path of
io_free_batch_list(). One explicit check of REQ_F_REFCOUNT, and two
other hidden in io_queue_next() and io_dismantle_req(). Moreover, there
is a io_req_put_rsrc_locked() call in between, so there is no hope
req->flags will be preserved in registers.
All those flags if not a slow path than definitely a slower path, so
put them all under a single flags mask check and save several mem
reloads and ifs.
Signed-off-by: Pavel Begunkov <[email protected]>
---
fs/io_uring.c | 20 ++++++++++++++------
1 file changed, 14 insertions(+), 6 deletions(-)
diff --git a/fs/io_uring.c b/fs/io_uring.c
index 4539461ee7b3..36bcfcc23193 100644
--- a/fs/io_uring.c
+++ b/fs/io_uring.c
@@ -116,6 +116,9 @@
REQ_F_POLLED | REQ_F_INFLIGHT | REQ_F_CREDS | \
REQ_F_ASYNC_DATA)
+#define IO_REQ_CLEAN_SLOW_FLAGS (REQ_F_REFCOUNT | REQ_F_LINK | REQ_F_HARDLINK |\
+ IO_REQ_CLEAN_FLAGS)
+
#define IO_TCTX_REFS_CACHE_NR (1U << 10)
struct io_uring {
@@ -2641,15 +2644,20 @@ static void io_free_batch_list(struct io_ring_ctx *ctx,
struct io_kiocb *req = container_of(node, struct io_kiocb,
comp_list);
- if (unlikely(req->flags & REQ_F_REFCOUNT)) {
- node = req->comp_list.next;
- if (!req_ref_put_and_test(req))
- continue;
+ if (unlikely(req->flags & IO_REQ_CLEAN_SLOW_FLAGS)) {
+ if (req->flags & REQ_F_REFCOUNT) {
+ node = req->comp_list.next;
+ if (!req_ref_put_and_test(req))
+ continue;
+ }
+ io_queue_next(req);
+ if (unlikely(req->flags & IO_REQ_CLEAN_FLAGS))
+ io_clean_op(req);
}
+ if (!(req->flags & REQ_F_FIXED_FILE))
+ io_put_file(req->file);
io_req_put_rsrc_locked(req, ctx);
- io_queue_next(req);
- io_dismantle_req(req);
if (req->task != task) {
if (task)
--
2.35.1
next prev parent reply other threads:[~2022-03-21 22:50 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-03-21 22:02 [PATCH 0/6] completion path optimisations Pavel Begunkov
2022-03-21 22:02 ` [PATCH 1/6] io_uring: small optimisation of tctx_task_work Pavel Begunkov
2022-03-21 22:02 ` [PATCH 2/6] io_uring: remove extra ifs around io_commit_cqring Pavel Begunkov
2022-03-21 22:02 ` [PATCH 3/6] io_uring: refactor io_req_find_next Pavel Begunkov
2022-03-21 22:02 ` Pavel Begunkov [this message]
2022-03-21 22:02 ` [PATCH 5/6] io_uring: move poll recycling later in compl flushing Pavel Begunkov
2022-03-21 22:02 ` [PATCH 6/6] io_uring: clean up io_queue_next() Pavel Begunkov
2022-03-22 2:52 ` [PATCH 0/6] completion path optimisations 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=0fb493f73f2009aea395c570c2932fecaa4e1244.1647897811.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