mbox series

[0/2] io_uring: add a CQ ring flag to enable/disable eventfd notification

Message ID 20200515105414.68683-1-sgarzare@redhat.com (mailing list archive)
Headers show
Series io_uring: add a CQ ring flag to enable/disable eventfd notification | expand

Message

Stefano Garzarella May 15, 2020, 10:54 a.m. UTC
The first patch adds the new 'cq_flags' field for the CQ ring. It
should be written by the application and read by the kernel.

The second patch adds a new IORING_CQ_NEED_WAKEUP flag that can be
used by the application to enable/disable eventfd notifications.

I'm not sure the name is the best one, an alternative could be
IORING_CQ_NEED_EVENT.

This feature can be useful if the application are using eventfd to be
notified when requests are completed, but they don't want a notification
for every request.
Of course the application can already remove the eventfd from the event
loop, but as soon as it adds the eventfd again, it will be notified,
even if it has already handled all the completed requests.

The most important use case is when the registered eventfd is used to
notify a KVM guest through irqfd and we want a mechanism to
enable/disable interrupts.

I also extended liburing API and added a test case here:
https://github.com/stefano-garzarella/liburing/tree/eventfd-disable

Stefano Garzarella (2):
  io_uring: add 'cq_flags' field for the CQ ring
  io_uring: add IORING_CQ_NEED_WAKEUP to the CQ ring flags

 fs/io_uring.c                 | 17 ++++++++++++++++-
 include/uapi/linux/io_uring.h |  9 ++++++++-
 2 files changed, 24 insertions(+), 2 deletions(-)

Comments

Jens Axboe May 15, 2020, 2:24 p.m. UTC | #1
On 5/15/20 4:54 AM, Stefano Garzarella wrote:
> The first patch adds the new 'cq_flags' field for the CQ ring. It
> should be written by the application and read by the kernel.
> 
> The second patch adds a new IORING_CQ_NEED_WAKEUP flag that can be
> used by the application to enable/disable eventfd notifications.
> 
> I'm not sure the name is the best one, an alternative could be
> IORING_CQ_NEED_EVENT.
> 
> This feature can be useful if the application are using eventfd to be
> notified when requests are completed, but they don't want a notification
> for every request.
> Of course the application can already remove the eventfd from the event
> loop, but as soon as it adds the eventfd again, it will be notified,
> even if it has already handled all the completed requests.
> 
> The most important use case is when the registered eventfd is used to
> notify a KVM guest through irqfd and we want a mechanism to
> enable/disable interrupts.
> 
> I also extended liburing API and added a test case here:
> https://github.com/stefano-garzarella/liburing/tree/eventfd-disable

Don't mind the feature, and I think the patches look fine. But the name
is really horrible, I'd have no idea what that flag does without looking
at the code or a man page. Why not call it IORING_CQ_EVENTFD_ENABLED or
something like that? Or maybe IORING_CQ_EVENTFD_DISABLED, and then you
don't have to muck with the default value either. The app would set the
flag to disable eventfd, temporarily, and clear it again when it wants
notifications again.
Stefano Garzarella May 15, 2020, 2:34 p.m. UTC | #2
On Fri, May 15, 2020 at 08:24:58AM -0600, Jens Axboe wrote:
> On 5/15/20 4:54 AM, Stefano Garzarella wrote:
> > The first patch adds the new 'cq_flags' field for the CQ ring. It
> > should be written by the application and read by the kernel.
> > 
> > The second patch adds a new IORING_CQ_NEED_WAKEUP flag that can be
> > used by the application to enable/disable eventfd notifications.
> > 
> > I'm not sure the name is the best one, an alternative could be
> > IORING_CQ_NEED_EVENT.
> > 
> > This feature can be useful if the application are using eventfd to be
> > notified when requests are completed, but they don't want a notification
> > for every request.
> > Of course the application can already remove the eventfd from the event
> > loop, but as soon as it adds the eventfd again, it will be notified,
> > even if it has already handled all the completed requests.
> > 
> > The most important use case is when the registered eventfd is used to
> > notify a KVM guest through irqfd and we want a mechanism to
> > enable/disable interrupts.
> > 
> > I also extended liburing API and added a test case here:
> > https://github.com/stefano-garzarella/liburing/tree/eventfd-disable
> 
> Don't mind the feature, and I think the patches look fine. But the name
> is really horrible, I'd have no idea what that flag does without looking
> at the code or a man page. Why not call it IORING_CQ_EVENTFD_ENABLED or
> something like that? Or maybe IORING_CQ_EVENTFD_DISABLED, and then you
> don't have to muck with the default value either. The app would set the
> flag to disable eventfd, temporarily, and clear it again when it wants
> notifications again.

