Kernel SamePage Merging (KSM)
Kernel SamePage Merging (KSM) (also: Kernel Shared Memory, Memory Merging) lets the hypervisor system share identical memory pages amongst different processes or virtualized guests. While not directly linked, KVM can use KSM to merge pages of Virtual machines.
This is done by scanning through the memory finding duplicate pages. The duplicate pair is then merged into a single page, and mapped into both original locations. The page is also marked as "copy-on-write", so the kernel will automatically separate them again should one process modify its data.
KSM was originally intended to run more virtual machines on one host by sharing memory between processes as well as virtual machines. Upon implementation, it was found to be useful for non-virtualized environments as well where memory is at a premium. An experimental implementation of KSM by Red Hat found that 52 virtual instances of Windows XP with 1GB of memory, could run on a host computer that had only 16GB of RAM.
KSM first appeared in Linux kernel version 2.6.32. To be effective, the operating system kernel must find identical memory pages held by different processes. As well it needs to decide whether the pages are going to update infrequently enough that SamePage Merging would be an efficient use of processor resources. A concern is that although memory usage is reduced, CPU usage is increased, thus negating potential increases in performance. Another concern is that KSM may pose security risks.
- "KSM tries again". lwn.net. kernel.org. Retrieved 2010-08-21.
- "Anatomy of Linux Kernel Shared Memory". IBM DeveloperWorks. IBM. Retrieved 2010-08-21.
- "Increasing memory density by using KSM". kernel.org. kernel.org. Retrieved 2010-08-21.
- "Kernel Samepage Merging (memory deduplication)". kernelnewbies. kernelnewbies. Retrieved 2010-08-21.
- Kuniyasu Suzaki, Kengo Iijima, Toshiki Yagi, Cyrille Artho. "Memory Deduplication as a Threat to the Guest OS".
- Using KSM
- Fedora KSM page
- Kernel-based virtual machine site - KSM
- Detail Overview of the KSM merging process