axboe / liburing

Library providing helpers for the Linux kernel io_uring support
MIT License
2.85k stars 402 forks source link

Question regarding behavior of IORING_POLL_ADD_MULTI #1014

Closed man9ourah closed 1 month ago

man9ourah commented 10 months ago

Hello,

my kernel version: 6.2.0-32-generic

is IORING_POLL_ADD_MULTI supposed to be edge-triggered or level-triggered? Right now I am using it and assuming that it is the former and expecting a cqe for when an event is set and then when it is cleared. For example, if I got a poll cqe with POLLIN event and handled it fully with read, will I get another poll cqe stating the new status of the event?

Just to share what I really want: I want my application to be up-to-date with the status of the event on a fd. Whenever it changes to either state, I want to receive a cqe with the new state. Is that possible?

Just adding references here to why I thought it is edge-triggered:

From: https://www.spinics.net/lists/io-uring/msg10211.html

IORING_POLL_ADD_MULTI is similar to epoll's edge-triggered mode,

Also the new (maybe still not yet active) IORING_POLL_ADD_LEVEL flag means currently it is edge?

Could you please help me understand? I think maybe I have things backward?

Thanks! Mansour.

sxstd001 commented 10 months ago

I tested it, and the effects are the same. io_uring_prep_poll_add == io_uring_prep_poll_multishot == epoll Level Triggered;

isilence commented 9 months ago

In short, they're rather level-triggered.

io_uring_prep_poll_add is purely level-triggered. Similarly, when you just queued a io_uring_prep_poll_multishot it's also level-triggered, i.e. if there's data/event/etc. at the time you submit the request it'll post a completion. However, for all subsequent completions of a multishot poll it kind of resembles the edge mode because it'll be posting completions only in reaction to new events/data arriving.