From: Pavel Begunkov <[email protected]>
To: Jens Axboe <[email protected]>, [email protected]
Subject: [PATCH liburing 1/1] queue: clean up SQ flushing
Date: Tue, 15 Jun 2021 16:07:28 +0100 [thread overview]
Message-ID: <7c725dda9dba669235737ee5fd0b37909b6d25a5.1623769611.git.asml.silence@gmail.com> (raw)
Clean up and deduplicate parts of __io_uring_flush_sq(), also helping to
generate a better binary if a compiler is not smart enough.
Signed-off-by: Pavel Begunkov <[email protected]>
---
src/queue.c | 13 +++++--------
1 file changed, 5 insertions(+), 8 deletions(-)
diff --git a/src/queue.c b/src/queue.c
index ce5d237..2f0f19b 100644
--- a/src/queue.c
+++ b/src/queue.c
@@ -198,23 +198,20 @@ int __io_uring_flush_sq(struct io_uring *ring)
{
struct io_uring_sq *sq = &ring->sq;
const unsigned mask = *sq->kring_mask;
- unsigned ktail, to_submit;
+ unsigned ktail = *sq->ktail;
+ unsigned to_submit = sq->sqe_tail - sq->sqe_head;
- if (sq->sqe_head == sq->sqe_tail) {
- ktail = *sq->ktail;
+ if (!to_submit)
goto out;
- }
/*
* Fill in sqes that we have queued up, adding them to the kernel ring
*/
- ktail = *sq->ktail;
- to_submit = sq->sqe_tail - sq->sqe_head;
- while (to_submit--) {
+ do {
sq->array[ktail & mask] = sq->sqe_head & mask;
ktail++;
sq->sqe_head++;
- }
+ } while (--to_submit);
/*
* Ensure that the kernel sees the SQE updates before it sees the tail
--
2.31.1
next reply other threads:[~2021-06-15 15:07 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-06-15 15:07 Pavel Begunkov [this message]
2021-06-15 21:36 ` [PATCH liburing 1/1] queue: clean up SQ flushing 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=7c725dda9dba669235737ee5fd0b37909b6d25a5.1623769611.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