From: Hao Xu <[email protected]>
To: Jens Axboe <[email protected]>, [email protected]
Cc: [email protected],
[email protected]
Subject: Re: [PATCH v2 2/2] io_uring: ensure task_work gets run as part of cancelations
Date: Fri, 10 Dec 2021 11:29:49 +0800 [thread overview]
Message-ID: <[email protected]> (raw)
In-Reply-To: <[email protected]>
在 2021/12/10 上午12:16, Jens Axboe 写道:
> If we successfully cancel a work item but that work item needs to be
> processed through task_work, then we can be sleeping uninterruptibly
> in io_uring_cancel_generic() and never process it. Hence we don't
> make forward progress and we end up with an uninterruptible sleep
> warning.
>
> Add the waitqueue earlier to ensure that any wakeups from cancelations
> are seen, and switch to using uninterruptible sleep so that postponed
^ typo
> task_work additions get seen and processed.
>
> While in there, correct a comment that should be IFF, not IIF.
>
> Reported-by: [email protected]
> Cc: [email protected]
> Signed-off-by: Jens Axboe <[email protected]>
>
> ---
>
> v2 - don't move prepare_to_wait(), it'll run into issues with locking
> etc, and we don't need to as the inflight tracking guards against
> missing a wakeup for a completion.
>
> diff --git a/fs/io_uring.c b/fs/io_uring.c
> index b4d5b8d168bf..111db33b940e 100644
> --- a/fs/io_uring.c
> +++ b/fs/io_uring.c
> @@ -9826,7 +9826,7 @@ static __cold void io_uring_drop_tctx_refs(struct task_struct *task)
>
> /*
> * Find any io_uring ctx that this task has registered or done IO on, and cancel
> - * requests. @sqd should be not-null IIF it's an SQPOLL thread cancellation.
> + * requests. @sqd should be not-null IFF it's an SQPOLL thread cancellation.
> */
> static __cold void io_uring_cancel_generic(bool cancel_all,
> struct io_sq_data *sqd)
> @@ -9868,8 +9868,10 @@ static __cold void io_uring_cancel_generic(bool cancel_all,
> cancel_all);
> }
>
> - prepare_to_wait(&tctx->wait, &wait, TASK_UNINTERRUPTIBLE);
> + prepare_to_wait(&tctx->wait, &wait, TASK_INTERRUPTIBLE);
> + io_run_task_work();
> io_uring_drop_tctx_refs(current);
> +
> /*
> * If we've seen completions, retry without waiting. This
> * avoids a race where a completion comes in before we did
>
next prev parent reply other threads:[~2021-12-10 3:29 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-12-09 15:59 [PATCHSET 0/2] Cancelation fixes Jens Axboe
2021-12-09 15:59 ` [PATCH 1/2] io_uring: check tctx->in_idle when decrementing inflight_tracked Jens Axboe
2021-12-10 7:21 ` Hao Xu
2021-12-10 13:47 ` Jens Axboe
2021-12-09 15:59 ` [PATCH 2/2] io_uring: ensure task_work gets run as part of cancelations Jens Axboe
2021-12-09 16:16 ` [PATCH v2 " Jens Axboe
2021-12-10 3:29 ` Hao Xu [this message]
2021-12-10 4:22 ` Jens Axboe
2021-12-10 7:31 ` Hao Xu
2021-12-10 13:45 ` Jens Axboe
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=227847a6-a76c-3942-a563-7d492b0d2ced@linux.alibaba.com \
[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