(update status, add required package versions, link to qemu patch) |
|||
Line 68: | Line 68: | ||
* Current [http://lkml.org/lkml/2009/6/29/221 madvise rollup] | * Current [http://lkml.org/lkml/2009/6/29/221 madvise rollup] | ||
* Posted [http://lkml.org/lkml/2009/7/17/163 KSM rollup] | * Posted [http://lkml.org/lkml/2009/7/17/163 KSM rollup] | ||
* | * Izik's [http://www.mail-archive.com/kvm@vger.kernel.org/msg19964.html qemu-kvm patch] | ||
== Release Notes == | == Release Notes == |
Revision as of 19:02, 11 August 2009
KSM
Summary
Allow KVM guest virtual machines to share identical memory pages. This is especially useful when running multiple guests from the same or similar base operating system image. Because memory is shared, the combined memory usage of the guests is reduced.
Owner
- Name: Justin M. Forbes
- Email: jforbes@redhat.com
Current status
- Targeted release: Fedora 12
- Last updated: 2009-08-05
- Percentage of completion: 100%
Completed
- Multiple versions of the patch posted and discussed on LKML.
- Confirmed the kernel patch is queued for 2.6.32 and the
madvise()
API is stable - Backport to 2.6.31
- Include in Fedora kernel builds
- Enable memory sharing in
qemu-kvm
Detailed Description
The concept of shared memory is very common in operating system design. For example, when a program is first started it shares all of its memory with the parent program. When either the child or parent program tries to modify some of this memory the kernel allocates a new memory region, copies the original contents and allows the program to modify this new region. This is known as copy on write.
KSM is a new Linux feature which turns this concept on its head. It enables the kernel to look at two already running programs and compare their memory. If any memory regions are exactly identical, the kernel can combine the two regions into one and mark those regions for copy on write as above.
This is especially useful in the case of KVM. When guest virtual machines are started, they can only inherit the memory of the parent qemu-kvm
process. However, it is the contents of the guest operating system image which has the data which is most likely to be shareable. KSM allows KVM to request that these identical guest memory regions be shared.
Benefit to Fedora
With this feature Fedora will be able to run guest virtual machines in a potentially much more memory efficient manner. This will mean that Fedora host machines will be capable of hosting more guests than before.
Scope
The main effort here is the kernel support. Since it is not going to make 2.6.31, we need to consider backporting it once the userspace API has been declared stable. KSM is a pretty well self-contained memory management feature, so backporting should be straightforward.
Once the kernel support is available, a minor patch for qemu-kvm
is required to enable the memory sharing.
An open question is whether KSM will be enabled for all guests by default. If not, support for enabling it will need to be added to libvirt, virtinst, virt-manager etc.
How To Test
- Ensure you are using
kernel >= 2.6.31-0.94.rc4.fc12
andqemu-kvm >=2:0.10.91-0.2.rc1.rc0
- Install two Fedora 11 virtual machines and run them
- Write "1" to
/sys/kernel/mm/ksm/run
- Check whether pages were merged using
/sys/kernel/mm/ksm/pages_shared
User Experience
Users running multiple, but similar, KVM guests should experience a reduction in memory usage when KSM is enabled.
Dependencies
Getting KSM accepted for 2.6.32 and the API declared stable.
Contingency Plan
None needed, if KSM is not implemented guests will still work as they do now, without the advantage of a reduced memory footprint.
Documentation
- Kernel patch submission
- Agreement to defer until 2.6.32
- Current madvise rollup
- Posted KSM rollup
- Izik's qemu-kvm patch
Release Notes
Fedora 12 adds KSM (Kernel SamePage Merging) which allows identical memory pages to be merged by the kernel into a single page. This is initially used by KVM to allow multiple, but similar, guest virtual machines to have a reduced memory footprint.