diff options
author | Xiaoguang Wang <xiaoguang.wang@linux.alibaba.com> | 2020-02-25 22:12:08 +0800 |
---|---|---|
committer | Jens Axboe <axboe@kernel.dk> | 2020-02-25 08:40:43 -0700 |
commit | bdcd3eab2a9ae0ac93f27275b6895dd95e5bf360 (patch) | |
tree | b5df2a7a9981068aa5a663b3f877867ce123b516 /fs/io-wq.c | |
parent | 41726c9a50e7464beca7112d0aebf3a0090c62d2 (diff) | |
download | linux-bdcd3eab2a9ae0ac93f27275b6895dd95e5bf360.tar.gz linux-bdcd3eab2a9ae0ac93f27275b6895dd95e5bf360.tar.bz2 linux-bdcd3eab2a9ae0ac93f27275b6895dd95e5bf360.zip |
io_uring: fix poll_list race for SETUP_IOPOLL|SETUP_SQPOLL
After making ext4 support iopoll method:
let ext4_file_operations's iopoll method be iomap_dio_iopoll(),
we found fio can easily hang in fio_ioring_getevents() with below fio
job:
rm -f testfile; sync;
sudo fio -name=fiotest -filename=testfile -iodepth=128 -thread
-rw=write -ioengine=io_uring -hipri=1 -sqthread_poll=1 -direct=1
-bs=4k -size=10G -numjobs=8 -runtime=2000 -group_reporting
with IORING_SETUP_SQPOLL and IORING_SETUP_IOPOLL enabled.
There are two issues that results in this hang, one reason is that
when IORING_SETUP_SQPOLL and IORING_SETUP_IOPOLL are enabled, fio
does not use io_uring_enter to get completed events, it relies on
kernel io_sq_thread to poll for completed events.
Another reason is that there is a race: when io_submit_sqes() in
io_sq_thread() submits a batch of sqes, variable 'inflight' will
record the number of submitted reqs, then io_sq_thread will poll for
reqs which have been added to poll_list. But note, if some previous
reqs have been punted to io worker, these reqs will won't be in
poll_list timely. io_sq_thread() will only poll for a part of previous
submitted reqs, and then find poll_list is empty, reset variable
'inflight' to be zero. If app just waits these deferred reqs and does
not wake up io_sq_thread again, then hang happens.
For app that entirely relies on io_sq_thread to poll completed requests,
let io_iopoll_req_issued() wake up io_sq_thread properly when adding new
element to poll_list, and when io_sq_thread prepares to sleep, check
whether poll_list is empty again, if not empty, continue to poll.
Signed-off-by: Xiaoguang Wang <xiaoguang.wang@linux.alibaba.com>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
Diffstat (limited to 'fs/io-wq.c')
0 files changed, 0 insertions, 0 deletions