[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [RFC 2/3] virtio: poll virtqueues for new buffers
From: |
Stefan Hajnoczi |
Subject: |
[Qemu-devel] [RFC 2/3] virtio: poll virtqueues for new buffers |
Date: |
Wed, 9 Nov 2016 17:13:21 +0000 |
Add an AioContext poll handler to detect new virtqueue buffers without
waiting for a guest->host notification.
Signed-off-by: Stefan Hajnoczi <address@hidden>
---
hw/virtio/virtio.c | 19 +++++++++++++++++++
1 file changed, 19 insertions(+)
diff --git a/hw/virtio/virtio.c b/hw/virtio/virtio.c
index bcbcfe0..b191e01 100644
--- a/hw/virtio/virtio.c
+++ b/hw/virtio/virtio.c
@@ -2026,15 +2026,34 @@ static void
virtio_queue_host_notifier_aio_read(EventNotifier *n)
}
}
+static bool virtio_queue_aio_poll(void *opaque)
+{
+ VirtQueue *vq = opaque;
+
+ return !virtio_queue_empty(vq);
+}
+
+static void virtio_queue_aio_poll_handler(void *opaque)
+{
+ VirtQueue *vq = opaque;
+
+ virtio_queue_notify_aio_vq(vq);
+}
+
void virtio_queue_aio_set_host_notifier_handler(VirtQueue *vq, AioContext *ctx,
VirtIOHandleOutput
handle_output)
{
if (handle_output) {
vq->handle_aio_output = handle_output;
+ aio_set_poll_handler(ctx,
+ virtio_queue_aio_poll,
+ virtio_queue_aio_poll_handler,
+ vq);
aio_set_event_notifier(ctx, &vq->host_notifier, true,
virtio_queue_host_notifier_aio_read);
} else {
aio_set_event_notifier(ctx, &vq->host_notifier, true, NULL);
+ aio_set_poll_handler(ctx, virtio_queue_aio_poll, NULL, vq);
/* Test and clear notifier before after disabling event,
* in case poll callback didn't have time to run. */
virtio_queue_host_notifier_aio_read(&vq->host_notifier);
--
2.7.4
- [Qemu-devel] [RFC 0/3] aio: experimental virtio-blk polling mode, Stefan Hajnoczi, 2016/11/09
- [Qemu-devel] [RFC 3/3] linux-aio: poll ring for completions, Stefan Hajnoczi, 2016/11/09
- [Qemu-devel] [RFC 2/3] virtio: poll virtqueues for new buffers,
Stefan Hajnoczi <=
- Re: [Qemu-devel] [RFC 0/3] aio: experimental virtio-blk polling mode, Karl Rister, 2016/11/11
- Re: [Qemu-devel] [RFC 0/3] aio: experimental virtio-blk polling mode, Stefan Hajnoczi, 2016/11/14
- Re: [Qemu-devel] [RFC 0/3] aio: experimental virtio-blk polling mode, Paolo Bonzini, 2016/11/14
- Re: [Qemu-devel] [RFC 0/3] aio: experimental virtio-blk polling mode, Stefan Hajnoczi, 2016/11/14
- Re: [Qemu-devel] [RFC 0/3] aio: experimental virtio-blk polling mode, Fam Zheng, 2016/11/14
- Re: [Qemu-devel] [RFC 0/3] aio: experimental virtio-blk polling mode, Paolo Bonzini, 2016/11/14
- Re: [Qemu-devel] [RFC 0/3] aio: experimental virtio-blk polling mode, Stefan Hajnoczi, 2016/11/15