Identical bytes need not occupy two physical locations. There is no marketing exaggeration in that statement: Linux KSM can discover matching anonymous-page contents and replace separate physical copies with one write-protected shared page. The exaggeration begins in the next sentence, when those savings become free additional RAM. Matches have lifetimes, finding them requires work, and later writes have consequences. Omit those conditions and the promise becomes too convenient to describe a real memory system.
First acknowledge the method’s genuine strength. If several virtual machines or processes retain matching data for a long time, storing every physical copy is unnecessary. Their virtual addresses can remain different while the kernel arranges mappings to shared contents. Each process still sees its own address space. Applications need not manually rewrite every read as access to a specially constructed shared array. That transparency makes the mechanism attractive where duplication persists longer than the search needed to discover it.
KSM does not, however, recognize a similar virtual machine in the human sense. It operates on page contents. Running the same program does not guarantee identical bytes in every region: addresses, mutable data, execution history, and layout can break matches. Conversely, matching regions can exist in applications a user considers unrelated. The unit of deduplication imposes its own definition of similarity, stricter than the impression made by several identical application windows.
Linux’s KSM administration documentation describes merging anonymous private pages rather than file page-cache pages. That boundary matters. File pages already have sharing mechanisms through the common file object. Treating all pages from matching executable files as new KSM savings could credit it with sharing the system already provided differently. An honest result identifies the origin of the memory considered for merging and the mechanism actually providing its mappings.
“Nothing changes for the program” also needs qualification. Private-data semantics must survive, but access costs can change. While participants read the shared page, one copy serves several mappings. When one participant writes, its modification must be separated from the others. Copy-on-write preserves independence: the writer obtains a private copy without changing the bytes other participants continue to read. That is additional work at write time, rather than a free indefinite continuation of sharing.
The weakest point in a permanent-capacity promise is the moment participants stop matching together. A quiet period produces attractive savings; a software update or changed dataset then causes widespread separation. Physical demand can rise precisely when CPUs are already busy with useful work. A savings ratio observed once cannot be treated as an invariant reserve for every future phase. Planning needs the mutability of the contents, rather than only a flattering snapshot taken after identical instances start.
This does not make merging a mistake. It makes the lifetime of a match relevant. Long-lived, mostly read duplicates have an opportunity to repay discovery work and retain useful savings. With rapidly changing pages, the search can repeatedly discover information too late. If writes separate pages immediately after merging, the system pays for short-lived results. A universal percentage for any server lacks a technical basis: data behavior matters more than the machine’s name or installed module count.
Searching uses the computer too. The ksmd worker scans registered regions and compares candidates. Greater intensity examines memory sooner while consuming more processing time and memory-access work. Lower intensity reduces current expense but can miss a short window of useful similarity. No single sleep interval is appropriate for every workload. Automatic adjustment does not eliminate the need to assess the result against the useful work the application is supposed to perform.
The KSM design documentation describes stable and unstable candidate trees. Their details establish an important point: deduplication requires metadata of its own. Removing a physical content copy is not the same as freeing that entire amount after accounting for all administrative structures. The article need not catalogue every kernel structure to preserve this conclusion. A memory-saving mechanism uses memory, and that expense belongs in an honest balance.
Matching contents also do not imply unlimited sharing among mappings. Long reverse-mapping lists can make some virtual-memory operations expensive. The documentation therefore describes max_page_sharing and the organization of duplicate copies with identical contents. At first a duplicate physical copy may look like deduplication failing. It is instead a compromise between maximum savings and bounded maintenance costs. The greatest possible sharing need not deliver the best latency for a particular workload.

