public inbox for [email protected]
 help / color / mirror / Atom feed
From: Jens Axboe <[email protected]>
To: Xiaoguang Wang <[email protected]>,
	[email protected]
Cc: [email protected]
Subject: Re: [PATCH] io_uring: add io_uring_enter(2) fixed file support
Date: Tue, 8 Mar 2022 06:10:09 -0700	[thread overview]
Message-ID: <[email protected]> (raw)
In-Reply-To: <[email protected]>

On 3/8/22 1:38 AM, Xiaoguang Wang wrote:
> hi,
> 
>>>> I'll take a look at liburing and see what we need to do there. I think
>>>> the sanest thing to do here is say that using a registered ring fd means
>>>> you cannot share the ring, ever. And then just have a
>>>> ring->enter_ring_fd which is normally just set to ring_fd when the ring
>>>> is setup, and if you register the ring fd, then we set it to whatever
>>>> the registered value is. Everything calling io_uring_enter() then just
>>>> needs to be modified to use ->enter_ring_fd instead of ->ring_fd.
>>> ok, look forward to use this api.
>> Can you take a look at the registered-ring branch for liburing:
>>
>> https://git.kernel.dk/cgit/liburing/log/?h=registered-ring
>>
>> which has the basic plumbing for it. Comments (or patches) welcome!
> Sorry for late reply, spend time to read your patch today. Basically it looks ok,
> there is one minor issue in "Add preliminary support for using a registered ring fd":
> @@ -417,6 +425,10 @@ struct io_uring_sqe *io_uring_get_sqe(struct io_uring *ring)
> 
>  int __io_uring_sqring_wait(struct io_uring *ring)
>  {
> -    return  ____sys_io_uring_enter(ring->ring_fd, 0, 0,
> -                       IORING_ENTER_SQ_WAIT, NULL);
> +    int flags = IORING_ENTER_SQ_WAIT;
> +
> +    if (ring->int_flags & INT_FLAG_REG_RING)
> +        flags |= IORING_ENTER_REGISTERED_RING;
> +
> +    return  ____sys_io_uring_enter(ring->ring_fd, 0, 0, flags, NULL);
>  }
> 
> Here it should be enter_ring_fd.

Ah good catch, I've fixed that up.

>> Few things I don't really love:
>>
>> 1) You need to call io_uring_register_ring_fd() after setting up the
>>     ring. We could provide init helpers for that, which just do queue
>>     init and then register ring. Maybe that'd make it more likely to get
>>     picked up by applications.
> Agree, that'd be better in some cases, but consider that currently the
> capacity of ring fd cache is just 16, I'd suggest to let users make
> their own decisions, in case some ring fds could not allocate one
> empty slot, but some ring fds don't need them at all, for example,
> ring fd which enable sqpoll may no need this feature.

Agree, that's the route I ended up taking too.

>> 2) For the setup where you do share the ring between a submitter and
>>     reaper, we need to ensure that the registered ring fd is the same
>>     between both of them. We need a helper for that. It's basically the
>>     same as io_uring_register_ring_fd(), but we need the specific offset.
>>     And if that fails with -EBUSY, we should just turn off
>>     INT_FLAG_RING_REG for the ring and you don't get the registered fd
>>     for either of them. At least it can be handled transparantly.
> Storing enter_ring_fd in struct io_uring seems not good, struct
> io_uring is a shared struct, as what you say, different threads that
> share one ring fd may have differed offset in ring fd cache. I have
> two suggestions:
> 1) Threads keep their offset in ring fd cache alone, and pass it to
> io_uring_submit, which may look ugly :)
> 2) define enter_ring_fd in struct io_ring to be a thread_local type,
> then your patches don't need to do any modifications.

Maybe I'm missing something here, but I don't see how your number 2 is
possible?

I think for now I'll just keep it as-is. Yes, then you can't use a
registered ring fd if you share the ring betwen threads, but so be it.

-- 
Jens Axboe


  reply	other threads:[~2022-03-08 13:10 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-03-03  5:28 [PATCH] io_uring: add io_uring_enter(2) fixed file support Xiaoguang Wang
2022-03-03  8:56 ` Hao Xu
2022-03-03 13:38 ` Jens Axboe
2022-03-03 14:36   ` Jens Axboe
2022-03-03 14:40     ` Jens Axboe
2022-03-03 16:31       ` Jens Axboe
2022-03-03 17:18         ` Jens Axboe
2022-03-03 20:41           ` Jens Axboe
2022-03-03 21:19             ` Jens Axboe
2022-03-04  0:07               ` Jens Axboe
2022-03-04 13:39                 ` Xiaoguang Wang
2022-03-04 13:44                   ` Jens Axboe
2022-03-04 15:16                     ` Xiaoguang Wang
2022-03-04 15:22                       ` Jens Axboe
2022-03-08  8:38                         ` Xiaoguang Wang
2022-03-08 13:10                           ` Jens Axboe [this message]
2022-03-03 22:24             ` Vito Caputo
2022-03-03 22:26               ` Jens Axboe
2022-03-04  1:49         ` Pavel Begunkov
2022-03-04  2:18           ` Jens Axboe
2022-03-04  2:28             ` Pavel Begunkov
2022-03-04  2:35               ` Pavel Begunkov
2022-03-04  2:43               ` Jens Axboe
2022-03-04  1:52         ` Pavel Begunkov
2022-03-04  2:19           ` Jens Axboe
2022-03-04  2:39             ` Pavel Begunkov
2022-03-04  3:03               ` Jens Axboe
2022-04-21 14:16     ` Hao Xu

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 \
    [email protected] \
    [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