From Fedora Project Wiki
(Created page with '= 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 cac...')
 
(update this for latest plan and move to ready for wrangler)
Line 7: Line 7:
== Owner ==
== Owner ==


* Name: [[User:Chrisw|Chris Wright]]
* Name: [[User:Chrisw|Chris Wright]], [[User:JohnCooper|John Cooper]]


== Current status ==
== Current status ==


* Targeted release: [[Releases/12|Fedora 12]]
* Targeted release: [[Releases/12|Fedora 12]]
* Last updated: 2009-06-16
* Last updated: 2009-06-22
* Percentage of completion: 60%
* Percentage of completion: 80%


=== TODO ===
=== TODO ===


# Add support to libvirt for running guests with <code>-mem-path</code>
# Add support to libvirt for running guests with <code>-mem-path /dev/hugepages</code>
# Investigate ways to make it easier to configure the host for huge page usage


=== Completed ===
=== Completed ===
Line 34: Line 33:
In order to use huge pages with KVM, one must do the following:
In order to use huge pages with KVM, one must do the following:


# Mount hugetlbfs to some path - <code>mount -t hugetlbfs hugetlbfs dev/hugepages</code>
# Mount hugetlbfs to <code>/dev/hugepages</code> - <code>mount -t hugetlbfs hugetlbfs /dev/hugepages</code>
# Reserve some memory for huge pages - <code>sctl vm.nr_hugepages=516</code>
# Reserve some memory for huge pages - <code>sctl vm.nr_hugepages=516</code>
# Pass the hugetlbfs path to <code>qemu-kvm</code> - <code>qemu-kvm -mem-path /dev/hugepages</code>
# Pass the hugetlbfs path to <code>qemu-kvm</code> - <code>qemu-kvm -mem-path /dev/hugepages</code>


There is currently no way to use huge pages with a libvirt managed KVM guest.
This feature aims to improve allow huge pages to be used with libvirt managed guests.
 
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 ==
== Benefit to Fedora ==
Line 51: Line 45:
== Scope ==
== Scope ==


The most obvious work required here is in libvirt.
Huge pages support in KVM already exists, so the remaining work is confined to 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 <code>vm.nr_hugepages</code> to be configured somewhere.
== How To Test ==


== How To Test ==
# <code>mount -t hugetlbfs hugetlbfs /dev/hugepages</code>
# Reserve some memory for huge pages - <code>sctl vm.nr_hugepages=516</code>
# Run an existing KVM guest with libvirt
# Confirm the guest has booted correctly
# Confirm the guest is using hugepages by checking <code>HugePages_Free</code> in </code>/proc/meminfo</code>


== User Experience ==
== User Experience ==
Users of KVM guests using huge page backed memory should experience reduced memory usage and improved performance.


== Dependencies ==
== Dependencies ==
None, the work is confined to libvirt.


== Contingency Plan ==
== Contingency Plan ==
None needed.


== Documentation ==
== Documentation ==
* Old [http://www.linux-kvm.com/content/get-performance-boost-backing-your-kvm-guest-hugetlbfs tutorial]


== Release Notes ==
== Release Notes ==
KVM guests running on Fedora can now take advantage of huge page backed memory to and benefit from improved performance and reduced memory usage.


== Comments and Discussion ==
== Comments and Discussion ==
Line 73: Line 81:
[[Category:Virtualization|KVM Huge Page Backed Memory]]
[[Category:Virtualization|KVM Huge Page Backed Memory]]


[[Category:FeaturePageIncomplete]]
[[Category:FeatureReadyForWrangler]]
<!-- Category:FeatureReadyForWrangler -->


[[Category:F12_Virt_Features|KVM Huge Page Backed Memory]]
[[Category:F12_Virt_Features|KVM Huge Page Backed Memory]]

Revision as of 11:45, 22 July 2009

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

Current status

  • Targeted release: Fedora 12
  • Last updated: 2009-06-22
  • Percentage of completion: 80%

TODO

  1. Add support to libvirt for running guests with -mem-path /dev/hugepages

Completed

  1. 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:

  1. Mount hugetlbfs to /dev/hugepages - mount -t hugetlbfs hugetlbfs /dev/hugepages
  2. Reserve some memory for huge pages - sctl vm.nr_hugepages=516
  3. Pass the hugetlbfs path to qemu-kvm - qemu-kvm -mem-path /dev/hugepages

This feature aims to improve allow huge pages to be used with libvirt managed guests.

Benefit to Fedora

Enables Fedora KVM hosts to achieve better performance.

Scope

Huge pages support in KVM already exists, so the remaining work is confined to libvirt.

How To Test

  1. mount -t hugetlbfs hugetlbfs /dev/hugepages
  2. Reserve some memory for huge pages - sctl vm.nr_hugepages=516
  3. Run an existing KVM guest with libvirt
  4. Confirm the guest has booted correctly
  5. Confirm the guest is using hugepages by checking HugePages_Free in /proc/meminfo

User Experience

Users of KVM guests using huge page backed memory should experience reduced memory usage and improved performance.

Dependencies

None, the work is confined to libvirt.

Contingency Plan

None needed.

Documentation

Release Notes

KVM guests running on Fedora can now take advantage of huge page backed memory to and benefit from improved performance and reduced memory usage.

Comments and Discussion