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

KsmScanner

Struct KsmScanner 

Source
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

Source

pub const fn new() -> Self

Create a new KSM scanner with default configuration.

Source

pub fn init(&mut self)

Initialize the scanner. Must be called once before enable().

Source

pub fn set_scan_rate(&mut self, pages_per_cycle: usize)

Set the number of pages to scan per cycle.

Source

pub fn set_sleep_ms(&mut self, ms: u64)

Set the delay between scan cycles in milliseconds.

Source

pub fn enable(&self)

Enable the KSM scanner.

Source

pub fn disable(&self)

Disable the KSM scanner.

Source

pub fn is_enabled(&self) -> bool

Check whether the scanner is enabled.

Source

pub fn get_stats(&self) -> KsmStats

Get current KSM statistics.

Source

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:

  1. Compute FNV-1a hash of the page content.
  2. Search the stable tree for a match (merge immediately).
  3. Search the unstable tree for a match (increment stable_count).
  4. If no match, add to the unstable tree.

Returns true if the page was merged (caller should remap as COW).

Source

pub fn unmerge_page(&mut self, frame: FrameNumber)

Remove a page from the stable tree (e.g. after a COW fault breaks the sharing).

Source

pub fn scan_rate(&self) -> usize

Get the configured scan rate.

Source

pub fn sleep_ms(&self) -> u64

Get the configured sleep interval in milliseconds.

Trait Implementations§

Source§

impl Default for KsmScanner

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

§

impl !Freeze for KsmScanner

§

impl RefUnwindSafe for KsmScanner

§

impl Send for KsmScanner

§

impl Sync for KsmScanner

§

impl Unpin for KsmScanner

§

impl UnwindSafe for KsmScanner

Blanket Implementations§

§

impl<T> Any for T
where T: 'static + ?Sized,

§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
§

impl<T> Borrow<T> for T
where T: ?Sized,

§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
§

impl<T> BorrowMut<T> for T
where T: ?Sized,

§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
§

impl<T> From<T> for T

§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T, U> Into<U> for T
where U: From<T>,

§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of [From]<T> for U chooses to do.

§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.