public inbox for io-uring@vger.kernel.org
 help / color / mirror / Atom feed
From: Pavel Begunkov <asml.silence@gmail.com>
To: io-uring@vger.kernel.org
Cc: asml.silence@gmail.com
Subject: [PATCH 3/6] io_uring: remove drain prealloc checks
Date: Thu,  8 May 2025 12:52:23 +0100	[thread overview]
Message-ID: <dd566f1986ea1feb2f2ed5a0344f05cebb9415b3.1746702098.git.asml.silence@gmail.com> (raw)
In-Reply-To: <cover.1746702098.git.asml.silence@gmail.com>

Currently io_drain_req() has two steps. The first is fast path checking
sequence numbers. The second is allocations, rechecking and actual
queuing. Further simplify it by removing the first step.

Signed-off-by: Pavel Begunkov <asml.silence@gmail.com>
---
 io_uring/io_uring.c | 15 +++------------
 1 file changed, 3 insertions(+), 12 deletions(-)

diff --git a/io_uring/io_uring.c b/io_uring/io_uring.c
index 21b70ad0edc4..72ae350f4f8b 100644
--- a/io_uring/io_uring.c
+++ b/io_uring/io_uring.c
@@ -1659,17 +1659,6 @@ static __cold void io_drain_req(struct io_kiocb *req)
 	struct io_defer_entry *de;
 	u32 seq = io_get_sequence(req);
 
-	/* Still need defer if there is pending req in defer list. */
-	spin_lock(&ctx->completion_lock);
-	if (!req_need_defer(req, seq) && list_empty_careful(&ctx->defer_list)) {
-		spin_unlock(&ctx->completion_lock);
-queue:
-		ctx->drain_active = false;
-		io_req_task_queue(req);
-		return;
-	}
-	spin_unlock(&ctx->completion_lock);
-
 	io_prep_async_link(req);
 	de = kmalloc(sizeof(*de), GFP_KERNEL_ACCOUNT);
 	if (!de) {
@@ -1681,7 +1670,9 @@ static __cold void io_drain_req(struct io_kiocb *req)
 	if (!req_need_defer(req, seq) && list_empty(&ctx->defer_list)) {
 		spin_unlock(&ctx->completion_lock);
 		kfree(de);
-		goto queue;
+		ctx->drain_active = false;
+		io_req_task_queue(req);
+		return;
 	}
 
 	trace_io_uring_defer(req);
-- 
2.49.0


  parent reply	other threads:[~2025-05-08 11:51 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-05-08 11:52 [PATCH 0/6] drain cleanups and extra Pavel Begunkov
2025-05-08 11:52 ` [PATCH 1/6] io_uring: account drain memory to cgroup Pavel Begunkov
2025-05-08 11:52 ` [PATCH 2/6] io_uring: simplify drain ret passing Pavel Begunkov
2025-05-08 11:52 ` Pavel Begunkov [this message]
2025-05-08 11:52 ` [PATCH 4/6] io_uring: consolidate drain seq checking Pavel Begunkov
2025-05-08 15:43   ` Pavel Begunkov
2025-05-08 11:52 ` [PATCH 5/6] io_uring/net: move CONFIG_NET guards to Makefile Pavel Begunkov
2025-05-08 11:52 ` [PATCH 6/6] io_uring: add lockdep asserts to io_add_aux_cqe 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=dd566f1986ea1feb2f2ed5a0344f05cebb9415b3.1746702098.git.asml.silence@gmail.com \
    --to=asml.silence@gmail.com \
    --cc=io-uring@vger.kernel.org \
    /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