Write-protecting a shared page does not prohibit the application from modifying its private data. It lets the kernel recognize when the old match no longer applies and provide a separate copy. The continued write must preserve the usual meaning of modifying private contents. This page fault has a different purpose from reporting a defective DRAM cell. Its occurrence alone is not a detected hardware error: it is part of implementing privacy over temporarily shared physical contents.
Counters can support an excessively attractive story. In KSM’s interface, pages_shared counts physical shared pages, while pages_sharing counts additional sites sharing them. These are different quantities. A large first number alone does not establish how many copies were avoided. Summing processes’ resident-memory figures can also count shared pages repeatedly. A report needs field definitions, page size, and an accounting boundary, or one physical object can quietly become several gigabytes on paper.
Special handling of zero pages adds another qualification. The documentation distinguishes ordinary merging from using common zero pages, with a separate ksm_zero_pages counter. A crude formula using only one familiar field may cease to represent actual savings after the mode changes. Keeping settings and the full set of fields with the observation date lets a later reader distinguish changed memory behavior from changed accounting. A smaller number should not automatically become evidence of a better algorithm.
The pages_unshared and pages_volatile fields expose another side of discovery: candidates remain unique or change too quickly. This is not automatically a malfunction. The workload may simply be a poor candidate for merging. The substantive comparison is work expended against persistent matches found. A report that shows only savings while hiding CPU costs and splitting behavior describes one pleasant fragment of the mechanism, rather than its overall usefulness to the system.
Permission to scan is not a scanning result. The madvise manual describes MADV_MERGEABLE as advice identifying suitable regions. A successful call does not prove the pages are already merged. Kernel support, an operating mechanism, and matching contents are still needed. The application states an intention; that intention cannot manufacture an identical second page on demand. Immediate startup observations and measurements after a long quiet interval can consequently describe different stages.
The word disable needs care as well. In the documented run interface, setting zero stops ksmd but retains already merged pages. The unmerging mode performs different work. Reduced scanning expense therefore need not immediately restore every separate copy. Reversing merging can itself require additional memory. We discuss interface semantics without changing parameters on any running system. A dashboard label should preserve the distinction between stopping discovery and undoing the results discovery previously produced.
A before-and-after comparison consequently needs a dated history. Were pages separated, or was only scanning stopped? Did the application enter another phase? How long did old shared pages remain? Without those details, a setting can receive credit for an unrelated event. The same homemade KSM-off label can conceal different actions. A technical conclusion should follow the action and observed state, rather than relying on the wording beside a switch.
NUMA introduces the location of the remaining copy. Matching data may initially have lived close to different CPUs, whereas a shared physical page has a particular location. The merge_across_nodes control defines the scope of merging, and the documentation connects it with a capacity-versus-locality tradeoff. Saving a page and reducing access time are different objectives. Sharing alone cannot promise both; a remote access does not disappear because two sets of bytes happen to match.
Deduplication must not be mistaken for an application communication channel either. Accidentally identical private pages do not acquire ordinary shared-write semantics after KSM merging. Copy-on-write specifically preserves the private meaning of a modification. A program expecting to notify a neighbor by changing its own such page uses the wrong model. Shared physical storage of present contents and an agreement to modify data jointly are distinct properties, even when a utility displays both beside the word shared.
Confidentiality claims have a similar logical boundary. Transparency of stored values does not prove the absence of all observable side effects from sharing resources. Policies spanning trust domains require a separate threat model and applicable implementation evidence. Copy-on-write alone cannot establish a universal timing-isolation guarantee. We neither test security nor report a real attack here; the point is that preservation of private values supports a narrower promise than complete absence of every possible observation.
Finally, KSM neither increases the modules’ physical bandwidth nor repairs stored-data errors. A workload dominated by bandwidth or unique changing data may offer very little useful duplication. That problem needs another analysis. The name of a memory-saving technology should not become a generic explanation for every pause. Its subject is specific: repeated contents in eligible pages, shared long enough to remain worthwhile after discovery and maintenance costs.
That is a worthwhile subject for a precise promise. In a suitable workload, KSM removes physical copies while retaining private semantics. Success concerns persistent savings and their consequences for useful work, rather than an impressive starting number. When matching ends, demand for separate pages returns. Additional effective capacity exists while the system sustains a useful match. Calling it free permanent RAM would remove the very life of the data that the memory exists to support. Sources checked October 24, 2026.



