public inbox for [email protected]
 help / color / mirror / Atom feed
From: Stefano Garzarella <[email protected]>
To: Jens Axboe <[email protected]>
Cc: [email protected]
Subject: Re: [PATCH liburing 3/5] Add helpers to set and get eventfd notification status
Date: Wed, 20 May 2020 15:12:21 +0200	[thread overview]
Message-ID: <20200520131221.rktn7dy42e633rvg@steredhat> (raw)
In-Reply-To: <20200515171111.zwgblergup6a23p2@steredhat>

On Fri, May 15, 2020 at 07:11:11PM +0200, Stefano Garzarella wrote:
> On Fri, May 15, 2020 at 10:53:50AM -0600, Jens Axboe wrote:
> > On 5/15/20 10:43 AM, Stefano Garzarella wrote:
> > > This patch adds the new IORING_CQ_EVENTFD_DISABLED flag. It can be
> > > used to disable/enable notifications from the kernel when a
> > > request is completed and queued to the CQ ring.
> > > 
> > > We also add two helpers function to check if the notifications are
> > > enabled and to enable/disable them.
> > > 
> > > If the kernel doesn't provide CQ ring flags, the notifications are
> > > always enabled if an eventfd is registered.
> > > 
> > > Signed-off-by: Stefano Garzarella <[email protected]>
> > > ---
> > >  src/include/liburing.h          | 30 ++++++++++++++++++++++++++++++
> > >  src/include/liburing/io_uring.h |  7 +++++++
> > >  2 files changed, 37 insertions(+)
> > > 
> > > diff --git a/src/include/liburing.h b/src/include/liburing.h
> > > index ea596f6..fe03547 100644
> > > --- a/src/include/liburing.h
> > > +++ b/src/include/liburing.h
> > > @@ -9,7 +9,9 @@ extern "C" {
> > >  #include <sys/socket.h>
> > >  #include <sys/uio.h>
> > >  #include <sys/stat.h>
> > > +#include <errno.h>
> > >  #include <signal.h>
> > > +#include <stdbool.h>
> > >  #include <inttypes.h>
> > >  #include <time.h>
> > >  #include "liburing/compat.h"
> > > @@ -445,6 +447,34 @@ static inline unsigned io_uring_cq_ready(struct io_uring *ring)
> > >  	return io_uring_smp_load_acquire(ring->cq.ktail) - *ring->cq.khead;
> > >  }
> > >  
> > > +static inline int io_uring_cq_eventfd_enable(struct io_uring *ring,
> > > +					     bool enabled)
> > > +{
> > > +	uint32_t flags;
> > > +
> > > +	if (!ring->cq.kflags)
> > > +		return -ENOTSUP;
> > > +
> > > +	flags = *ring->cq.kflags;
> > > +
> > > +	if (enabled)
> > > +		flags &= ~IORING_CQ_EVENTFD_DISABLED;
> > > +	else
> > > +		flags |= IORING_CQ_EVENTFD_DISABLED;
> > > +
> > > +	IO_URING_WRITE_ONCE(*ring->cq.kflags, flags);
> > > +
> > > +	return 0;
> > > +}
> > 
> > The -ENOTSUP seems a bit odd, I wonder if we should even flag that as an
> > error.
> 
> Do you think it's better to ignore the enabling/disabling if we don't have
> the flag field available?
> 
> > 
> > The function should probably also be io_uring_cq_eventfd_toggle() or
> > something like that, as it does both enable and disable.
> > 
> > Either that, or have two functions, and enable and disable.
> 
> Okay, I'll change it in io_uring_cq_eventfd_toggle().
> 
> > 
> > The bigger question is probably how to handle kernels that don't
> > have this feature. It'll succeed, but we'll still post events. Maybe
> > the kernel side should have a feature flag that we can test?
> 
> I thought about that, and initially I added a
> IORING_FEAT_EVENTFD_DISABLE, but then I realized that we are adding
> the CQ 'flags' field together with the eventfd disabling feature.
> 
> So I supposed that if 'p->cq_off.flags' is not zero, than the kernel
> supports CQ flags and also the IORING_CQ_EVENTFD_DISABLED bit.
> 
> Do you think that's okay, or should we add IORING_FEAT_EVENTFD_DISABLE
> (or something similar)?

Hi Jens,
I'm changing io_uring_cq_eventfd_enable() to io_uring_cq_eventfd_toggle().

Any advice on the error and eventual feature flag?

Thank you very much,
Stefano


  reply	other threads:[~2020-05-20 13:12 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-05-15 16:43 [PATCH liburing 0/5] liburing: add helpers to enable/disable eventfd notifications Stefano Garzarella
2020-05-15 16:43 ` [PATCH liburing 1/5] Add CQ ring 'flags' field Stefano Garzarella
2020-05-15 16:43 ` [PATCH liburing 2/5] man/io_uring_setup.2: add 'flags' field in the struct io_cqring_offsets Stefano Garzarella
2020-05-15 16:43 ` [PATCH liburing 3/5] Add helpers to set and get eventfd notification status Stefano Garzarella
2020-05-15 16:53   ` Jens Axboe
2020-05-15 17:11     ` Stefano Garzarella
2020-05-20 13:12       ` Stefano Garzarella [this message]
2020-05-20 13:43         ` Jens Axboe
2020-05-20 15:11           ` Stefano Garzarella
2020-05-20 15:19             ` Jens Axboe
2020-05-15 16:43 ` [PATCH liburing 4/5] man/io_uring_register.2: add IORING_CQ_EVENTFD_DISABLED description Stefano Garzarella
2020-05-15 16:43 ` [PATCH liburing 5/5] Add test/eventfd-disable.c test case Stefano Garzarella

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=20200520131221.rktn7dy42e633rvg@steredhat \
    [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