From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:33057) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZXKGo-0008W0-KZ for qemu-devel@nongnu.org; Wed, 02 Sep 2015 22:28:59 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZXKGl-0006aF-E3 for qemu-devel@nongnu.org; Wed, 02 Sep 2015 22:28:58 -0400 Received: from e06smtp15.uk.ibm.com ([195.75.94.111]:37813) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZXKGl-0006a2-4o for qemu-devel@nongnu.org; Wed, 02 Sep 2015 22:28:55 -0400 Received: from /spool/local by e06smtp15.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Wed, 2 Sep 2015 16:57:56 +0100 Received: from d06av11.portsmouth.uk.ibm.com (d06av11.portsmouth.uk.ibm.com [9.149.37.252]) by b06cxnps4075.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id t82FovXm38338790 for ; Wed, 2 Sep 2015 15:50:57 GMT Received: from d06av11.portsmouth.uk.ibm.com (localhost [127.0.0.1]) by d06av11.portsmouth.uk.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id t82FoulP004701 for ; Wed, 2 Sep 2015 09:50:57 -0600 Date: Wed, 2 Sep 2015 17:50:55 +0200 From: Cornelia Huck Message-ID: <20150902175055.78b06a5b.cornelia.huck@de.ibm.com> In-Reply-To: <1441207429-23221-1-git-send-email-pmorel@linux.vnet.ibm.com> References: <1441207429-23221-1-git-send-email-pmorel@linux.vnet.ibm.com> Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH] virtio: right size for virtio_queue_get_avail_size List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Pierre Morel Cc: mst@redhat.com, qemu-devel@nongnu.org, stefanha@redhat.com, gkurz@linux.vnet.ibm.com On Wed, 2 Sep 2015 17:23:49 +0200 Pierre Morel wrote: > Being working on dataplane I notice something strange: > > virtio_queue_get_avail_size() used a 64bit size index > for the calculation of the available ring size. > > It is quite strange but it did work with the old calculation > of the avail ring, at most with performance penalty, > and I wonder where I missed something. > > This patch let use a 16bit size as defined in virtio_ring.h > > Signed-off-by: Pierre Morel > --- > 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 788b556..5c856eb 100644 > --- a/hw/virtio/virtio.c > +++ b/hw/virtio/virtio.c > @@ -1460,7 +1460,7 @@ hwaddr virtio_queue_get_desc_size(VirtIODevice *vdev, int n) > hwaddr virtio_queue_get_avail_size(VirtIODevice *vdev, int n) > { > return offsetof(VRingAvail, ring) + > - sizeof(uint64_t) * vdev->vq[n].vring.num; > + sizeof(uint16_t) * vdev->vq[n].vring.num; > } > > hwaddr virtio_queue_get_used_size(VirtIODevice *vdev, int n) I'm wondering about the semantics of the _size() functions. Naively I would expect (size of buffer) * (number of buffers). I think at least vhost expects the {used,avail} indices in there as well? The s390-virtio code seems not to expect the indices to be contained in the size, though...