virtio-balloon: prioritize most recently used memory when inflating the balloon #2085
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
When inflating the memory balloon to decrease host memory usage, the existing code is not effective in finding previously-used memory areas (which usually are memory ranges that have been unmapped by the user program, or pages that have been evicted from the page cache, and correspond to memory ranges that have actually been populated in the host machine); as a result, balloon inflation does not allow the host hypervisor to significantly decrease its memory usage.
This change fixes the above issue by:
Using a buddy memory allocator as physical memory heap brings the following improvements:
The typical overhead of the buddy allocator is around 0.1%, i.e. 99.9% of the physical memory available for a VM can be used for kernel and user program allocations.