summaryrefslogtreecommitdiffstats
path: root/include/block
diff options
context:
space:
mode:
authorStefan Hajnoczi2020-03-05 18:08:06 +0100
committerStefan Hajnoczi2020-03-09 17:45:16 +0100
commitd37d0e365afb6825a90d8356fc6adcc1f58f40f3 (patch)
treed5cc874fc5fffaaecd073a4f56dac12378449265 /include/block
parentaio-posix: support userspace polling of fd monitoring (diff)
downloadqemu-d37d0e365afb6825a90d8356fc6adcc1f58f40f3.tar.gz
qemu-d37d0e365afb6825a90d8356fc6adcc1f58f40f3.tar.xz
qemu-d37d0e365afb6825a90d8356fc6adcc1f58f40f3.zip
aio-posix: remove idle poll handlers to improve scalability
When there are many poll handlers it's likely that some of them are idle most of the time. Remove handlers that haven't had activity recently so that the polling loop scales better for guests with a large number of devices. This feature only takes effect for the Linux io_uring fd monitoring implementation because it is capable of combining fd monitoring with userspace polling. The other implementations can't do that and risk starving fds in favor of poll handlers, so don't try this optimization when they are in use. IOPS improves from 10k to 105k when the guest has 100 virtio-blk-pci,num-queues=32 devices and 1 virtio-blk-pci,num-queues=1 device for rw=randread,iodepth=1,bs=4k,ioengine=libaio on NVMe. [Clarified aio_poll_handlers locking discipline explanation in comment after discussion with Paolo Bonzini <pbonzini@redhat.com>. --Stefan] Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com> Link: https://lore.kernel.org/r/20200305170806.1313245-8-stefanha@redhat.com Message-Id: <20200305170806.1313245-8-stefanha@redhat.com>
Diffstat (limited to 'include/block')
-rw-r--r--include/block/aio.h8
1 files changed, 8 insertions, 0 deletions
diff --git a/include/block/aio.h b/include/block/aio.h
index f07ebb76b8..cb1989105a 100644
--- a/include/block/aio.h
+++ b/include/block/aio.h
@@ -227,6 +227,14 @@ struct AioContext {
int64_t poll_grow; /* polling time growth factor */
int64_t poll_shrink; /* polling time shrink factor */
+ /*
+ * List of handlers participating in userspace polling. Protected by
+ * ctx->list_lock. Iterated and modified mostly by the event loop thread
+ * from aio_poll() with ctx->list_lock incremented. aio_set_fd_handler()
+ * only touches the list to delete nodes if ctx->list_lock's count is zero.
+ */
+ AioHandlerList poll_aio_handlers;
+
/* Are we in polling mode or monitoring file descriptors? */
bool poll_started;