• P
    virtio: move allocation to virtqueue_pop/vring_pop · 51b19ebe
    Paolo Bonzini 提交于
    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: NPaolo Bonzini <pbonzini@redhat.com>
    Reviewed-by: NMichael S. Tsirkin <mst@redhat.com>
    Signed-off-by: NMichael S. Tsirkin <mst@redhat.com>
    Reviewed-by: NCornelia Huck <cornelia.huck@de.ibm.com>
    51b19ebe
virtio.c 46.6 KB