Dear all, This is v2 of the RFC patch series to refine aio_poll adaptive polling logic for better CPU efficiency.
v1: https://lore.kernel.org/qemu-devel/[email protected]/ Changes in v2: - Patch 2/3: Changed default POLL_WEIGHT_SHIFT from 2 to 3 based on extensive testing. Updated commit message with detailed performance comparison showing weight=3 provides better balance between throughput and CPU savings - Patch 3/3: Added proper initialization of poll-weight, poll-grow, and poll-shrink defaults in iothread.c This patch series refines the aio_poll adaptive polling logic to reduce unnecessary busy-waiting and improve CPU efficiency. The first patch prevents redundant polling time calculation when polling is disabled. The second patch enhances the adaptive polling mechanism by dynamically adjusting the iothread's polling duration based on event intervals measured by individual AioHandlers. The third patch introduces a new 'poll-weight' parameter for runtime control over how much the current interval influences the next polling duration. We evaluated the patches on s390x hosts with different configurations: Initial testing (Fedora 42): Using a single guest with 16 virtio block devices backed by FCP multipath devices, I/O scheduler set to 'none'. Across four FIO workload patterns (sequential R/W, random R/W), averaged over numjobs 1, 4, 8, and 16: - Throughput: -3% to -8% (one iothread), -2% to -5% (two iothreads) - CPU usage: -10% to -25% (one iothread), -7% to -12% (two iothreads) Additional validation (RHEL 10.1 GA + QEMU 10.0.0): Comparing baseline vs poll-weight=2/3 with FCP and FICON storage, using 1 and 8 iothreads, averaged over numjobs 1, 4, and 8: Summary of results (% change vs baseline): - Throughput avg: -2.2% (weight=3), -2.4% (weight=2) - CPU consumption avg: -9.4% (weight=3), -10.9% (weight=2) Weight=3 was selected as default for providing slightly better throughput (-2.2% vs -2.4%) while maintaining substantial CPU savings (-9.4%). Best regards, Jaehoon Kim Jaehoon Kim (3): aio-poll: avoid unnecessary polling time computation aio-poll: refine iothread polling using weighted handler intervals qapi/iothread: introduce poll-weight parameter for aio-poll include/qemu/aio.h | 8 +- include/system/iothread.h | 1 + iothread.c | 34 ++++++- monitor/hmp-cmds.c | 1 + qapi/misc.json | 7 ++ qapi/qom.json | 8 +- qemu-options.hx | 7 +- tests/unit/test-nested-aio-poll.c | 2 +- util/aio-posix.c | 141 ++++++++++++++++++++---------- util/aio-win32.c | 3 +- util/async.c | 2 + 11 files changed, 161 insertions(+), 53 deletions(-) -- 2.50.1
