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, axboe@kernel.dk
Subject: [PATCH liburing 1/1] src/queue: simplify IORING_SETUP_SQ_REWIND handling
Date: Thu, 29 Jan 2026 17:19:31 +0000	[thread overview]
Message-ID: <6fcdfda380cb636b3ddcb9d446907abdb63782c5.1769707053.git.asml.silence@gmail.com> (raw)

io_uring_load_sq_head() shouldn't need a IORING_SETUP_SQ_REWIND check
as the SQ head should already be zero. Also, add a couple of words about
the tail resetting logic.

Signed-off-by: Pavel Begunkov <asml.silence@gmail.com>
---
 src/include/liburing.h | 3 ---
 src/queue.c            | 7 +++++++
 2 files changed, 7 insertions(+), 3 deletions(-)

diff --git a/src/include/liburing.h b/src/include/liburing.h
index b41958ce..8d45d400 100644
--- a/src/include/liburing.h
+++ b/src/include/liburing.h
@@ -1684,9 +1684,6 @@ IOURINGINLINE void io_uring_prep_pipe_direct(struct io_uring_sqe *sqe, int *fds,
 IOURINGINLINE unsigned io_uring_load_sq_head(const struct io_uring *ring)
 	LIBURING_NOEXCEPT
 {
-	if (ring->flags & IORING_SETUP_SQ_REWIND)
-		return 0;
-
 	/*
 	 * Without acquire ordering, we could overwrite a SQE before the kernel
 	 * finished reading it. We don't need the acquire ordering for
diff --git a/src/queue.c b/src/queue.c
index 00995ace..87b4dbbe 100644
--- a/src/queue.c
+++ b/src/queue.c
@@ -205,6 +205,13 @@ static unsigned __io_uring_flush_sq(struct io_uring *ring)
 	struct io_uring_sq *sq = &ring->sq;
 	unsigned tail = sq->sqe_tail;
 
+	/*
+	 * With IORING_SETUP_SQ_REWIND, the kernel ignores the SQ head / tail
+	 * and submits entries from the beginning of the queue. Continue using
+	 * the indices as before but reset the tail on submission. With the
+	 * head kept to be zero, io_uring_get_sqe() / etc. will work without
+	 * any extra changes.
+	 */
 	if (ring->flags & IORING_SETUP_SQ_REWIND) {
 		sq->sqe_tail = 0;
 		return tail;
-- 
2.52.0


             reply	other threads:[~2026-01-29 17:19 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-01-29 17:19 Pavel Begunkov [this message]
2026-01-29 20:11 ` [PATCH liburing 1/1] src/queue: simplify IORING_SETUP_SQ_REWIND handling 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=6fcdfda380cb636b3ddcb9d446907abdb63782c5.1769707053.git.asml.silence@gmail.com \
    --to=asml.silence@gmail.com \
    --cc=axboe@kernel.dk \
    --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