]> git.proxmox.com Git - mirror_qemu.git/commit - hw/scsi/virtio-scsi.c
virtio: move allocation to virtqueue_pop/vring_pop
authorPaolo Bonzini <pbonzini@redhat.com>
Thu, 4 Feb 2016 14:26:51 +0000 (16:26 +0200)
committerMichael S. Tsirkin <mst@redhat.com>
Sat, 6 Feb 2016 18:39:07 +0000 (20:39 +0200)
commit51b19ebe4320f3dcd93cea71235c1219318ddfd2
treea242566284e7efb7a45e151481b0433a3ffe39b5
parent6aa46d8ff1ee7e9ca0c4a54d75c74108bee22124
virtio: move allocation to virtqueue_pop/vring_pop

The return code of virtqueue_pop/vring_pop is unused except to check for
errors or 0.  We can thus easily move allocation inside the functions
and just return a pointer to the VirtQueueElement.

The advantage is that we will be able to allocate only the space that
is needed for the actual size of the s/g list instead of the full
VIRTQUEUE_MAX_SIZE items.  Currently VirtQueueElement takes about 48K
of memory, and this kind of allocation puts a lot of stress on malloc.
By cutting the size by two or three orders of magnitude, malloc can
use much more efficient algorithms.

The patch is pretty large, but changes to each device are testable
more or less independently.  Splitting it would mostly add churn.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Reviewed-by: Cornelia Huck <cornelia.huck@de.ibm.com>
22 files changed:
hw/9pfs/9p.c
hw/9pfs/virtio-9p-device.c
hw/9pfs/virtio-9p.h
hw/block/dataplane/virtio-blk.c
hw/block/virtio-blk.c
hw/char/virtio-serial-bus.c
hw/display/virtio-gpu.c
hw/input/virtio-input.c
hw/net/virtio-net.c
hw/scsi/virtio-scsi-dataplane.c
hw/scsi/virtio-scsi.c
hw/virtio/dataplane/vring.c
hw/virtio/virtio-balloon.c
hw/virtio/virtio-rng.c
hw/virtio/virtio.c
include/hw/virtio/dataplane/vring.h
include/hw/virtio/virtio-balloon.h
include/hw/virtio/virtio-blk.h
include/hw/virtio/virtio-net.h
include/hw/virtio/virtio-scsi.h
include/hw/virtio/virtio-serial.h
include/hw/virtio/virtio.h