On Sun, 31 Jan 2016 11:28:58 +0100 Paolo Bonzini <pbonz...@redhat.com> wrote:
> 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 <pbonz...@redhat.com> > --- > v1->v2: add assertions on sz [Conny] > > hw/9pfs/9p.c | 2 +- > hw/9pfs/virtio-9p-device.c | 17 ++++---- > hw/9pfs/virtio-9p.h | 2 +- > hw/block/dataplane/virtio-blk.c | 11 +++-- > hw/block/virtio-blk.c | 15 +++---- > hw/char/virtio-serial-bus.c | 80 > +++++++++++++++++++++++-------------- > hw/display/virtio-gpu.c | 25 +++++++----- > hw/input/virtio-input.c | 24 +++++++---- > hw/net/virtio-net.c | 69 ++++++++++++++++++++------------ > hw/scsi/virtio-scsi-dataplane.c | 15 +++---- > hw/scsi/virtio-scsi.c | 18 ++++----- > hw/virtio/dataplane/vring.c | 18 +++++---- > hw/virtio/virtio-balloon.c | 22 ++++++---- > hw/virtio/virtio-rng.c | 10 +++-- > hw/virtio/virtio.c | 12 ++++-- > include/hw/virtio/dataplane/vring.h | 2 +- > include/hw/virtio/virtio-balloon.h | 2 +- > include/hw/virtio/virtio-blk.h | 3 +- > include/hw/virtio/virtio-net.h | 2 +- > include/hw/virtio/virtio-scsi.h | 2 +- > include/hw/virtio/virtio-serial.h | 2 +- > include/hw/virtio/virtio.h | 2 +- > 22 files changed, 212 insertions(+), 143 deletions(-) Reviewed-by: Cornelia Huck <cornelia.h...@de.ibm.com>