public inbox for [email protected]
 help / color / mirror / Atom feed
* [PATCH liburing 1/1] queue: clean up SQ flushing
@ 2021-06-15 15:07 Pavel Begunkov
  2021-06-15 21:36 ` Jens Axboe
  0 siblings, 1 reply; 2+ messages in thread
From: Pavel Begunkov @ 2021-06-15 15:07 UTC (permalink / raw)
  To: Jens Axboe, io-uring

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


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH liburing 1/1] queue: clean up SQ flushing
  2021-06-15 15:07 [PATCH liburing 1/1] queue: clean up SQ flushing Pavel Begunkov
@ 2021-06-15 21:36 ` Jens Axboe
  0 siblings, 0 replies; 2+ messages in thread
From: Jens Axboe @ 2021-06-15 21:36 UTC (permalink / raw)
  To: Pavel Begunkov, io-uring

On 6/15/21 9:07 AM, Pavel Begunkov wrote:
> Clean up and deduplicate parts of __io_uring_flush_sq(), also helping to
> generate a better binary if a compiler is not smart enough.

Applied, thanks.

-- 
Jens Axboe


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2021-06-15 21:36 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-06-15 15:07 [PATCH liburing 1/1] queue: clean up SQ flushing Pavel Begunkov
2021-06-15 21:36 ` Jens Axboe

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox