]> www.infradead.org Git - nvme.git/commit
io_uring/epoll: add support for IORING_OP_EPOLL_WAIT
authorJens Axboe <axboe@kernel.dk>
Fri, 31 Jan 2025 21:29:09 +0000 (14:29 -0700)
committerJens Axboe <axboe@kernel.dk>
Thu, 20 Feb 2025 14:59:56 +0000 (07:59 -0700)
commit19f7e942732766aec8a51d217ab5fb4a7fe3bb0d
tree13c82a5ecf5166b08eb1b58bc120c11615af13ce
parent0fb3f5600c5e583a1cf9dbe803ba7ef89f7fbc65
io_uring/epoll: add support for IORING_OP_EPOLL_WAIT

For existing epoll event loops that can't fully convert to io_uring,
the used approach is usually to add the io_uring fd to the epoll
instance and use epoll_wait() to wait on both "legacy" and io_uring
events. While this work, it isn't optimal as:

1) epoll_wait() is pretty limited in what it can do. It does not support
   partial reaping of events, or waiting on a batch of events.

2) When an io_uring ring is added to an epoll instance, it activates the
   io_uring "I'm being polled" logic which slows things down.

Rather than use this approach, with EPOLL_WAIT support added to io_uring,
event loops can use the normal io_uring wait logic for everything, as
long as an epoll wait request has been armed with io_uring.

Note that IORING_OP_EPOLL_WAIT does NOT take a timeout value, as this
is an async request. Waiting on io_uring events in general has various
timeout parameters, and those are the ones that should be used when
waiting on any kind of request. If events are immediately available for
reaping, then This opcode will return those immediately. If none are
available, then it will post an async completion when they become
available.

cqe->res will contain either an error code (< 0 value) for a malformed
request, invalid epoll instance, etc. It will return a positive result
indicating how many events were reaped.

IORING_OP_EPOLL_WAIT requests may be canceled using the normal io_uring
cancelation infrastructure.

Signed-off-by: Jens Axboe <axboe@kernel.dk>
include/uapi/linux/io_uring.h
io_uring/epoll.c
io_uring/epoll.h
io_uring/opdef.c