Re: [PATCH v2 1/1] selftests/proc: use RSS in /proc/pid/smaps_rollup tearing tests

From: Pedro Falcato

Date: Mon Nov 02 2026 - 08:30:04 EST


On Sun, Nov 01, 2026 at 07:45:03AM -0800, Suren Baghdasaryan wrote:
> Pss metrics can be affected by map count even if VMA tree stays unchanged,
> therefore tests checking VMA tree integrity can't use them. Use Rss instead
> and pre-populate the VMAs so that Rss changes if a VMA gets skipped or
> double-counted.
>
> To ensure all test VMAs are populated with anonymous pages, remain
> mergeable across VMA operations, and do not have their Rss changed by
> memory reclaim:
> - Toggle PROT_EXEC instead of PROT_WRITE between adjacent test VMAs so
> all test VMAs remain writable and MAP_POPULATE faults in anonymous pages
> (rather than the shared zero page, which is not accounted in Rss).
> - Use mprotect() instead of mmap(..., MAP_FIXED) in split_vma() and
> merge_vma() so the first page of the split VMA stays resident.
> mprotect(..., PROT_NONE) splits the VMA without unmapping the first page
> (pte_present() remains true for PAGE_NONE PTEs), and
> mprotect(..., self->mod_info->prot) merges it back. Both parts of the
> split VMA retain their non-zero Rss.
> - Lock all present pages in the child with mlockall(MCL_CURRENT |
> MCL_FUTURE | MCL_ONFAULT) so memory pressure cannot reclaim pages and
> alter Rss during the test.

FWIW, I was wondering if it would remain constant in face of compaction (page
migration). It seems so, from looking at the code the migration entry should
make it count the RSS. But is it always the case? I'm not super familiar with
the migration logic.


--
Pedro