In
computing
Computing is any goal-oriented activity requiring, benefiting from, or creating computer, computing machinery. It includes the study and experimentation of algorithmic processes, and the development of both computer hardware, hardware and softw ...
, kernel same-page merging (KSM), also known as kernel shared memory, memory merging, memory deduplication, and page deduplication is a
kernel feature that makes it possible for a
hypervisor
A hypervisor, also known as a virtual machine monitor (VMM) or virtualizer, is a type of computer software, firmware or hardware that creates and runs virtual machines. A computer on which a hypervisor runs one or more virtual machines is called ...
system to share
memory pages that have identical contents between multiple
processes or
virtualized guests. While not directly linked,
Kernel-based Virtual Machine
Kernel-based Virtual Machine (KVM) is a free and open-source virtualization module in the Linux kernel that allows the Kernel (operating system), kernel to function as a hypervisor. It was merged into the Mainline Linux, mainline Linux kernel i ...
(KVM) can use KSM to merge memory pages occupied by
virtual machine
In computing, a virtual machine (VM) is the virtualization or emulator, emulation of a computer system. Virtual machines are based on computer architectures and provide the functionality of a physical computer. Their implementations may involve ...
s.
Deduplication
KSM performs memory deduplication by scanning through
main memory
Computer data storage or digital data storage is a technology consisting of computer components and recording media that are used to retain digital data. It is a core function and fundamental component of computers.
The central processin ...
for physical pages that have identical content, and identifies the virtual pages that are mapped to those physical pages. It leaves one page unchanged, and re-maps each duplicate page to point to the same physical page, after which it releases the extra physical pages for re-use. It also marks both virtual pages as "
copy-on-write" (COW), so that kernel will automatically remap a virtual page back to having its own separate physical page as soon as any process begins to write to it.
KSM was originally intended to run more virtual machines on one host by
sharing memory between processes as well as virtual machines. 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.
Upon its
implementation
Implementation is the realization of an application, execution of a plan, idea, scientific modelling, model, design, specification, Standardization, standard, algorithm, policy, or the Management, administration or management of a process or Goal ...
, users found KSM to also be useful for non-virtualized environments in which memory is at a premium.
KSM was merged into the
Linux kernel
The Linux kernel is a Free and open-source software, free and open source Unix-like kernel (operating system), kernel that is used in many computer systems worldwide. The kernel was created by Linus Torvalds in 1991 and was soon adopted as the k ...
mainline in version 2.6.32, which was released on December 3, 2009.
To be effective, the operating system kernel must find identical memory pages held by different processes. The kernel also needs to predict whether the pages are likely to update infrequently enough that the 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.
Security risks
Security is also a concern:
* Allows circumvention of
address space layout randomization (ASLR)
* Exposes information via
timing attacks
* Allows contamination of cryptographic resources in other virtualized guests via the memory
row hammer attack
See also
*
Data deduplication – Reduction of storage requirement by sharing duplicate files
*
Single-instance storage
References
External links
Linux kernel documentationFedora KSM pageKernel-based virtual machine site - KSM
{{DEFAULTSORT:Kernel samepage merging
Computer memory
Linux kernel features