Skip to main content

Pager

Struct Pager 

Source
pub struct Pager { /* private fields */ }
Expand description

The pager dispatches fault requests onto its PageSource and tracks which IPA ranges are eligible.

The Mach side runs as a dedicated std::thread (the mach_msg server loop is blocking, can’t go on the tokio runtime). On non-macOS targets the serve_* entry-points are provided as stubs so unit tests of the dispatch logic still run on Linux CI nodes.

Implementations§

Source§

impl Pager

Source

pub fn new(source: Box<dyn PageSource>, config: PagerConfig) -> Self

Build a pager around a page source.

regions is added separately via Self::register_region — typically [ram_start, ram_size).

Source

pub fn register_region(&self, base: u64, size: u64)

Register a postcopy region [base, base + size). Subsequent faults for IPAs inside the region are served from the page source.

Source

pub fn prewarm(&self) -> Result<(), PagerError>

Pre-warm the pages in PagerConfig::prewarm.

§Errors

First PagerError::OutOfRegion / PagerError::Source.

Source

pub fn serve_fault(&self, ipa: u64, page_size: u64) -> Result<Bytes, PagerError>

Serve one fault by computing the page boundary and pulling bytes.

Returns the page bytes; the caller is responsible for mach_vm_protect on macOS or the equivalent host-side write through the HVF mapping.

§Errors

PagerError::OutOfRegion if the IPA isn’t in a registered region; PagerError::Source for source-side failures.

Source

pub fn contains_ipa(&self, ipa: u64) -> bool

true if the IPA falls inside any registered region.

Source

pub fn stats(&self) -> PagerStatsSnapshot

Snapshot of the pager’s counters.

Source

pub fn request_shutdown(&self)

Signal the Mach server loop to exit at its next poll boundary.

Source

pub fn handle(&self) -> PagerHandle

Reference-counted clone of the pager handle. Used so the Mach server thread (or test scaffolding) can hold a handle for the lifetime of the run.

Trait Implementations§

Source§

impl Debug for Pager

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl Freeze for Pager

§

impl !RefUnwindSafe for Pager

§

impl Send for Pager

§

impl Sync for Pager

§

impl Unpin for Pager

§

impl UnsafeUnpin for Pager

§

impl !UnwindSafe for Pager

Blanket Implementations§

Source§

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

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

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

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

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

Source§

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

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

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

Source§

fn into(self) -> U

Calls U::from(self).

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

Source§

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

Source§

type Error = Infallible

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

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

Performs the conversion.
Source§

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

Source§

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

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

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

Performs the conversion.