]> git.baikalelectronics.ru Git - kernel.git/commit
io_uring: fix __io_iopoll_check deadlock in io_sq_thread
authorXiaoguang Wang <xiaoguang.wang@linux.alibaba.com>
Sat, 22 Feb 2020 06:46:05 +0000 (14:46 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 28 Feb 2020 16:22:27 +0000 (17:22 +0100)
commit58e5d0e9575b1c7a08e51b8e73c4f8a152f11af7
tree94e7ea33fc06acfd3ac7883c09318c1cef73e6ba
parent6b0435164c626a38b4d2556aeda0acff7bfb9a53
io_uring: fix __io_iopoll_check deadlock in io_sq_thread

commit 55eda77c6aab6a3f15a4ee8ed77b05f067f65bca upstream.

Since commit d59891fe5b0f ("io_uring: don't enter poll loop if we have
CQEs pending"), if we already events pending, we won't enter poll loop.
In case SETUP_IOPOLL and SETUP_SQPOLL are both enabled, if app has
been terminated and don't reap pending events which are already in cq
ring, and there are some reqs in poll_list, io_sq_thread will enter
__io_iopoll_check(), and find pending events, then return, this loop
will never have a chance to exit.

I have seen this issue in fio stress tests, to fix this issue, let
io_sq_thread call io_iopoll_getevents() with argument 'min' being zero,
and remove __io_iopoll_check().

Fixes: d59891fe5b0f ("io_uring: don't enter poll loop if we have CQEs pending")
Signed-off-by: Xiaoguang Wang <xiaoguang.wang@linux.alibaba.com>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
fs/io_uring.c