Skip to main content

nonresident

Function nonresident 

Source
pub(super) fn nonresident(ptr: *mut u8, len: usize) -> bool
Available on Unix and crate feature pool and non-miri only.
Expand description

Whether every page of the page-aligned subrange of [ptr, ptr + len) has been unmapped from this process, per the present bits in /proc/self/pagemap. A failed observation reports false: the ledger keeps counting pages it cannot prove gone.

The present bit is the signal, deliberately not mincore(2): successful asynchronous reclaim unmaps the PTE to a swap entry while the page’s clean copy lingers in the kernel’s swap cache, and mincore reports swap-cache pages as in core. Observing in-core-ness would therefore misclassify essentially every successful pageout on an unpressured host (the retry advice cannot change the outcome either, since the advice skips already-unmapped PTEs). An unmapped page is reclaimed for this ledger’s purposes: a clean swap-cache copy is memory the kernel drops for free.

Only Linux answers from the kernel. Elsewhere the reclaim advice is compiled out, so there is no reclaim to observe and the answer is true, keeping the compressed tier cycling on development platforms.