Skip to content

Commit c57a91f

Browse files
isilenceaxboe
authored andcommitted
io_uring: fix missing mb() before waitqueue_active
In case of !SQPOLL, io_cqring_ev_posted_iopoll() doesn't provide a memory barrier required by waitqueue_active(&ctx->poll_wait). There is a wq_has_sleeper(), which does smb_mb() inside, but it's called only for SQPOLL. Fixes: 5fd4617 ("io_uring: be smarter about waking multiple CQ ring waiters") Signed-off-by: Pavel Begunkov <[email protected]> Link: https://lore.kernel.org/r/2982e53bcea2274006ed435ee2a77197107d8a29.1631130542.git.asml.silence@gmail.com Signed-off-by: Jens Axboe <[email protected]>
1 parent 713b982 commit c57a91f

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

fs/io_uring.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1619,8 +1619,11 @@ static void io_cqring_ev_posted(struct io_ring_ctx *ctx)
16191619

16201620
static void io_cqring_ev_posted_iopoll(struct io_ring_ctx *ctx)
16211621
{
1622+
/* see waitqueue_active() comment */
1623+
smp_mb();
1624+
16221625
if (ctx->flags & IORING_SETUP_SQPOLL) {
1623-
if (wq_has_sleeper(&ctx->cq_wait))
1626+
if (waitqueue_active(&ctx->cq_wait))
16241627
wake_up_all(&ctx->cq_wait);
16251628
}
16261629
if (io_should_trigger_evfd(ctx))

0 commit comments

Comments
 (0)