]> www.infradead.org Git - users/dwmw2/linux.git/commitdiff
io_uring: flush overflowed CQ events in the io_uring_poll()
authorStefano Garzarella <sgarzare@redhat.com>
Fri, 7 Feb 2020 12:18:28 +0000 (13:18 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 5 Mar 2020 15:45:05 +0000 (16:45 +0100)
[ Upstream commit 63e5d81f72af1bf370bf8a6745b0a8d71a7bb37d ]

In io_uring_poll() we must flush overflowed CQ events before to
check if there are CQ events available, to avoid missing events.

We call the io_cqring_events() that checks and flushes any overflow
and returns the number of CQ events available.

Signed-off-by: Stefano Garzarella <sgarzare@redhat.com>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
Signed-off-by: Sasha Levin <sashal@kernel.org>
fs/io_uring.c

index 678c62782ba3bfc70e57ab811c2af3d3b0f783f0..de4bd647cd1dfbaf060152b9f86a34a39d193a33 100644 (file)
@@ -4970,7 +4970,7 @@ static __poll_t io_uring_poll(struct file *file, poll_table *wait)
        if (READ_ONCE(ctx->rings->sq.tail) - ctx->cached_sq_head !=
            ctx->rings->sq_ring_entries)
                mask |= EPOLLOUT | EPOLLWRNORM;
-       if (READ_ONCE(ctx->rings->cq.head) != ctx->cached_cq_tail)
+       if (io_cqring_events(ctx, false))
                mask |= EPOLLIN | EPOLLRDNORM;
 
        return mask;