Jump to content

Kernel same-page merging

From Wikipedia, the free encyclopedia
This is an old revision of this page, as edited by AnomieBOT (talk | contribs) at 01:06, 8 January 2016 (Dating maintenance tags: {{By whom?}}). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.

In computing, kernel same-page merging (abbreviated to KSM, and also known as kernel shared memory or as memory merging) lets a hypervisor system share identical memory pages amongst different processes or virtualized guests. While not directly linked, KVM can use KSM to merge memory pages occupied by virtual machines.

This is done by scanning through the memory and 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" (COW), so the kernel will automatically separate them again should one process modify its data.[1]

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 also found[by whom?] useful for non-virtualized environments where memory is at a premium.[2][3] An experimental implementation of KSM by Red Hat found that 52 virtual instances of Windows XP with 1 GB of memory, could run on a host computer that had only 16 GB of RAM.[4]

KSM was merged into the Linux kernel mainline in kernel version 2.6.32, released on December 3, 2009.[2][4] To be effective, the operating system kernel must find identical memory pages held by different processes. The kernel also needs to decide whether the pages are going to update infrequently enough that the merging would be an efficient use of processor resources.[3] A concern is that although memory usage is reduced, CPU usage is increased, thus negating potential increases in performance.[1] Another concern is that KSM may pose security risks, such as allowing circumvention of address space layout randomization (ASLR).[5][6]

References

  1. ^ a b "KSM tries again". lwn.net. kernel.org. Retrieved August 21, 2010.
  2. ^ a b "Anatomy of Linux Kernel Shared Memory". IBM DeveloperWorks. IBM. Retrieved August 21, 2010.
  3. ^ a b "Increasing memory density by using KSM" (PDF). kernel.org. Retrieved August 21, 2010.
  4. ^ a b "Linux kernel 2.6.32, Section 1.3. Kernel Samepage Merging (memory deduplication)". kernelnewbies.org. December 3, 2009. Retrieved August 12, 2015.
  5. ^ "Memory Deduplication as a Threat to the Guest OS" (PDF). {{cite web}}: Unknown parameter |authors= ignored (help)
  6. ^ Antonio Barresi; Kaveh Razavi; Mathias Payer; Thomas R. Gross (August 2015). "CAIN: Silently Breaking ASLR in the Cloud" (PDF). USENIX. Retrieved August 12, 2015.