public inbox for [email protected]
 help / color / mirror / Atom feed
From: Pavel Begunkov <[email protected]>
To: Jens Axboe <[email protected]>, [email protected]
Subject: [PATCH 3/3] io_uring: fix cancellation hangs
Date: Sun, 20 Dec 2020 13:21:45 +0000	[thread overview]
Message-ID: <f06b936c1a537828f4055a3673d05e82c846d77c.1608469706.git.asml.silence@gmail.com> (raw)
In-Reply-To: <[email protected]>

We may enter files cancellation with requests that we want to cancel and
that are currently enqueued as task_work. However, before that happens
do_exit() sets PF_EXITING, disabling io_run_task_work() and so locking
up cancellation.

Also, if run between setting PF_EXITING and exit_task_work(), as the
case exit_files() and so io_uring cancellation, task_work_add() might
actually enqueue more task works.

Signed-off-by: Pavel Begunkov <[email protected]>
---
 fs/io_uring.c | 6 ------
 1 file changed, 6 deletions(-)

diff --git a/fs/io_uring.c b/fs/io_uring.c
index 30edf47a8f1a..941fe9b64fd9 100644
--- a/fs/io_uring.c
+++ b/fs/io_uring.c
@@ -2357,12 +2357,6 @@ static inline unsigned int io_put_rw_kbuf(struct io_kiocb *req)
 
 static inline bool io_run_task_work(void)
 {
-	/*
-	 * Not safe to run on exiting task, and the task_work handling will
-	 * not add work to such a task.
-	 */
-	if (unlikely(current->flags & PF_EXITING))
-		return false;
 	if (current->task_works) {
 		__set_current_state(TASK_RUNNING);
 		task_work_run();
-- 
2.24.0


  parent reply	other threads:[~2020-12-20 13:26 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-12-20 13:21 [PATCH 0/3] task/files cancellation fixes Pavel Begunkov
2020-12-20 13:21 ` [PATCH 1/3] io_uring: always progress task_work on task cancel Pavel Begunkov
2020-12-20 13:21 ` [PATCH 2/3] io_uring: end waiting before task cancel attempts Pavel Begunkov
2020-12-20 13:21 ` Pavel Begunkov [this message]
2020-12-20 18:01 ` [PATCH 0/3] task/files cancellation fixes Pavel Begunkov
2020-12-20 18:05   ` 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=f06b936c1a537828f4055a3673d05e82c846d77c.1608469706.git.asml.silence@gmail.com \
    [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