From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:36054) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aLbKj-0001Lx-3i for qemu-devel@nongnu.org; Tue, 19 Jan 2016 13:48:49 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aLbKf-000394-UD for qemu-devel@nongnu.org; Tue, 19 Jan 2016 13:48:49 -0500 Received: from mail-wm0-x244.google.com ([2a00:1450:400c:c09::244]:35755) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aLbKf-00038u-LO for qemu-devel@nongnu.org; Tue, 19 Jan 2016 13:48:45 -0500 Received: by mail-wm0-x244.google.com with SMTP id 123so18026594wmz.2 for ; Tue, 19 Jan 2016 10:48:45 -0800 (PST) Sender: Paolo Bonzini References: <1452861718-25806-1-git-send-email-pbonzini@redhat.com> <1452861718-25806-10-git-send-email-pbonzini@redhat.com> <20160119185119-mutt-send-email-mst@redhat.com> From: Paolo Bonzini Message-ID: <569E850A.5070300@redhat.com> Date: Tue, 19 Jan 2016 19:48:42 +0100 MIME-Version: 1.0 In-Reply-To: <20160119185119-mutt-send-email-mst@redhat.com> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH 09/10] virtio: read avail_idx from VQ only when necessary List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: "Michael S. Tsirkin" Cc: qemu-devel@nongnu.org, Vincenzo Maffione 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 >> >> 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 >> Message-Id: >> Signed-off-by: Paolo Bonzini > > 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