]> xenbits.xensource.com Git - people/pauldu/qemu.git/commit
xen-block: avoid repeated memory allocation qom+tim
authorTim Smith <tim.smith@citrix.com>
Tue, 11 Dec 2018 17:46:41 +0000 (17:46 +0000)
committerPaul Durrant <paul.durrant@citrix.com>
Tue, 11 Dec 2018 17:57:37 +0000 (17:57 +0000)
commitb606834d2d4386b55343e16f362b245f989ddb54
treeebfd67f5398a4ba0066529c4e2d6c3d6595edda4
parent5acc702713442187b491f26ee9d687b960e0aabf
xen-block: avoid repeated memory allocation

The xen-block dataplane currently allocates memory to hold the data for
each request as that request is used, and frees it afterwards. Because
it requires page-aligned blocks, this interacts poorly with non-page-
aligned allocations and balloons the heap.

Instead, allocate the maximum possible buffer size required for the
protocol, which is BLKIF_MAX_SEGMENTS_PER_REQUEST (currently 11) pages
when the request structure is created, and keep that buffer until it is
destroyed. Since the requests are re-used via a free list, this should
actually improve memory usage.

Signed-off-by: Tim Smith <tim.smith@citrix.com>
Re-based and commit comment adjusted.

Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
---
Cc: Stefan Hajnoczi <stefanha@redhat.com>
Cc: Stefano Stabellini <sstabellini@kernel.org>
Cc: Anthony Perard <anthony.perard@citrix.com>
Cc: Kevin Wolf <kwolf@redhat.com>
Cc: Max Reitz <mreitz@redhat.com>
hw/block/dataplane/xen-block.c