pub struct KsmScanner { /* private fields */ }Expand description
Kernel Same-page Merging scanner.
Maintains stable and unstable trees of page content hashes and orchestrates scanning, comparison, and merge operations.
Implementations§
Source§impl KsmScanner
impl KsmScanner
Sourcepub fn set_scan_rate(&mut self, pages_per_cycle: usize)
pub fn set_scan_rate(&mut self, pages_per_cycle: usize)
Set the number of pages to scan per cycle.
Sourcepub fn set_sleep_ms(&mut self, ms: u64)
pub fn set_sleep_ms(&mut self, ms: u64)
Set the delay between scan cycles in milliseconds.
Sourcepub fn is_enabled(&self) -> bool
pub fn is_enabled(&self) -> bool
Check whether the scanner is enabled.
Sourcepub fn scan_page(&mut self, frame: FrameNumber, content: &[u8]) -> bool
pub fn scan_page(&mut self, frame: FrameNumber, content: &[u8]) -> bool
Scan a single page. The caller provides the frame number and a reference to the page content (PAGE_SIZE bytes).
The scanner will:
- Compute FNV-1a hash of the page content.
- Search the stable tree for a match (merge immediately).
- Search the unstable tree for a match (increment stable_count).
- If no match, add to the unstable tree.
Returns true if the page was merged (caller should remap as COW).
Sourcepub fn unmerge_page(&mut self, frame: FrameNumber)
pub fn unmerge_page(&mut self, frame: FrameNumber)
Remove a page from the stable tree (e.g. after a COW fault breaks the sharing).