Getting acquainted with KSM
KSM is a feature that allows the sharing of identical pages between the different processes running on a system. We might presume that the identical pages exist due to certain reasons—for example, if there are multiple processes spawned from the same binary or something similar. There is no rule such as this though. KSM scans these identical memory pages and consolidates a Copy-on-Write (COW) shared page. COW is nothing but a mechanism where when there is an attempt to change a memory region that is shared and common to more than one process, the process that requests the change gets a new copy and the changes are saved in it.
Even though the consolidated COW shared page is accessible by all the processes, whenever a process tries to change the content (write to that page), the process gets a new copy with all of the changes. By now, you will have understood that, by using KSM, we can reduce physical memory consumption. In the KVM context, this...