From: Ming Lei <[email protected]>
To: Jens Axboe <[email protected]>
Cc: [email protected], [email protected],
David Howells <[email protected]>,
Chengming Zhou <[email protected]>,
[email protected]
Subject: Re: [PATCH V2] io_uring: fix IO hang in io_wq_put_and_exit from do_exit()
Date: Fri, 1 Sep 2023 23:12:00 +0800 [thread overview]
Message-ID: <ZPH/QEXmh3NiY736@fedora> (raw)
In-Reply-To: <[email protected]>
On Fri, Sep 01, 2023 at 08:47:28AM -0600, Jens Axboe wrote:
> 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.
Here we just cancel requests in io_wq, which is per-task actually.
Yeah, ctx->iopoll_ctx could be shared, but if it is used in this way,
the event can't be avoided to reap from remote context.
>
> 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;
This way isn't enough, any request submitted to io_wq before do_exit()
need to be reaped by io_iopoll_try_reap_events() explicitly.
Not mention IO_URING_F_NONBLOCK isn't set, so io_issue_sqe() may hang
forever.
Thanks,
Ming
next prev parent reply other threads:[~2023-09-01 15:13 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-09-01 13:49 [PATCH V2] io_uring: fix IO hang in io_wq_put_and_exit from do_exit() Ming Lei
2023-09-01 14:47 ` Jens Axboe
2023-09-01 15:12 ` Ming Lei [this message]
2023-09-01 15:13 ` Jens Axboe
2023-09-01 15:13 ` Jens Axboe
2023-09-07 15:36 ` Jens Axboe
2023-09-08 1:03 ` Pavel Begunkov
2023-09-08 6:22 ` Ming Lei
2023-09-08 16:01 ` Pavel Begunkov
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=ZPH/QEXmh3NiY736@fedora \
[email protected] \
[email protected] \
[email protected] \
[email protected] \
[email protected] \
[email protected] \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox