On 10/19/26 10:42 PM, Gregory Price (Meta) wrote:
> MADV_COLD and MADV_PAGEOUT share a page-table walker covering ordinary
> PTEs, PTE-mapped large folios and huge PMDs. Existing selftests use
> MADV_PAGEOUT mostly to swap memory out for other tests, and check only
> special mappings (PFNMAP, guard regions, droppable memory), not the
> walker's range, folio and permission handling.
>
> Add a kselftest harness test for both hints, starting with the most basic
> behavior userspace relies on: neither hint populates a PTE hole or faults
> a swapped page back in, and neither may be applied to a locked VMA.
>
> Before running the tests, pin the process to the CPU it starts on,
> so that the LRU batch MADV_COLD and MADV_PAGEOUT drain holds the
> folios a test faulted in.
>
> Signed-off-by: Gregory Price (Meta) <[email protected]>
> ---
> v3: Dropped Sarthak's Reviewed-by from v2 1/8 and 2/8, which are folded
> here, since this patch now adds main() with the CPU pinning and the
> one-time reclaim check, and the swapped-page tests fail rather than skip.
Thanks for changing the name of the selftest. Adding the swap check once
in main() also looks good.
Reviewed-by: Sarthak Sharma <[email protected]>