aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPavel Begunkov <asml.silence@gmail.com>2021-06-15 16:07:28 +0100
committerJens Axboe <axboe@kernel.dk>2021-06-15 15:36:05 -0600
commitc4c280f31b0e05a1ea792ce255dc8689aad1c887 (patch)
tree55bceea586e6c8d3e317582c6787fe3b957d552b
parentee551425c1d25ed1d7febf673df75cc1222fc4ee (diff)
downloadliburing-c4c280f31b0e05a1ea792ce255dc8689aad1c887.tar.gz
queue: clean up SQ flushing
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 <asml.silence@gmail.com> Signed-off-by: Jens Axboe <axboe@kernel.dk>
-rw-r--r--src/queue.c13
1 files 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