aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJackie Liu <liuyun01@kylinos.cn>2019-05-15 23:46:30 -0400
committerJens Axboe <axboe@kernel.dk>2019-05-16 10:10:25 -0400
commitdc6ce4bc2b355a47f225a0205046b3ebf29a7f72 (patch)
tree78492c45930982a9d1fae0ce6eed67c2a92597b1
parent2bbcd6d3b36a75a19be4917807f54ae32dd26aba (diff)
io_uring: adjust smp_rmb inside io_cqring_events
Whenever smp_rmb is required to use io_cqring_events, keep smp_rmb inside the function io_cqring_events. Signed-off-by: Jackie Liu <liuyun01@kylinos.cn> Signed-off-by: Jens Axboe <axboe@kernel.dk>
-rw-r--r--fs/io_uring.c6
1 files changed, 2 insertions, 4 deletions
diff --git a/fs/io_uring.c b/fs/io_uring.c
index 67d1aae349d7..9cc7a101ef2a 100644
--- a/fs/io_uring.c
+++ b/fs/io_uring.c
@@ -2167,6 +2167,8 @@ static int io_ring_submit(struct io_ring_ctx *ctx, unsigned int to_submit)
2167 2167
2168static unsigned io_cqring_events(struct io_cq_ring *ring) 2168static unsigned io_cqring_events(struct io_cq_ring *ring)
2169{ 2169{
2170 /* See comment at the top of this file */
2171 smp_rmb();
2170 return READ_ONCE(ring->r.tail) - READ_ONCE(ring->r.head); 2172 return READ_ONCE(ring->r.tail) - READ_ONCE(ring->r.head);
2171} 2173}
2172 2174
@@ -2182,8 +2184,6 @@ static int io_cqring_wait(struct io_ring_ctx *ctx, int min_events,
2182 DEFINE_WAIT(wait); 2184 DEFINE_WAIT(wait);
2183 int ret; 2185 int ret;
2184 2186
2185 /* See comment at the top of this file */
2186 smp_rmb();
2187 if (io_cqring_events(ring) >= min_events) 2187 if (io_cqring_events(ring) >= min_events)
2188 return 0; 2188 return 0;
2189 2189
@@ -2205,8 +2205,6 @@ static int io_cqring_wait(struct io_ring_ctx *ctx, int min_events,
2205 prepare_to_wait(&ctx->wait, &wait, TASK_INTERRUPTIBLE); 2205 prepare_to_wait(&ctx->wait, &wait, TASK_INTERRUPTIBLE);
2206 2206
2207 ret = 0; 2207 ret = 0;
2208 /* See comment at the top of this file */
2209 smp_rmb();
2210 if (io_cqring_events(ring) >= min_events) 2208 if (io_cqring_events(ring) >= min_events)
2211 break; 2209 break;
2212 2210