[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL 12/14] virtio: disable virtqueue notifications during
From: |
Stefan Hajnoczi |
Subject: |
[Qemu-devel] [PULL 12/14] virtio: disable virtqueue notifications during polling |
Date: |
Wed, 4 Jan 2017 13:34:12 +0000 |
This is a performance optimization to eliminate vmexits during polling.
It also avoids spurious ioeventfd processing after polling ends.
Signed-off-by: Stefan Hajnoczi <address@hidden>
Reviewed-by: Paolo Bonzini <address@hidden>
Message-id: address@hidden
Signed-off-by: Stefan Hajnoczi <address@hidden>
---
hw/virtio/virtio.c | 18 ++++++++++++++++++
1 file changed, 18 insertions(+)
diff --git a/hw/virtio/virtio.c b/hw/virtio/virtio.c
index 79b5c36..d40711a 100644
--- a/hw/virtio/virtio.c
+++ b/hw/virtio/virtio.c
@@ -2053,6 +2053,13 @@ static void
virtio_queue_host_notifier_aio_read(EventNotifier *n)
}
}
+static void virtio_queue_host_notifier_aio_poll_begin(EventNotifier *n)
+{
+ VirtQueue *vq = container_of(n, VirtQueue, host_notifier);
+
+ virtio_queue_set_notification(vq, 0);
+}
+
static bool virtio_queue_host_notifier_aio_poll(void *opaque)
{
EventNotifier *n = opaque;
@@ -2066,6 +2073,14 @@ static bool virtio_queue_host_notifier_aio_poll(void
*opaque)
return true;
}
+static void virtio_queue_host_notifier_aio_poll_end(EventNotifier *n)
+{
+ VirtQueue *vq = container_of(n, VirtQueue, host_notifier);
+
+ /* Caller polls once more after this to catch requests that race with us */
+ virtio_queue_set_notification(vq, 1);
+}
+
void virtio_queue_aio_set_host_notifier_handler(VirtQueue *vq, AioContext *ctx,
VirtIOHandleOutput
handle_output)
{
@@ -2074,6 +2089,9 @@ void virtio_queue_aio_set_host_notifier_handler(VirtQueue
*vq, AioContext *ctx,
aio_set_event_notifier(ctx, &vq->host_notifier, true,
virtio_queue_host_notifier_aio_read,
virtio_queue_host_notifier_aio_poll);
+ aio_set_event_notifier_poll(ctx, &vq->host_notifier,
+ virtio_queue_host_notifier_aio_poll_begin,
+ virtio_queue_host_notifier_aio_poll_end);
} else {
aio_set_event_notifier(ctx, &vq->host_notifier, true, NULL, NULL);
/* Test and clear notifier before after disabling event,
--
2.9.3
- [Qemu-devel] [PULL 02/14] aio: add flag to skip fds to aio_dispatch(), (continued)
- [Qemu-devel] [PULL 02/14] aio: add flag to skip fds to aio_dispatch(), Stefan Hajnoczi, 2017/01/04
- [Qemu-devel] [PULL 01/14] HACKING: document #include order, Stefan Hajnoczi, 2017/01/04
- [Qemu-devel] [PULL 04/14] aio: add polling mode to AioContext, Stefan Hajnoczi, 2017/01/04
- [Qemu-devel] [PULL 06/14] linux-aio: poll ring for completions, Stefan Hajnoczi, 2017/01/04
- [Qemu-devel] [PULL 07/14] iothread: add polling parameters, Stefan Hajnoczi, 2017/01/04
- [Qemu-devel] [PULL 05/14] virtio: poll virtqueues for new buffers, Stefan Hajnoczi, 2017/01/04
- [Qemu-devel] [PULL 03/14] aio: add AioPollFn and io_poll() interface, Stefan Hajnoczi, 2017/01/04
- [Qemu-devel] [PULL 08/14] virtio-blk: suppress virtqueue kick during processing, Stefan Hajnoczi, 2017/01/04
- [Qemu-devel] [PULL 09/14] virtio-scsi: suppress virtqueue kick during processing, Stefan Hajnoczi, 2017/01/04
- [Qemu-devel] [PULL 10/14] virtio: turn vq->notification into a nested counter, Stefan Hajnoczi, 2017/01/04
- [Qemu-devel] [PULL 12/14] virtio: disable virtqueue notifications during polling,
Stefan Hajnoczi <=
- [Qemu-devel] [PULL 11/14] aio: add .io_poll_begin/end() callbacks, Stefan Hajnoczi, 2017/01/04
- [Qemu-devel] [PULL 13/14] aio: self-tune polling time, Stefan Hajnoczi, 2017/01/04
- [Qemu-devel] [PULL 14/14] iothread: add poll-grow and poll-shrink parameters, Stefan Hajnoczi, 2017/01/04
- Re: [Qemu-devel] [PULL 00/14] Block patches, Peter Maydell, 2017/01/05