Struct swap::page_handler::TrimContext
source · pub struct TrimContext<'a> {
ctx: &'a Mutex<PageHandleContext<'a>>,
cur_region: usize,
cur_page: usize,
next_data_in_file: Range<usize>,
clean_pages: usize,
zero_pages: usize,
}
Expand description
Context for trim operation.
This drops 2 types of pages in the staging memory to reduce disk write.
- Clean pages
- The pages which have been swapped out to the disk and have not been changed.
- Drop the pages in the staging memory and mark it as present on the swap file.
- Zero pages
- Drop the pages in the staging memory. The pages will be UFFD_ZEROed on page fault.
Fields§
§ctx: &'a Mutex<PageHandleContext<'a>>
§cur_region: usize
§cur_page: usize
§next_data_in_file: Range<usize>
The page idx range of pages which have been stored in the swap file.
clean_pages: usize
§zero_pages: usize
Implementations§
source§impl TrimContext<'_>
impl TrimContext<'_>
sourcepub fn trim_pages(&mut self, max_pages: usize) -> Result<Option<usize>>
pub fn trim_pages(&mut self, max_pages: usize) -> Result<Option<usize>>
Trim pages in the staging memory.
This returns the pages trimmed. This returns None
if it traversed all pages in the staging
memory.
§Arguments
max_size
- The maximum pages to be compared.
sourcepub fn trimmed_clean_pages(&self) -> usize
pub fn trimmed_clean_pages(&self) -> usize
Total trimmed clean pages.
sourcepub fn trimmed_zero_pages(&self) -> usize
pub fn trimmed_zero_pages(&self) -> usize
Total trimmed zero pages.
Auto Trait Implementations§
impl<'a> RefUnwindSafe for TrimContext<'a>
impl<'a> Send for TrimContext<'a>
impl<'a> Sync for TrimContext<'a>
impl<'a> Unpin for TrimContext<'a>
impl<'a> UnwindSafe for TrimContext<'a>
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more