2016-01-19 19:48 GMT+01:00 Paolo Bonzini <pbonz...@redhat.com>: > > > On 19/01/2016 17:54, Michael S. Tsirkin wrote: >> On Fri, Jan 15, 2016 at 01:41:57PM +0100, Paolo Bonzini wrote: >>> From: Vincenzo Maffione <v.maffi...@gmail.com> >>> >>> The virtqueue_pop() implementation needs to check if the avail ring >>> contains some pending buffers. To perform this check, it is not >>> always necessary to fetch the avail_idx in the VQ memory, which is >>> expensive. This patch introduces a shadow variable tracking avail_idx >>> and modifies virtio_queue_empty() to access avail_idx in physical >>> memory only when necessary. >>> >>> Signed-off-by: Vincenzo Maffione <v.maffi...@gmail.com> >>> Message-Id: >>> <b617d6459902773d9f4ab843bfaca764f5af8eda.1450218353.git.v.maffi...@gmail.com> >>> Signed-off-by: Paolo Bonzini <pbonz...@redhat.com> >> >> Is the cost due to the page walk? > > Yes, as with all the other patches. But unlike patches 7 and 10 where > we just reduce the number of walks, for patch 8 and 9 it's difficult to > beat a local cache. :) > >>> @@ -1579,6 +1595,7 @@ int virtio_load(VirtIODevice *vdev, QEMUFile *f, int >>> version_id) >>> return -1; >>> } >>> vdev->vq[i].used_idx = vring_used_idx(&vdev->vq[i]); >>> + vdev->vq[i].shadow_avail_idx = vring_avail_idx(&vdev->vq[i]); >>> } >>> } >> >> >> shadow_avail_idx also should be updated on vhost stop, > > That's virtio_queue_set_last_avail_idx, right? > > Paolo
Right. Sorry, I missed that. Vincenzo -- Vincenzo Maffione