From c5f0a205e9bf205d71ed015aa2be0b9e24b0e756 Mon Sep 17 00:00:00 2001 From: Jens Axboe Date: Wed, 28 Sep 2022 07:28:58 -0600 Subject: [PATCH] t/io_uring: get rid of useless read barriers We don't need a read barrier when we have acquire semantics on reading the CQ ring tail. We also don't need acquire semantics on the SQ ring head, unless we're using SQPOLL. A syscall transition will have happened for !SQPOLL. Signed-off-by: Jens Axboe --- t/io_uring.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/t/io_uring.c b/t/io_uring.c index b9353ac8..edbacee3 100644 --- a/t/io_uring.c +++ b/t/io_uring.c @@ -661,8 +661,12 @@ static void init_io_pt(struct submitter *s, unsigned index) static int prep_more_ios_uring(struct submitter *s, int max_ios) { struct io_sq_ring *ring = &s->sq_ring; - unsigned index, tail, next_tail, prepped = 0; - unsigned int head = atomic_load_acquire(ring->head); + unsigned head, index, tail, next_tail, prepped = 0; + + if (sq_thread_poll) + head = atomic_load_acquire(ring->head); + else + head = *ring->head; next_tail = tail = *ring->tail; do { @@ -741,7 +745,6 @@ static int reap_events_uring(struct submitter *s) do { struct file *f; - read_barrier(); if (head == atomic_load_acquire(ring->tail)) break; cqe = &ring->cqes[head & cq_ring_mask]; @@ -796,7 +799,6 @@ static int reap_events_uring_pt(struct submitter *s) do { struct file *f; - read_barrier(); if (head == atomic_load_acquire(ring->tail)) break; index = head & cq_ring_mask; -- 2.25.1