[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [RFC v2 2/8] virtio: memory cache for packed ring
From: |
Wei Xu |
Subject: |
Re: [Qemu-devel] [RFC v2 2/8] virtio: memory cache for packed ring |
Date: |
Tue, 19 Jun 2018 15:39:32 +0800 |
User-agent: |
Mutt/1.5.24 (2015-08-30) |
On Wed, Jun 06, 2018 at 10:53:07AM +0800, Jason Wang wrote:
>
>
> On 2018年06月06日 03:07, address@hidden wrote:
> >From: Wei Xu <address@hidden>
> >
> >Mostly reuse memory cache with 1.0 except for the offset calculation.
> >
> >Signed-off-by: Wei Xu <address@hidden>
> >---
> > hw/virtio/virtio.c | 29 ++++++++++++++++++++---------
> > 1 file changed, 20 insertions(+), 9 deletions(-)
> >
> >diff --git a/hw/virtio/virtio.c b/hw/virtio/virtio.c
> >index e192a9a..f6c0689 100644
> >--- a/hw/virtio/virtio.c
> >+++ b/hw/virtio/virtio.c
> >@@ -150,11 +150,8 @@ static void virtio_init_region_cache(VirtIODevice
> >*vdev, int n)
> > VRingMemoryRegionCaches *old = vq->vring.caches;
> > VRingMemoryRegionCaches *new;
> > hwaddr addr, size;
> >- int event_size;
> > int64_t len;
> >- event_size = virtio_vdev_has_feature(vq->vdev, VIRTIO_RING_F_EVENT_IDX)
> >? 2 : 0;
> >-
> > addr = vq->vring.desc;
> > if (!addr) {
> > return;
> >@@ -168,7 +165,7 @@ static void virtio_init_region_cache(VirtIODevice *vdev,
> >int n)
> > goto err_desc;
> > }
> >- size = virtio_queue_get_used_size(vdev, n) + event_size;
> >+ size = virtio_queue_get_used_size(vdev, n);
> > len = address_space_cache_init(&new->used, vdev->dma_as,
> > vq->vring.used, size, true);
> > if (len < size) {
> >@@ -176,7 +173,7 @@ static void virtio_init_region_cache(VirtIODevice *vdev,
> >int n)
> > goto err_used;
> > }
> >- size = virtio_queue_get_avail_size(vdev, n) + event_size;
> >+ size = virtio_queue_get_avail_size(vdev, n);
> > len = address_space_cache_init(&new->avail, vdev->dma_as,
> > vq->vring.avail, size, false);
> > if (len < size) {
> >@@ -2320,14 +2317,28 @@ hwaddr virtio_queue_get_desc_size(VirtIODevice
> >*vdev, int n)
> > hwaddr virtio_queue_get_avail_size(VirtIODevice *vdev, int n)
>
> I would rather rename this to virtio_queue_get_driver_size().
Would this confuse 1.0 if it is shared by both? Otherwise I will take it to
next version, thanks.
Wei
>
> > {
> >- return offsetof(VRingAvail, ring) +
> >- sizeof(uint16_t) * vdev->vq[n].vring.num;
> >+ int s;
> >+
> >+ if (virtio_vdev_has_feature(vdev, VIRTIO_F_RING_PACKED)) {
> >+ return sizeof(struct VRingPackedDescEvent);
> >+ } else {
> >+ s = virtio_vdev_has_feature(vdev, VIRTIO_RING_F_EVENT_IDX) ? 2 : 0;
> >+ return offsetof(VRingAvail, ring) +
> >+ sizeof(uint16_t) * vdev->vq[n].vring.num + s;
> >+ }
> > }
> > hwaddr virtio_queue_get_used_size(VirtIODevice *vdev, int n)
>
> virtio_queue_get_device_size().
>
> Thanks
>
> > {
> >- return offsetof(VRingUsed, ring) +
> >- sizeof(VRingUsedElem) * vdev->vq[n].vring.num;
> >+ int s;
> >+
> >+ if (virtio_vdev_has_feature(vdev, VIRTIO_F_RING_PACKED)) {
> >+ return sizeof(struct VRingPackedDescEvent);
> >+ } else {
> >+ s = virtio_vdev_has_feature(vdev, VIRTIO_RING_F_EVENT_IDX) ? 2 : 0;
> >+ return offsetof(VRingUsed, ring) +
> >+ sizeof(VRingUsedElem) * vdev->vq[n].vring.num + s;
> >+ }
> > }
> > uint16_t virtio_queue_get_last_avail_idx(VirtIODevice *vdev, int n)
>
- [Qemu-devel] [RFC v2 0/8] packed ring virtio-net userspace backend support, wexu, 2018/06/05
- [Qemu-devel] [RFC v2 1/8] virtio: feature bit, data structure, init for 1.1, wexu, 2018/06/05
- [Qemu-devel] [RFC v2 2/8] virtio: memory cache for packed ring, wexu, 2018/06/05
- [Qemu-devel] [RFC v2 3/8] virtio: empty check and desc read for packed ring, wexu, 2018/06/05
- [Qemu-devel] [RFC v2 4/8] virtio: get avail bytes check for packed ring, wexu, 2018/06/05
- [Qemu-devel] [RFC v2 5/8] virtio: queue pop for packed ring, wexu, 2018/06/05