All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jens Axboe <axboe@kernel.dk>
To: Usama Arif <usama.arif@bytedance.com>,
	io-uring@vger.kernel.org, asml.silence@gmail.com,
	linux-kernel@vger.kernel.org
Cc: fam.zheng@bytedance.com
Subject: Re: [PATCH 1/2] io_uring: avoid ring quiesce while registering/unregistering eventfd
Date: Thu, 3 Feb 2022 09:58:58 -0700	[thread overview]
Message-ID: <da09cb46-9d60-71a3-a758-46d082989bae@kernel.dk> (raw)
In-Reply-To: <62f59304-1a0e-1047-f474-94097cb8b13e@bytedance.com>

On 2/3/22 9:49 AM, Usama Arif wrote:
>> One thing that both mine and your version suffers from is if someone
>> does an eventfd unregister, and then immediately does an eventfd
>> register. If the rcu grace period hasn't passed, we'll get -EBUSY on
>> trying to do that, when I think the right behavior there would be to
>> wait for the grace period to pass.
>>
>> I do think we need to handle that gracefully, spurious -EBUSY is
>> impossible for an application to deal with.
> 
> I don't think my version would suffer from this as its protected by 
> locks? The mutex_unlock on ev_fd_lock in unregister happens only after 
> the call_rcu. And the mutex is locked in io_eventfd_register at the 
> start, so wouldnt get the -EBUSY if there is a register immediately 
> after unregister?

The call_rcu() just registers it for getting the callback when the grace
period has passed, it doesn't mean it's done by the time it returns.
Hence there's definitely a window where you can enter
io_uring_register() with the callback still being pending, and you'd get
-EBUSY from that.

-- 
Jens Axboe


  reply	other threads:[~2022-02-03 16:59 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-02-03 15:11 [PATCH 0/2] io_uring: avoid ring quiesce in io_uring_register for eventfd opcodes Usama Arif
2022-02-03 15:11 ` [PATCH 1/2] io_uring: avoid ring quiesce while registering/unregistering eventfd Usama Arif
2022-02-03 15:48   ` Pavel Begunkov
2022-02-03 17:47     ` Usama Arif
2022-02-03 15:55   ` Jens Axboe
2022-02-03 16:49     ` Usama Arif
2022-02-03 16:58       ` Jens Axboe [this message]
2022-02-03 17:42         ` [External] " Usama Arif
2022-02-03 15:11 ` [PATCH 2/2] io_uring: avoid ring quiesce for IORING_REGISTER_EVENTFD_ASYNC Usama Arif

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=da09cb46-9d60-71a3-a758-46d082989bae@kernel.dk \
    --to=axboe@kernel.dk \
    --cc=asml.silence@gmail.com \
    --cc=fam.zheng@bytedance.com \
    --cc=io-uring@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=usama.arif@bytedance.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.