io_uring: wait interruptibly for request completions on exit
authorJens Axboe <axboe@kernel.dk>
Mon, 12 Jun 2023 03:14:09 +0000 (21:14 -0600)
committerJens Axboe <axboe@kernel.dk>
Mon, 12 Jun 2023 15:43:57 +0000 (09:43 -0600)
commit4826c59453b3b4677d6bf72814e7ababdea86949
treeee5a531bdc02c675f0519f0b3d9a3780e67ddca3
parent003f242b0dc16b287e6d15833d1d7f4adfa346ff
io_uring: wait interruptibly for request completions on exit

WHen the ring exits, cleanup is done and the final cancelation and
waiting on completions is done by io_ring_exit_work. That function is
invoked by kworker, which doesn't take any signals. Because of that, it
doesn't really matter if we wait for completions in TASK_INTERRUPTIBLE
or TASK_UNINTERRUPTIBLE state. However, it does matter to the hung task
detection checker!

Normally we expect cancelations and completions to happen rather
quickly. Some test cases, however, will exit the ring and park the
owning task stopped (eg via SIGSTOP). If the owning task needs to run
task_work to complete requests, then io_ring_exit_work won't make any
progress until the task is runnable again. Hence io_ring_exit_work can
trigger the hung task detection, which is particularly problematic if
panic-on-hung-task is enabled.

As the ring exit doesn't take signals to begin with, have it wait
interruptibly rather than uninterruptibly. io_uring has a separate
stuck-exit warning that triggers independently anyway, so we're not
really missing anything by making this switch.

Cc: stable@vger.kernel.org # 5.10+
Link: https://lore.kernel.org/r/b0e4aaef-7088-56ce-244c-976edeac0e66@kernel.dk
Signed-off-by: Jens Axboe <axboe@kernel.dk>
io_uring/io_uring.c