io_uring: remove unnecessary barrier before reading cq head
authorStefan Bühler <source@stbuehler.de>
Wed, 24 Apr 2019 21:54:18 +0000 (23:54 +0200)
committerJens Axboe <axboe@kernel.dk>
Tue, 30 Apr 2019 15:40:02 +0000 (09:40 -0600)
The memory operations before reading cq head are unrelated and we
don't care about their order.

Document that the control dependency in combination with READ_ONCE and
WRITE_ONCE forms a barrier we need.

Signed-off-by: Stefan Bühler <source@stbuehler.de>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
fs/io_uring.c

index bb71b7f00bb388bca3f293b1c8587a436a62b277..3671a654a146970c9063fb6abd883e284e052752 100644 (file)
@@ -431,8 +431,11 @@ static struct io_uring_cqe *io_get_cqring(struct io_ring_ctx *ctx)
        unsigned tail;
 
        tail = ctx->cached_cq_tail;
-       /* See comment at the top of the file */
-       smp_rmb();
+       /*
+        * writes to the cq entry need to come after reading head; the
+        * control dependency is enough as we're using WRITE_ONCE to
+        * fill the cq entry
+        */
        if (tail - READ_ONCE(ring->r.head) == ring->ring_entries)
                return NULL;