public inbox for [email protected]
 help / color / mirror / Atom feed
From: Bijan Mottahedeh <[email protected]>
To: [email protected]
Cc: [email protected]
Subject: [RFC 1/1] io_uring: use valid mm in io_req_work_grab_env() in SQPOLL mode
Date: Fri, 19 Jun 2020 16:57:44 -0700	[thread overview]
Message-ID: <[email protected]> (raw)
In-Reply-To: <[email protected]>

If current->mm is not set in SQPOLL mode, then use ctx->sqo_mm;
otherwise fail thre request.

Signed-off-by: Bijan Mottahedeh <[email protected]>
---
 fs/io_uring.c | 14 ++++++++++++--
 1 file changed, 12 insertions(+), 2 deletions(-)

diff --git a/fs/io_uring.c b/fs/io_uring.c
index cb696ab..fd53ea6 100644
--- a/fs/io_uring.c
+++ b/fs/io_uring.c
@@ -1062,8 +1062,18 @@ static inline void io_req_work_grab_env(struct io_kiocb *req,
 					const struct io_op_def *def)
 {
 	if (!req->work.mm && def->needs_mm) {
-		mmgrab(current->mm);
-		req->work.mm = current->mm;
+		struct mm_struct *mm = current->mm;
+
+		if (!mm) {
+			if (req->ctx && req->ctx->sqo_thread)
+				mm = req->ctx->sqo_mm;
+			else
+				req->work.flags |= IO_WQ_WORK_CANCEL;
+		}
+		if (mm) {
+			mmgrab(mm);
+			req->work.mm = mm;
+		}
 	}
 	if (!req->work.creds)
 		req->work.creds = get_current_cred();
-- 
1.8.3.1


  reply	other threads:[~2020-06-19 23:59 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-06-19 23:57 [RFC 0/1] io_uring: use valid mm in io_req_work_grab_env() in SQPOLL mode Bijan Mottahedeh
2020-06-19 23:57 ` Bijan Mottahedeh [this message]
2020-06-20  9:59   ` [RFC 1/1] " Pavel Begunkov
2020-06-20 14:22     ` Jens Axboe
2020-06-22 20:48       ` Bijan Mottahedeh
2020-06-20 22:23 ` [RFC 0/1] " 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=1592611064-35370-2-git-send-email-bijan.mottahedeh@oracle.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