linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Pavel Begunkov <asml.silence@gmail.com>
To: Jens Axboe <axboe@kernel.dk>,
	io-uring@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH 2/6] io_uring: simplify io_timeout locking
Date: Tue, 26 May 2020 20:34:03 +0300	[thread overview]
Message-ID: <a34d6960cbd39aed1361b7cfd0a606acddfec193.1590513806.git.asml.silence@gmail.com> (raw)
In-Reply-To: <cover.1590513806.git.asml.silence@gmail.com>

Move spin_lock_irq() earlier to have only 1 call site of it in
io_timeout(). It makes the flow easier.

Signed-off-by: Pavel Begunkov <asml.silence@gmail.com>
---
 fs/io_uring.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/fs/io_uring.c b/fs/io_uring.c
index 42b5603ee410..e30fc17dd268 100644
--- a/fs/io_uring.c
+++ b/fs/io_uring.c
@@ -4845,6 +4845,7 @@ static int io_timeout(struct io_kiocb *req)
 	u32 seq = req->sequence;
 
 	data = &req->io->timeout;
+	spin_lock_irq(&ctx->completion_lock);
 
 	/*
 	 * sqe->off holds how many events that need to occur for this
@@ -4853,7 +4854,6 @@ static int io_timeout(struct io_kiocb *req)
 	 */
 	if (!count) {
 		req->flags |= REQ_F_TIMEOUT_NOSEQ;
-		spin_lock_irq(&ctx->completion_lock);
 		entry = ctx->timeout_list.prev;
 		goto add;
 	}
@@ -4864,7 +4864,6 @@ static int io_timeout(struct io_kiocb *req)
 	 * Insertion sort, ensuring the first entry in the list is always
 	 * the one we need first.
 	 */
-	spin_lock_irq(&ctx->completion_lock);
 	list_for_each_prev(entry, &ctx->timeout_list) {
 		struct io_kiocb *nxt = list_entry(entry, struct io_kiocb, list);
 		unsigned nxt_seq;
-- 
2.24.0


  parent reply	other threads:[~2020-05-26 17:36 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-05-26 17:34 [PATCH 0/6] random patches for 5.8 Pavel Begunkov
2020-05-26 17:34 ` [PATCH 1/6] io_uring: fix flush req->refs underflow Pavel Begunkov
2020-05-26 18:04   ` Jens Axboe
2020-05-26 17:34 ` Pavel Begunkov [this message]
2020-05-26 17:34 ` [PATCH 3/6] io_uring: don't re-read sqe->off in timeout_prep() Pavel Begunkov
2020-05-26 17:34 ` [PATCH 4/6] io_uring: separate DRAIN flushing into a cold path Pavel Begunkov
2020-05-26 17:34 ` [PATCH 5/6] io_uring: get rid of manual punting in io_close Pavel Begunkov
2020-05-26 17:34 ` [PATCH 6/6] io_uring: let io_req_aux_free() handle fixed files Pavel Begunkov
2020-05-26 18:03   ` Jens Axboe
2020-05-26 18:11     ` Pavel Begunkov
2020-05-26 19:32 ` [PATCH 0/6] random patches for 5.8 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=a34d6960cbd39aed1361b7cfd0a606acddfec193.1590513806.git.asml.silence@gmail.com \
    --to=asml.silence@gmail.com \
    --cc=axboe@kernel.dk \
    --cc=io-uring@vger.kernel.org \
    --cc=linux-kernel@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).