Block patches
The following changes since commit 6bf90d4fc5027567cb704d7888f5ec792b4ed75a:
Merge tag 'pull-target-arm-20261124' of https://gitlab.com/pm215/qemu into staging (2026-11-24 07:09:41 -0800)
are available in the Git repository at:
https://gitlab.com/stefanha/qemu.git tags/block-pull-request
for you to fetch changes up to d8be4d3166ae991b28171fed3fd336632ba54d5e:
fdmon-io_uring: avoid idle event loop being accounted as IO wait (2026-11-24 15:03:00 -0500)
----------------------------------------------------------------
Pull request
Thomas & Fiona's fix for io_uring IO wait accounting.
----------------------------------------------------------------
Thomas Lamprecht (1):
fdmon-io_uring: avoid idle event loop being accounted as IO wait
meson.build | 2 ++ include/qemu/aio.h | 15 ++++++++++++++ util/fdmon-io_uring.c | 46 ++++++++++++++++++++++++++++++++++++++++--- 3 files changed, 60 insertions(+), 3 deletions(-)
Signature · 1 line
2.56.1
[PULL for-11.2 1/1] fdmon-io_uring: avoid idle event loop being accounted as IO wait
From: Thomas Lamprecht <[email protected]>
Since QEMU 10.2, iothreads use io_uring for file descriptor monitoring when available at build time. The blocking wait in io_uring_enter() gets accounted as IO wait by the kernel even when only poll or timeout SQEs are present. The result is nearly 100% IO pressure in PSI on idle VMs.
The Linux kernel also has a bug conflating reservations for task references and real in-flight requests [0], so the issue could occur even if no poll or timeout SQE was present.
The io_uring_set_iowait() function is available since liburing 2.10, so create a stub when it's not available and accept that IOWAIT accounting includes POLL_ADD and TIMEOUT ops on older hosts.
Track the number of in-flight requests that represent real block-layer IO (currently, anything submitted via aio_add_sqe() is) in a per-AioContext counter, and disable iowait accounting when the count is zero.
SQ-ring composition alone is not a usable signal here: poll SQEs get re-armed by process_cqe_aio_handler() on every fd-event cycle, so workloads with constant fd wakeups (observed with librbd) always leave a non-timeout SQE in the ring even when the guest is idle. Block drivers that do not go through aio_add_sqe() (e.g. librbd, libaio, thread-pool) never increment the counter and thus always get the flag passed, which matches the semantic intent: their iothreads block on completion notifications from other threads, not on IO they issued themselves.
The iowait_accounting_reqs counter added to the AioContext struct must be accessed with atomics, since a vCPU thread can reach fdmon_io_uring_wait() via aio_poll() (for example via virtio_scsi_dataplane_stop()).
[0]: https://lore.kernel.org/io-uring/[email protected]/T/
Message-id: [email protected]
--- meson.build | 2 ++ include/qemu/aio.h | 15 ++++++++++++++ util/fdmon-io_uring.c | 46 ++++++++++++++++++++++++++++++++++++++++--- 3 files changed, 60 insertions(+), 3 deletions(-)
meson.build +2 -0
@@ -2717,6 +2717,8 @@ if linux_io_uring.found() cc.has_header_symbol('liburing.h', 'io_uring_prep_writev2')) config_host_data.set('HAVE_IO_URING_CQ_HAS_OVERFLOW', cc.has_header_symbol('liburing.h', 'io_uring_cq_has_overflow')) + config_host_data.set('HAVE_IO_URING_SET_IOWAIT', + cc.has_header_symbol('liburing.h', 'io_uring_set_iowait')) endif config_host_data.set('HAVE_TCP_KEEPCNT', cc.has_header_symbol('netinet/tcp.h', 'TCP_KEEPCNT') or
include/qemu/aio.h +15 -0
@@ -55,6 +55,12 @@ struct CqeHandler {/* This field is filled in before ->cb() is called */ struct io_uring_cqe cqe; + +/* +* Whether the in-flight request should count towards IO wait. +* Private to the fdmon layer; must not be touched outside of it. +*/ +bool iowait_accounting; }; typedef QSIMPLEQ_HEAD(, CqeHandler) CqeHandlerSimpleQ;
@@ -295,6 +301,12 @@ struct AioContext {/* Pending callback state for cqe handlers */ CqeHandlerSimpleQ cqe_handler_ready_list; + +/* +* Number of in-flight requests that should count towards IO wait. +* Must be accessed using atomics. +*/ +unsigned int iowait_accounting_reqs;#endif /* CONFIG_LINUX_IO_URING */ /* TimerLists for calling timers - one per clock type. Has its own
@@ -843,6 +855,9 @@ static inline bool aio_has_io_uring(void)* as soon as @prep_sqe() returns or it may take until the next event loop * iteration. * +* The fdmon's IO wait accounting logic currently assumes that the request is +* not multishot. +* * When the AioContext is destroyed, pending sqes are ignored and their * CqeHandlers are not invoked. *
util/fdmon-io_uring.c +43 -3
91 lines not on this page · raw message
Signature · 1 line
2.56.1
Richard Henderson
AppliedQuoted 8 lines · Stefan Hajnoczi
The following changes since commit
6bf90d4fc5027567cb704d7888f5ec792b4ed75a:Merge tag 'pull-target-arm-20261124' ofhttps://gitlab.com/pm215/qemu into staging (2026-11-24 07:09:41 -0800)are available in the Git repository at:
https://gitlab.com/stefanha/qemu.git tags/block-pull-request
Quoted 8 lines
for you to fetch changes up to
d8be4d3166ae991b28171fed3fd336632ba54d5e:fdmon-io_uring: avoid idle event loop being accounted as IO wait (2026-11-24 15:03:00 -0500)
----------------------------------------------------------------
Pull requestThomas & Fiona's fix for
io_uringIO wait accounting.
Applied, thanks.
r~
Richard Henderson
AppliedQuoted 8 lines · Stefan Hajnoczi
The following changes since commit
6bf90d4fc5027567cb704d7888f5ec792b4ed75a:Merge tag 'pull-target-arm-20261124' ofhttps://gitlab.com/pm215/qemu into staging (2026-11-24 07:09:41 -0800)are available in the Git repository at:
https://gitlab.com/stefanha/qemu.git tags/block-pull-request
Quoted 8 lines
for you to fetch changes up to
d8be4d3166ae991b28171fed3fd336632ba54d5e:fdmon-io_uring: avoid idle event loop being accounted as IO wait (2026-11-24 15:03:00 -0500)
----------------------------------------------------------------
Pull requestThomas & Fiona's fix for
io_uringIO wait accounting.
Applied, thanks.
r~