You're clearly right! :-) The name was horrible.

I agree that IORING_CQ_EVENTFD_DISABLED should be the best.
I'll send a v2 changing the name and removing the default value.

Thanks,
Stefano
Jens Axboe May 15, 2020, 3:13 p.m. UTC | #3
On 5/15/20 8:34 AM, Stefano Garzarella wrote:
> On Fri, May 15, 2020 at 08:24:58AM -0600, Jens Axboe wrote:
>> On 5/15/20 4:54 AM, Stefano Garzarella wrote:
>>> The first patch adds the new 'cq_flags' field for the CQ ring. It
>>> should be written by the application and read by the kernel.
>>>
>>> The second patch adds a new IORING_CQ_NEED_WAKEUP flag that can be
>>> used by the application to enable/disable eventfd notifications.
>>>
>>> I'm not sure the name is the best one, an alternative could be
>>> IORING_CQ_NEED_EVENT.
>>>
>>> This feature can be useful if the application are using eventfd to be
>>> notified when requests are completed, but they don't want a notification
>>> for every request.
>>> Of course the application can already remove the eventfd from the event
>>> loop, but as soon as it adds the eventfd again, it will be notified,
>>> even if it has already handled all the completed requests.
>>>
>>> The most important use case is when the registered eventfd is used to
>>> notify a KVM guest through irqfd and we want a mechanism to
>>> enable/disable interrupts.
>>>
>>> I also extended liburing API and added a test case here:
>>> https://github.com/stefano-garzarella/liburing/tree/eventfd-disable
>>
>> Don't mind the feature, and I think the patches look fine. But the name
>> is really horrible, I'd have no idea what that flag does without looking
>> at the code or a man page. Why not call it IORING_CQ_EVENTFD_ENABLED or
>> something like that? Or maybe IORING_CQ_EVENTFD_DISABLED, and then you
>> don't have to muck with the default value either. The app would set the
>> flag to disable eventfd, temporarily, and clear it again when it wants
>> notifications again.
> 
> You're clearly right! :-) The name was horrible.

Sometimes you go down that path on naming and just can't think of
the right one. I think we've all been there.

> I agree that IORING_CQ_EVENTFD_DISABLED should be the best.
> I'll send a v2 changing the name and removing the default value.

Great thanks, and please do queue a pull for the liburing side too.
Stefano Garzarella May 15, 2020, 3:24 p.m. UTC | #4
On Fri, May 15, 2020 at 09:13:33AM -0600, Jens Axboe wrote:
> On 5/15/20 8:34 AM, Stefano Garzarella wrote:
> > On Fri, May 15, 2020 at 08:24:58AM -0600, Jens Axboe wrote:
> >> On 5/15/20 4:54 AM, Stefano Garzarella wrote:
> >>> The first patch adds the new 'cq_flags' field for the CQ ring. It
> >>> should be written by the application and read by the kernel.
> >>>
> >>> The second patch adds a new IORING_CQ_NEED_WAKEUP flag that can be
> >>> used by the application to enable/disable eventfd notifications.
> >>>
> >>> I'm not sure the name is the best one, an alternative could be
> >>> IORING_CQ_NEED_EVENT.
> >>>
> >>> This feature can be useful if the application are using eventfd to be
> >>> notified when requests are completed, but they don't want a notification
> >>> for every request.
> >>> Of course the application can already remove the eventfd from the event
> >>> loop, but as soon as it adds the eventfd again, it will be notified,
> >>> even if it has already handled all the completed requests.
> >>>
> >>> The most important use case is when the registered eventfd is used to
> >>> notify a KVM guest through irqfd and we want a mechanism to
> >>> enable/disable interrupts.
> >>>
> >>> I also extended liburing API and added a test case here:
> >>> https://github.com/stefano-garzarella/liburing/tree/eventfd-disable
> >>
> >> Don't mind the feature, and I think the patches look fine. But the name
> >> is really horrible, I'd have no idea what that flag does without looking
> >> at the code or a man page. Why not call it IORING_CQ_EVENTFD_ENABLED or
> >> something like that? Or maybe IORING_CQ_EVENTFD_DISABLED, and then you
> >> don't have to muck with the default value either. The app would set the
> >> flag to disable eventfd, temporarily, and clear it again when it wants
> >> notifications again.
> > 
> > You're clearly right! :-) The name was horrible.
> 
> Sometimes you go down that path on naming and just can't think of
> the right one. I think we've all been there.

