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
impl Pager
Sourcepub fn new(source: Box<dyn PageSource>, config: PagerConfig) -> Self
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).
Sourcepub fn register_region(&self, base: u64, size: u64)
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.
Sourcepub fn prewarm(&self) -> Result<(), PagerError>
pub fn prewarm(&self) -> Result<(), PagerError>
Pre-warm the pages in PagerConfig::prewarm.
§Errors
Sourcepub fn serve_fault(&self, ipa: u64, page_size: u64) -> Result<Bytes, PagerError>
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.
Sourcepub fn contains_ipa(&self, ipa: u64) -> bool
pub fn contains_ipa(&self, ipa: u64) -> bool
true if the IPA falls inside any registered region.
Sourcepub fn stats(&self) -> PagerStatsSnapshot
pub fn stats(&self) -> PagerStatsSnapshot
Snapshot of the pager’s counters.
Sourcepub fn request_shutdown(&self)
pub fn request_shutdown(&self)
Signal the Mach server loop to exit at its next poll boundary.
Sourcepub fn handle(&self) -> PagerHandle
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.