xen-block: avoid repeated memory allocation
commitc6025bd197d0dbcc5067553fd12538d8b29383c2
authorTim Smith <tim.smith@citrix.com>
Wed, 12 Dec 2018 11:16:26 +0000 (12 11:16 +0000)
committerAnthony PERARD <anthony.perard@citrix.com>
Mon, 14 Jan 2019 13:45:40 +0000 (14 13:45 +0000)
treeb4b04c95b9c75162cdf60dbcda51c9ca7563071b
parentbfd0d6366043935990a69ed4d8183f88772256ee
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>
Acked-by: Anthony PERARD <anthony.perard@citrix.com>
Signed-off-by: Anthony PERARD <anthony.perard@citrix.com>
hw/block/dataplane/xen-block.c