qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Stefan Hajnoczi <stefanha@redhat.com>
To: qemu-devel@nongnu.org
Cc: borntraeger@de.ibm.com, Paolo Bonzini <pbonzini@redhat.com>,
	Karl Rister <krister@redhat.com>, Fam Zheng <famz@redhat.com>,
	Stefan Hajnoczi <stefanha@redhat.com>
Subject: [Qemu-devel] [PATCH v2 3/4] virtio: poll virtqueues for new buffers
Date: Wed, 16 Nov 2016 17:47:01 +0000	[thread overview]
Message-ID: <1479318422-10979-4-git-send-email-stefanha@redhat.com> (raw)
In-Reply-To: <1479318422-10979-1-git-send-email-stefanha@redhat.com>

Add an AioContext poll handler to detect new virtqueue buffers without
waiting for a guest->host notification.

Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
---
 hw/virtio/virtio.c | 16 +++++++++++++++-
 1 file changed, 15 insertions(+), 1 deletion(-)

diff --git a/hw/virtio/virtio.c b/hw/virtio/virtio.c
index 8985a2f..982ba85 100644
--- a/hw/virtio/virtio.c
+++ b/hw/virtio/virtio.c
@@ -2015,13 +2015,27 @@ static void virtio_queue_host_notifier_aio_read(EventNotifier *n)
     }
 }
 
+static bool virtio_queue_host_notifier_aio_poll(void *opaque)
+{
+    EventNotifier *n = opaque;
+    VirtQueue *vq = container_of(n, VirtQueue, host_notifier);
+
+    if (virtio_queue_empty(vq)) {
+        return false;
+    }
+
+    virtio_queue_notify_aio_vq(vq);
+    return true;
+}
+
 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_event_notifier(ctx, &vq->host_notifier, true,
-                               virtio_queue_host_notifier_aio_read, NULL);
+                               virtio_queue_host_notifier_aio_read,
+                               virtio_queue_host_notifier_aio_poll);
     } else {
         aio_set_event_notifier(ctx, &vq->host_notifier, true, NULL, NULL);
         /* Test and clear notifier before after disabling event,
-- 
2.7.4

  parent reply	other threads:[~2016-11-16 17:47 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-11-16 17:46 [Qemu-devel] [PATCH v2 0/4] aio: experimental virtio-blk polling mode Stefan Hajnoczi
2016-11-16 17:46 ` [Qemu-devel] [PATCH v2 1/4] aio: add AioPollFn and io_poll() interface Stefan Hajnoczi
2016-11-17  6:14   ` Fam Zheng
2016-11-16 17:47 ` [Qemu-devel] [PATCH v2 2/4] aio: add polling mode to AioContext Stefan Hajnoczi
2016-11-16 18:14   ` Paolo Bonzini
2016-11-17 11:51     ` Stefan Hajnoczi
2016-11-16 18:30   ` Paolo Bonzini
2016-11-16 17:47 ` Stefan Hajnoczi [this message]
2016-11-16 17:47 ` [Qemu-devel] [PATCH v2 4/4] linux-aio: poll ring for completions Stefan Hajnoczi
2016-11-16 18:30 ` [Qemu-devel] [PATCH v2 0/4] aio: experimental virtio-blk polling mode no-reply
2016-11-17 14:15 ` Karl Rister
2016-11-18 10:54   ` Stefan Hajnoczi

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1479318422-10979-4-git-send-email-stefanha@redhat.com \
    --to=stefanha@redhat.com \
    --cc=borntraeger@de.ibm.com \
    --cc=famz@redhat.com \
    --cc=krister@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).