Skip to contentSkip to conversation

qemu:virtio: Allow guest to defer VIRTIO_F_NOTIFY_ON_EMPTY

PATCH Applied Alex Williamson 2 participants 2 messages Mar 19, 2009 – Mar 20, 2009 KVM

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 qemu:virtio: Allow guest to defer VIRTIO_F_NOTIFY_ON_EMPTY

There may be cases where the guest does not want the avail queue interrupt, even when it's empty. For the virtio-net case, the guest may use a different buffering scheme or decide polling for used buffers is more efficient. This can be accomplished by simply checking for whether the guest has acknowledged the existing notify on empty flag.

---

 hw/virtio.c |    7 ++++---
 1 files changed, 4 insertions(+), 3 deletions(-)
hw/virtio.c +4 -3
index b94ab0f..08ea16d 100644
@@ -726,9 +726,10 @@ VirtQueue *virtio_add_queue(VirtIODevice *vdev, int queue_size,
 
 void virtio_notify(VirtIODevice *vdev, VirtQueue *vq)
 {
-    /* Always notify when queue is empty */
-    if ((vq->inuse || vring_avail_idx(vq) != vq->last_avail_idx) &&
-        (vring_avail_flags(vq) & VRING_AVAIL_F_NO_INTERRUPT))
+    /* Always notify when queue is empty (when feature acknowledge) */
+    if ((vring_avail_flags(vq) & VRING_AVAIL_F_NO_INTERRUPT) &&
+        (!(vdev->features & (1 << VIRTIO_F_NOTIFY_ON_EMPTY)) ||
+         (vq->inuse || vring_avail_idx(vq) != vq->last_avail_idx)))
         return;
 
     vdev->isr |= 0x01;
#1 lore raw
Quoted 9 lines · Alex Williamson

There may be cases where the guest does not want the avail queue interrupt, even when it's empty. For the virtio-net case, the guest may use a different buffering scheme or decide polling for used buffers is more efficient. This can be accomplished by simply checking for whether the guest has acknowledged the existing notify on empty flag.

Applied to trunk and stable. Thanks.

Regards,

Anthony Liguori

Quoted 1 line