KVM Huge Page Backed Memory
Summary
Enable KVM guests to use huge page backed memory in order to reduce memory consumption and improve performance by reducing CPU cache pressure.
Owner
- Name: Chris Wright
Current status
- Targeted release: Fedora 12
- Last updated: 2009-06-16
- Percentage of completion: 60%
TODO
- Add support to libvirt for running guests with
-mem-path
- Investigate ways to make it easier to configure the host for huge page usage
Completed
- KVM support for huge pages
Detailed Description
x86 CPUs usually address memory in 4kB pages, but they also have the ability to use huge pages (4MB on x86_63, 2MB on x86_64 and x86_32 PAE).
By using huge pages for a KVM guest's memory, less memory is used for page tables and CPU cache misses are reduced, thereby increasing performance.
Using huge pages for guest memory does have a downside, however - you can no longer swap nor balloon guest memory.
In order to use huge pages with KVM, one must do the following:
- Mount hugetlbfs to some path -
mount -t hugetlbfs hugetlbfs dev/hugepages
- Reserve some memory for huge pages -
sctl vm.nr_hugepages=516
- Pass the hugetlbfs path to
qemu-kvm
-qemu-kvm -mem-path /dev/hugepages
There is currently no way to use huge pages with a libvirt managed KVM guest.
This feature aims to improve the situation by:
- Allowing huge pages to be used with libvirt managed guests
- Possibly making it easier to configure the host for huge page usage
Benefit to Fedora
Enables Fedora KVM hosts to achieve better performance.
Scope
The most obvious work required here is in libvirt.
Making it easier to configure the host for huge page usage might involve work in other parts of the distro - e.g. settling on a default mount point for hugegtlbfs or allowing vm.nr_hugepages
to be configured somewhere.