Am 05.11.2025 um 16:06 hat Richard Henderson geschrieben:
> On 11/4/25 18:53, Kevin Wolf wrote:
> > From: Stefan Hajnoczi <[email protected]>
> >
> > AioContext's glib integration only supports ppoll(2) file descriptor
> > monitoring. epoll(7) and io_uring(7) disable themselves and switch back
> > to ppoll(2) when the glib event loop is used. The main loop thread
> > cannot use epoll(7) or io_uring(7) because it always uses the glib event
> > loop.
> >
> > Future QEMU features may require io_uring(7). One example is uring_cmd
> > support in FUSE exports. Each feature could create its own io_uring(7)
> > context and integrate it into the event loop, but this is inefficient
> > due to extra syscalls. It would be more efficient to reuse the
> > AioContext's existing fdmon-io_uring.c io_uring(7) context because
> > fdmon-io_uring.c will already be active on systems where Linux io_uring
> > is available.
> >
> > In order to keep fdmon-io_uring.c's AioContext operational even when the
> > glib event loop is used, extend FDMonOps with an API similar to
> > GSourceFuncs so that file descriptor monitoring can integrate into the
> > glib event loop.
> >
> > A quick summary of the GSourceFuncs API:
> > - prepare() is called each event loop iteration before waiting for file
> > descriptors and timers.
> > - check() is called to determine whether events are ready to be
> > dispatched after waiting.
> > - dispatch() is called to process events.
> >
> > More details here: https://docs.gtk.org/glib/struct.SourceFuncs.html
> >
> > Move the ppoll(2)-specific code from aio-posix.c into fdmon-poll.c and
> > also implement epoll(7)- and io_uring(7)-specific file descriptor
> > monitoring code for glib event loops.
> >
> > Note that it's still faster to use aio_poll() rather than the glib event
> > loop since glib waits for file descriptor activity with ppoll(2) and
> > does not support adaptive polling. But at least epoll(7) and io_uring(7)
> > now work in glib event loops.
> >
> > Splitting this into multiple commits without temporarily breaking
> > AioContext proved difficult so this commit makes all the changes. The
> > next commit will remove the aio_context_use_g_source() API because it is
> > no longer needed.
> >
> > Signed-off-by: Stefan Hajnoczi <[email protected]>
> > Reviewed-by: Eric Blake <[email protected]>
> > Message-ID: <[email protected]>
> > Reviewed-by: Kevin Wolf <[email protected]>
> > Signed-off-by: Kevin Wolf <[email protected]>
> > diff --git a/util/fdmon-io_uring.c b/util/fdmon-io_uring.c
> > index 3d8638b0e5..0a5ec5ead6 100644
> > --- a/util/fdmon-io_uring.c
> > +++ b/util/fdmon-io_uring.c
> > @@ -262,6 +262,11 @@ static int process_cq_ring(AioContext *ctx,
> > AioHandlerList *ready_list)
> > unsigned num_ready = 0;
> > unsigned head;
> > + /* If the CQ overflowed then fetch CQEs with a syscall */
> > + if (io_uring_cq_has_overflow(ring)) {
> > + io_uring_get_events(ring);
> > + }
>
>
> https://gitlab.com/qemu-project/qemu/-/jobs/11984045425#L2379
>
>
> ../util/fdmon-io_uring.c: In function 'process_cq_ring':
> ../util/fdmon-io_uring.c:315:9: error: implicit declaration of function
> 'io_uring_cq_has_overflow' [-Werror=implicit-function-declaration]
> 315 | if (io_uring_cq_has_overflow(ring)) {
> | ^~~~~~~~~~~~~~~~~~~~~~~~
> ../util/fdmon-io_uring.c:315:9: error: nested extern declaration of
> 'io_uring_cq_has_overflow' [-Werror=nested-externs]
> ../util/fdmon-io_uring.c:316:9: error: implicit declaration of function
> 'io_uring_get_events'; did you mean 'io_uring_get_sqe'?
> [-Werror=implicit-function-declaration]
> 316 | io_uring_get_events(ring);
> | ^~~~~~~~~~~~~~~~~~~
> | io_uring_get_sqe
> ../util/fdmon-io_uring.c:316:9: error: nested extern declaration of
> 'io_uring_get_events' [-Werror=nested-externs]
Thanks, I sent a v2 pull request.
Please reply to all in the future instead of only to qemu-devel. I
missed this reply until today, which due to the hard freeze meant a
somewhat longer working day for me than I had hoped for.
Kevin