From: Jens Axboe Date: Mon, 30 Sep 2024 15:21:17 +0000 (-0600) Subject: t/io_uring: only load tail once per reap loop X-Git-Tag: fio-3.38~2 X-Git-Url: https://git.kernel.dk/?a=commitdiff_plain;h=b46877edc9a94009ebbb33a461b21dad9bd40964;p=fio.git t/io_uring: only load tail once per reap loop It'll never change with the settings that t/io_uring uses to setup the ring - and even if it could, it's still cheaper to just read the tail once per reap. Signed-off-by: Jens Axboe --- diff --git a/t/io_uring.c b/t/io_uring.c index aa6e09e9..0fa01837 100644 --- a/t/io_uring.c +++ b/t/io_uring.c @@ -699,14 +699,15 @@ static int reap_events_uring(struct submitter *s) { struct io_cq_ring *ring = &s->cq_ring; struct io_uring_cqe *cqe; - unsigned head, reaped = 0; + unsigned tail, head, reaped = 0; int last_idx = -1, stat_nr = 0; head = *ring->head; + tail = atomic_load_acquire(ring->tail); do { struct file *f; - if (head == atomic_load_acquire(ring->tail)) + if (head == tail) break; cqe = &ring->cqes[head & cq_ring_mask]; if (!do_nop) { @@ -755,16 +756,17 @@ static int reap_events_uring_pt(struct submitter *s) { struct io_cq_ring *ring = &s->cq_ring; struct io_uring_cqe *cqe; - unsigned head, reaped = 0; + unsigned head, tail, reaped = 0; int last_idx = -1, stat_nr = 0; unsigned index; int fileno; head = *ring->head; + tail = atomic_load_acquire(ring->tail); do { struct file *f; - if (head == atomic_load_acquire(ring->tail)) + if (head == tail) break; index = head & cq_ring_mask; cqe = &ring->cqes[index << 1];