On 10/14/26 11:27 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 provide
> little coverage of its range, folio-state and permission decisions.
>
> Add a kselftest harness test for both hints, starting with the most basic
> behavior userspace relies on: MADV_COLD neither populates a PTE hole nor
> faults a swapped page back in, and neither hint may be applied to a locked
> VMA.
>
> The swapped-page test skips when swap is unavailable.
>
> Signed-off-by: Gregory Price (Meta) <[email protected]>
> ---
> tools/testing/selftests/mm/Makefile | 2 +
> tools/testing/selftests/mm/ksft_madvise.sh | 4 +
> tools/testing/selftests/mm/madvise.c | 134 +++++++++++++++++++++
> tools/testing/selftests/mm/run_vmtests.sh | 5 +
> 4 files changed, 145 insertions(+)
> create mode 100755 tools/testing/selftests/mm/ksft_madvise.sh
> create mode 100644 tools/testing/selftests/mm/madvise.c
I am not sure if this test needs to be called madvise. I think this
might be a too broad name for a test for MADV_COLD and MADV_PAGEOUT. Can
we maybe call it something like madv_cold_pageout (similar to
madv_populate already present)?
Apart from that, it LGTM.
Reviewed-by: Sarthak Sharma <[email protected]>