public inbox for [email protected]
 help / color / mirror / Atom feed
From: Pavel Begunkov <[email protected]>
To: Jens Axboe <[email protected]>, [email protected]
Cc: [email protected]
Subject: [PATCH 1/2] io_uring: wait potential ->release() on resurrect
Date: Sat, 20 Feb 2021 01:39:52 +0000	[thread overview]
Message-ID: <75e1c94aff46a5bc409f50e50207f4d9a01ff9a0.1613785076.git.asml.silence@gmail.com> (raw)
In-Reply-To: <[email protected]>

There is a short window where percpu_refs are already turned zero, but
we try to do resurrect(). Play nicer and wait for all users to leave RCU
section.

Cc: <[email protected]> # 5.5+
Signed-off-by: Pavel Begunkov <[email protected]>
---
 fs/io_uring.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/fs/io_uring.c b/fs/io_uring.c
index f3af499b12a9..ce5fccf00367 100644
--- a/fs/io_uring.c
+++ b/fs/io_uring.c
@@ -7351,6 +7351,7 @@ static int io_rsrc_ref_quiesce(struct fixed_rsrc_data *data,
 			break;
 
 		percpu_ref_resurrect(&data->refs);
+		synchronize_rcu();
 		io_sqe_rsrc_set_node(ctx, data, backup_node);
 		reinit_completion(&data->done);
 		mutex_unlock(&ctx->uring_lock);
@@ -10089,6 +10090,7 @@ static int __io_uring_register(struct io_ring_ctx *ctx, unsigned opcode,
 
 		if (ret) {
 			percpu_ref_resurrect(&ctx->refs);
+			synchronize_rcu();
 			goto out_quiesce;
 		}
 	}
-- 
2.24.0


  reply	other threads:[~2021-02-20  1:44 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-02-20  1:39 [PATCH 0/2] random fixes Pavel Begunkov
2021-02-20  1:39 ` Pavel Begunkov [this message]
2021-02-20  3:40   ` [PATCH 1/2] io_uring: wait potential ->release() on resurrect Jens Axboe
2021-02-20  3:47     ` Pavel Begunkov
2021-02-20  3:53       ` Jens Axboe
2021-02-20  1:39 ` [PATCH 2/2] io_uring: fix leaving invalid req->flags Pavel Begunkov
2021-02-20  4:17   ` Jens Axboe
  -- strict thread matches above, loose matches on Subject: below --
2021-02-20 17:21 [PATCH 0/2] resurrect Pavel Begunkov
2021-02-20 17:21 ` [PATCH 1/2] io_uring: wait potential ->release() on resurrect Pavel Begunkov

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=75e1c94aff46a5bc409f50e50207f4d9a01ff9a0.1613785076.git.asml.silence@gmail.com \
    [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