提交 3d1f85fd 编写于 作者: J Jackie Liu 提交者: Cheng Jian

io_uring: adjust smp_rmb inside io_cqring_events

mainline inclusion
from mainline-5.2-rc1
commit dc6ce4bc
category: feature
bugzilla: https://bugzilla.openeuler.org/show_bug.cgi?id=27
CVE: NA
---------------------------

Whenever smp_rmb is required to use io_cqring_events,
keep smp_rmb inside the function io_cqring_events.
Signed-off-by: NJackie Liu <liuyun01@kylinos.cn>
Signed-off-by: NJens Axboe <axboe@kernel.dk>
Signed-off-by: NZhihao Cheng <chengzhihao1@huawei.com>
Signed-off-by: Nyangerkun <yangerkun@huawei.com>
Reviewed-by: Nzhangyi (F) <yi.zhang@huawei.com>
Signed-off-by: NCheng Jian <cj.chengjian@huawei.com>
上级 8ff77cc5
...@@ -2164,6 +2164,8 @@ static int io_ring_submit(struct io_ring_ctx *ctx, unsigned int to_submit) ...@@ -2164,6 +2164,8 @@ static int io_ring_submit(struct io_ring_ctx *ctx, unsigned int to_submit)
static unsigned io_cqring_events(struct io_cq_ring *ring) static unsigned io_cqring_events(struct io_cq_ring *ring)
{ {
/* See comment at the top of this file */
smp_rmb();
return READ_ONCE(ring->r.tail) - READ_ONCE(ring->r.head); return READ_ONCE(ring->r.tail) - READ_ONCE(ring->r.head);
} }
...@@ -2179,8 +2181,6 @@ static int io_cqring_wait(struct io_ring_ctx *ctx, int min_events, ...@@ -2179,8 +2181,6 @@ static int io_cqring_wait(struct io_ring_ctx *ctx, int min_events,
DEFINE_WAIT(wait); DEFINE_WAIT(wait);
int ret; int ret;
/* See comment at the top of this file */
smp_rmb();
if (io_cqring_events(ring) >= min_events) if (io_cqring_events(ring) >= min_events)
return 0; return 0;
...@@ -2202,8 +2202,6 @@ static int io_cqring_wait(struct io_ring_ctx *ctx, int min_events, ...@@ -2202,8 +2202,6 @@ static int io_cqring_wait(struct io_ring_ctx *ctx, int min_events,
prepare_to_wait(&ctx->wait, &wait, TASK_INTERRUPTIBLE); prepare_to_wait(&ctx->wait, &wait, TASK_INTERRUPTIBLE);
ret = 0; ret = 0;
/* See comment at the top of this file */
smp_rmb();
if (io_cqring_events(ring) >= min_events) if (io_cqring_events(ring) >= min_events)
break; break;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册