July 18, 2011

The Kernel Samepage Merging Process

KSM, simply put is a service daemon which scans the page addresses to find duplicate pages, merges them and therefore reduces the memory density. The code used in this post as example can be found under /mm/ksm.c in the kernel source. Before continuing, it is important to keep in mind that: KSM uses a red-black tree for the stable and unstable trees - efficiency is $$O(\log\ n)$$ per tree since the height can never be more than $$(2log\ (n+1))$$ with n being the number of nodes. ... Read more