:-)

> 
> > I agree that IORING_CQ_EVENTFD_DISABLED should be the best.
> > I'll send a v2 changing the name and removing the default value.
> 
> Great thanks, and please do queue a pull for the liburing side too.

For the liburing side do you prefer a PR on github or posting the
patches on io-uring@vger.kernel.org with 'liburing' tag?

Thanks,
Stefano
Jens Axboe May 15, 2020, 3:26 p.m. UTC | #5
On 5/15/20 9:24 AM, Stefano Garzarella wrote:
> On Fri, May 15, 2020 at 09:13:33AM -0600, Jens Axboe wrote:
>> On 5/15/20 8:34 AM, Stefano Garzarella wrote:
>>> On Fri, May 15, 2020 at 08:24:58AM -0600, Jens Axboe wrote:
>>>> On 5/15/20 4:54 AM, Stefano Garzarella wrote:
>>>>> The first patch adds the new 'cq_flags' field for the CQ ring. It
>>>>> should be written by the application and read by the kernel.
>>>>>
>>>>> The second patch adds a new IORING_CQ_NEED_WAKEUP flag that can be
>>>>> used by the application to enable/disable eventfd notifications.
>>>>>
>>>>> I'm not sure the name is the best one, an alternative could be
>>>>> IORING_CQ_NEED_EVENT.
>>>>>
>>>>> This feature can be useful if the application are using eventfd to be
>>>>> notified when requests are completed, but they don't want a notification
>>>>> for every request.
>>>>> Of course the application can already remove the eventfd from the event
>>>>> loop, but as soon as it adds the eventfd again, it will be notified,
>>>>> even if it has already handled all the completed requests.
>>>>>
>>>>> The most important use case is when the registered eventfd is used to
>>>>> notify a KVM guest through irqfd and we want a mechanism to
>>>>> enable/disable interrupts.
>>>>>
>>>>> I also extended liburing API and added a test case here:
>>>>> https://github.com/stefano-garzarella/liburing/tree/eventfd-disable
>>>>
>>>> Don't mind the feature, and I think the patches look fine. But the name
>>>> is really horrible, I'd have no idea what that flag does without looking
>>>> at the code or a man page. Why not call it IORING_CQ_EVENTFD_ENABLED or
>>>> something like that? Or maybe IORING_CQ_EVENTFD_DISABLED, and then you
>>>> don't have to muck with the default value either. The app would set the
>>>> flag to disable eventfd, temporarily, and clear it again when it wants
>>>> notifications again.
>>>
>>> You're clearly right! :-) The name was horrible.
>>
>> Sometimes you go down that path on naming and just can't think of
>> the right one. I think we've all been there.
> 
> :-)
> 
>>
>>> I agree that IORING_CQ_EVENTFD_DISABLED should be the best.
>>> I'll send a v2 changing the name and removing the default value.
>>
>> Great thanks, and please do queue a pull for the liburing side too.
> 
> For the liburing side do you prefer a PR on github or posting the
> patches on io-uring@vger.kernel.org with 'liburing' tag?

Either one is fine. I tend to prefer patches, but that's mostly because
various contributors on the liburing side don't have the same kind of
patch writing etiquette that we do on the kernel side. Hence they need
massaging in terms of commit messages, and patches are then easier. But
for you, just do what you prefer. I never use the github merge features,
always do it manually myself anyway.