Re: [PATCH v6 09/17] virtio: add minimal support for virtqueues

Paolo Bonzini
2014-07-11T09:23:16Z

Il 11/07/2014 10:19, Andrew Jones ha scritto:
> +static struct virtqueue *vm_setup_vq(struct virtio_device *vdev,
> + unsigned index,
> + void (*callback)(struct virtqueue *vq),
> + const char *name)
> +{
> + struct virtio_mmio_device *vm_dev = to_virtio_mmio_device(vdev);
> + struct vring_virtqueue *vq;
> + void *queue;
> + unsigned num = VIRTIO_MMIO_QUEUE_NUM_MIN;
> +
> + vq = alloc(sizeof(*vq));

You can move the allocation of vq to vm_find_vqs (interleaving alloc and
alloc_aligned causes some fragmentation), allocating a single block
instead of one per vq.

Paolo

> + queue = alloc_aligned(VIRTIO_MMIO_QUEUE_SIZE_MIN, PAGE_SIZE);