Re: [PATCH v8 2/4] kselftest: mm: replace usage of /proc/self/smaps for __check_pmd_huge()
From: Baolin Wang
Date: Tue Sep 29 2026 - 02:40:56 EST
On 9/25/26 3:11 AM, Yeoreum Yun wrote:
Since glibc commit 321e1fc73f (“malloc: Enable 2MB THP by default on AArch64”),
glibc may call madvise(MADV_HUGEPAGE) for sufficiently large allocations
made by memalign().
The underlying VMA may start at a different address from the aligned
address returned by memalign(). Furthermore, a subsequent
madvise(MADV_HUGEPAGE) call does not split the VMA because the flag is
already set.
This causes split_huge_page_test to fail because the check_pmd_huge()
helpers incorrectly require the address returned by memalign() to
match the VMA start address reported in /proc/self/smaps.
Instead of relying on /proc/self/smaps, use /proc/self/pagemap and
/proc/kpageflags to detect huge-page mappings checking PAGE_IS_HUGE
and PAGE_IS_FILE accroding to type of huge page.
Since shmem pages are also file-backed, simply check whether the page
is file-backed.
Fixes: 642bc52aed9 ("selftests: vm: bring common functions to a new file")
Suggested-by: David Hildenbrand (Arm) <david@xxxxxxxxxx>
Signed-off-by: Yeoreum Yun <yeoreum.yun@xxxxxxx>
---
With comments from Sarthak addressed,
Reviewed-by: Baolin Wang <baolin.wang@xxxxxxxxxxxxxxxxx>
Tested-by: Baolin Wang <baolin.wang@xxxxxxxxxxxxxxxxx>