linux-block.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jens Axboe <axboe@kernel.dk>
To: Bijan Mottahedeh <bijan.mottahedeh@oracle.com>
Cc: linux-block@vger.kernel.org
Subject: Re: [RFC 2/2] io_uring: acquire ctx->uring_lock before calling io_issue_sqe()
Date: Wed, 15 Jan 2020 21:42:25 -0700	[thread overview]
Message-ID: <8f7986c7-e5b4-8f24-1c71-666c01b16c8b@kernel.dk> (raw)
In-Reply-To: <9b359dde-3bb6-5886-264b-4bee90be9e25@kernel.dk>

On 1/15/20 9:34 PM, Jens Axboe wrote:
> On 1/15/20 7:37 PM, Bijan Mottahedeh wrote:
>> io_issue_sqe() calls io_iopoll_req_issued() which manipulates poll_list,
>> so acquire ctx->uring_lock beforehand similar to other instances of
>> calling io_issue_sqe().
> 
> Is the below not enough?

This should be better, we have two that set ->in_async, and only one
doesn't hold the mutex.

If this works for you, can you resend patch 2 with that? Also add a:

Fixes: 8a4955ff1cca ("io_uring: sqthread should grab ctx->uring_lock for submissions")

to it as well. Thanks!

diff --git a/fs/io_uring.c b/fs/io_uring.c
index 3130ed16456e..52e5764540e4 100644
--- a/fs/io_uring.c
+++ b/fs/io_uring.c
@@ -3286,10 +3286,19 @@ static int io_issue_sqe(struct io_kiocb *req, const struct io_uring_sqe *sqe,
 		return ret;
 
 	if (ctx->flags & IORING_SETUP_IOPOLL) {
+		const bool in_async = io_wq_current_is_worker();
+
 		if (req->result == -EAGAIN)
 			return -EAGAIN;
 
+		/* workqueue context doesn't hold uring_lock, grab it now */
+		if (in_async)
+			mutex_lock(&ctx->uring_lock);
+
 		io_iopoll_req_issued(req);
+
+		if (in_async)
+			mutex_unlock(&ctx->uring_lock);
 	}
 
 	return 0;

-- 
Jens Axboe


  reply	other threads:[~2020-01-16  4:42 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-01-16  2:37 [RFC 0/2] Fixes for fio io_uring polled mode test failures Bijan Mottahedeh
2020-01-16  2:37 ` [RFC 1/2] io_uring: clear req->result always before issuing a read/write request Bijan Mottahedeh
2020-01-16  4:34   ` Jens Axboe
2020-01-16  2:37 ` [RFC 2/2] io_uring: acquire ctx->uring_lock before calling io_issue_sqe() Bijan Mottahedeh
2020-01-16  4:34   ` Jens Axboe
2020-01-16  4:42     ` Jens Axboe [this message]
2020-01-16 16:22       ` Jens Axboe
2020-01-16 19:08         ` Bijan Mottahedeh
2020-01-16 20:02           ` Jens Axboe
2020-01-16 21:04             ` Bijan Mottahedeh
2020-01-16 21:26               ` Jens Axboe
2020-01-28 20:34                 ` Bijan Mottahedeh
2020-01-28 23:37                   ` Jens Axboe
2020-01-28 23:49                     ` Bijan Mottahedeh
2020-01-28 23:52                       ` Jens Axboe
2020-01-31  3:36                         ` Bijan Mottahedeh

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=8f7986c7-e5b4-8f24-1c71-666c01b16c8b@kernel.dk \
    --to=axboe@kernel.dk \
    --cc=bijan.mottahedeh@oracle.com \
    --cc=linux-block@vger.kernel.org \
    /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;
as well as URLs for NNTP newsgroup(s).