Re: [PATCH 8/8] selftests/mm: check that unauthorized MADV_PAGEOUT skips large file folios

From: Gregory Price

Date: Wed Oct 14 2026 - 17:27:19 EST


On Wed, Oct 14, 2026 at 01:57:56PM -0400, Gregory Price (Meta) wrote:
> A caller that neither owns nor may write a file may page out the COW pages
> of a private mapping of it, but not its file pages. When the advised range
> only partly covers a large file folio, the folio must be filtered out
> before it is split or reclaimed, on separate paths for PMD- and PTE-mapped
> folios.
>
> Check that partial MADV_PAGEOUT by such a caller leaves every page of a
> PMD-sized shmem folio resident, both when a PMD maps it and when a mapping
> of half of it maps it with PTEs.
>
... snip ...
> + ASSERT_EQ(madvise(mapping, pmd_size / 2, MADV_PAGEOUT), 0);
> + for (offset = 0; offset < pmd_size; offset += page_size)
> + ASSERT_TRUE(page_is_present(self->pagemap_fd,
> + mapping + offset));
> + assert_filled(_metadata, mapping, pmd_size);

Sashiko reported:

The commit message states that the folio must be filtered out before it is
split or reclaimed. Since page_is_present() only confirms the pages were not
reclaimed, should this test also verify that the underlying folio was not
split by the partial-range madvise?

I'm fairly sure this is a false-positive. Splitting a file folio unmaps it
entirely, so the page_is_present assert would fail.

~Gregory