mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2025-01-21 20:15:21 +00:00
9dd1698556
Currently, virtio-balloon can't work well with page size other than 4k. The virtio-balloon always works in units of 4kiB (BALLOON_PAGE_SIZE), but we can only actually discard memory in units of the host page size. We get some idea from [1] to solve this issue. What has been done in this commit: For balloon inflation: A bitmap is employed to track the memory range to be released in 4k granularity. Once it accumulates to one host page size, the corresponding page is released, and the bitmap is cleared to handle the next record. This process continues until all the memory range is managed. Memory will only be released when a consecutive set of balloon request entries from the same host page reaches the full host page size. If a balloon request entry from a different host page is encountered, the bitmap and the base host page address will be reset. Consequently, memory is released in units of the page size, ensuring efficient memory management. That's say if memory range length to be released smaller than page size or if the guest scatters requests each of whose size is smaller than page size across different host pages no memory will be released. [1] https://patchwork.kernel.org/project/qemu-devel/patch/20190214043916.22128-6-david@gibson.dropbear.id.au/ Fixes: cloud-hypervisor#5369 Signed-off-by: Jianyong Wu <jianyong.wu@arm.com>