From: Sasha Levin Subject: [PATCH 1/4] kvm tools: Support VIRTIO_RING_F_EVENT_IDX Date: Thu, 17 Nov 2011 15:04:37 +0200 Message-ID: <1321535080-4840-1-git-send-email-levinsasha928@gmail.com> Cc: kvm@vger.kernel.org, mingo@elte.hu, asias.hejun@gmail.com, gorcunov@gmail.com, Sasha Levin To: penberg@kernel.org Return-path: Received: from mail-ww0-f42.google.com ([74.125.82.42]:64250 "EHLO mail-ww0-f42.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753520Ab1KQNHE (ORCPT ); Thu, 17 Nov 2011 08:07:04 -0500 Received: by wwe3 with SMTP id 3so3222892wwe.1 for ; Thu, 17 Nov 2011 05:07:02 -0800 (PST) Sender: kvm-owner@vger.kernel.org List-ID: Support the event index feature in the virtio spec. The results are less notifications between the guest and host, and in result faster operation of the virt queues. Signed-off-by: Sasha Levin --- tools/kvm/include/kvm/virtio.h | 7 +++++++ 1 files changed, 7 insertions(+), 0 deletions(-) diff --git a/tools/kvm/include/kvm/virtio.h b/tools/kvm/include/kvm/virtio.h index c6c380d..cd24285 100644 --- a/tools/kvm/include/kvm/virtio.h +++ b/tools/kvm/include/kvm/virtio.h @@ -38,6 +38,8 @@ static inline bool virt_queue__available(struct virt_queue *vq) { if (!vq->vring.avail) return 0; + + vring_avail_event(&vq->vring) = vq->last_avail_idx; return vq->vring.avail->idx != vq->last_avail_idx; } @@ -51,6 +53,11 @@ static inline void *guest_pfn_to_host(struct kvm *kvm, u32 pfn) return guest_flat_to_host(kvm, (unsigned long)pfn << VIRTIO_PCI_QUEUE_ADDR_SHIFT); } +static inline int virtio_queue__should_signal(struct virt_queue *vq) +{ + return vring_used_event(&vq->vring) <= vq->vring.used->idx; +} + struct vring_used_elem *virt_queue__set_used_elem(struct virt_queue *queue, u32 head, u32 len); u16 virt_queue__get_iov(struct virt_queue *queue, struct iovec iov[], u16 *out, u16 *in, struct kvm *kvm); -- 1.7.8.rc1