On 31.08.25 04:27, Wei Yang wrote:
Subject: "selftests/mm: verify page content after remapping PMD through PTEs"
After mremap(), add a check on content to see whether mremap corrupt data.
Signed-off-by: Wei Yang richard.weiyang@gmail.com
v2: add check on content instead of just test backed folio
I'm confused, don't we have that exact check later in the function?
Your v1 might have been better, unless I am missing something.
tools/testing/selftests/mm/split_huge_page_test.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/tools/testing/selftests/mm/split_huge_page_test.c b/tools/testing/selftests/mm/split_huge_page_test.c index 10ae65ea032f..229b6dcabece 100644 --- a/tools/testing/selftests/mm/split_huge_page_test.c +++ b/tools/testing/selftests/mm/split_huge_page_test.c @@ -423,10 +423,14 @@ static void split_pte_mapped_thp(void) /* smap does not show THPs after mremap, use kpageflags instead */ thp_size = 0;
- for (i = 0; i < pagesize * 4; i++)
- for (i = 0; i < pagesize * 4; i++) {
if (pte_mapped[i] != (char)i)
ksft_exit_fail_msg("%ld byte corrupted\n", i);
- if (i % pagesize == 0 && is_backed_by_folio(&pte_mapped[i], pmd_order, pagemap_fd, kpageflags_fd)) thp_size++;
- }
if (thp_size != 4) ksft_exit_fail_msg("Some THPs are missing during mremap\n");
I'm a bit confused with this test in general.
We do a
pte_mapped = mremap(one_page, pagesize, pagesize, MREMAP_MAYMOVE);
which I read as a "NOP".
Questions
(a) Will this actually do anything? Also, maybe it does now, but can't the kernel just optimize that out in the future?
(b) Is it even guaranteed that we can access > pagesize afterwards? I mean, we specify MREMAP_MAYMOVE.
I would suggest to just use mprotect/madvise to pte-map a PMD-THP.
This is, of course, independent of this patch.