On 9/1/23 7:49 AM, Ming Lei wrote: > io_wq_put_and_exit() is called from do_exit(), but all FIXED_FILE requests > in io_wq aren't canceled in io_uring_cancel_generic() called from do_exit(). > Meantime io_wq IO code path may share resource with normal iopoll code > path. > > So if any HIPRI request is submittd via io_wq, this request may not get resouce > for moving on, given iopoll isn't possible in io_wq_put_and_exit(). > > The issue can be triggered when terminating 't/io_uring -n4 /dev/nullb0' > with default null_blk parameters. > > Fix it by always cancelling all requests in io_wq by adding helper of > io_uring_cancel_wq(), and this way is reasonable because io_wq destroying > follows canceling requests immediately. This does look much cleaner, but the unconditional cancel_all == true makes me a bit nervous in case the ring is being shared. Do we really need to cancel these bits? Can't we get by with something trivial like just stopping retrying if the original task is exiting? diff --git a/io_uring/io_uring.c b/io_uring/io_uring.c index c6d9e4677073..95316c0c3830 100644 --- a/io_uring/io_uring.c +++ b/io_uring/io_uring.c @@ -1939,7 +1939,7 @@ void io_wq_submit_work(struct io_wq_work *work) * If REQ_F_NOWAIT is set, then don't wait or retry with * poll. -EAGAIN is final for that case. */ - if (req->flags & REQ_F_NOWAIT) + if (req->flags & REQ_F_NOWAIT || req->task->flags & PF_EXITING) break; /* -- Jens Axboe