From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:36257) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XizOa-0003ay-UU for qemu-devel@nongnu.org; Tue, 28 Oct 2014 01:32:45 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XizOW-0004kg-3v for qemu-devel@nongnu.org; Tue, 28 Oct 2014 01:32:40 -0400 Received: from mx1.redhat.com ([209.132.183.28]:35499) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XizOV-0004kW-SZ for qemu-devel@nongnu.org; Tue, 28 Oct 2014 01:32:36 -0400 Date: Tue, 28 Oct 2014 07:32:28 +0200 From: "Michael S. Tsirkin" Message-ID: <20141028053228.GD18689@redhat.com> References: <1414462382-24264-1-git-send-email-wu.wubin@huawei.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1414462382-24264-1-git-send-email-wu.wubin@huawei.com> Subject: Re: [Qemu-devel] [PATCH] hw/virtio/virtio.c: fix the vring_avail_event error List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Bin Wu Cc: pbonzini@redhat.com, famz@redhat.com, qemu-devel@nongnu.org On Tue, Oct 28, 2014 at 02:13:02AM +0000, Bin Wu wrote: > The event idx in virtio is an effective way to reduce the number of > interrupts and exits of the guest. When the guest puts an request > into the virtio ring, it doesn't exit immediately to inform the > backend. Instead, the guest checks the "avail" event idx to determine > the notification. > > In virtqueue_pop, when a request is poped, the current avail event > idx should be set to the number of vq->last_avail_idx. > > Signed-off-by: Bin Wu Does this fix some observable bug? Improve efficiency for some workload? > --- > hw/virtio/virtio.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/hw/virtio/virtio.c b/hw/virtio/virtio.c > index 2c236bf..013979a 100644 > --- a/hw/virtio/virtio.c > +++ b/hw/virtio/virtio.c > @@ -469,7 +469,7 @@ int virtqueue_pop(VirtQueue *vq, VirtQueueElement *elem) > > i = head = virtqueue_get_head(vq, vq->last_avail_idx++); > if (vdev->guest_features & (1 << VIRTIO_RING_F_EVENT_IDX)) { > - vring_avail_event(vq, vring_avail_idx(vq)); > + vring_avail_event(vq, vq->last_avail_idx); > } > > if (vring_desc_flags(vdev, desc_pa, i) & VRING_DESC_F_INDIRECT) { > -- > 1.7.12.4