t/io_uring: get rid of useless read barriers
authorJens Axboe <axboe@kernel.dk>
Wed, 28 Sep 2022 13:28:58 +0000 (07:28 -0600)
committerJens Axboe <axboe@kernel.dk>
Wed, 28 Sep 2022 14:06:52 +0000 (08:06 -0600)
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 <axboe@kernel.dk>
t/io_uring.c

index b9353ac867331a2162a697876b7a37cfe408b0b1..edbacee3fc9fe93b39c65e00044b5f76ae237a5f 100644 (file)
@@ -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;