⚠️ VeridianOS Kernel Documentation - This is low-level kernel code. All functions are unsafe unless explicitly marked otherwise. no_std

Module ksm

Module ksm 

Source
Expand description

Kernel Same-page Merging (KSM)

Scans anonymous user-space pages for identical content and merges duplicates via Copy-on-Write (COW) mappings. Reduces memory consumption for workloads with many similar processes (e.g. KDE Plasma applets, browser tabs, containerized services).

Design:

  • Unstable tree: pages seen once, awaiting confirmation across multiple scan cycles before promotion.
  • Stable tree: pages confirmed identical, merged via COW.
  • FNV-1a hash: fast 32-bit content hash for candidate filtering (integer-only, no floating point).
  • Full comparison: byte-for-byte equality check on hash match before merging.

Pages are identified by frame number (FrameNumber). The scanner does not touch kernel pages, device-mapped pages, or already-merged pages.

Structs§

KsmScanner
Kernel Same-page Merging scanner.
KsmStats
Statistics reported by the KSM scanner.