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) <[email protected]>
Signed-off-by: Yeoreum Yun <[email protected]>
---

With comments from Sarthak addressed,
Reviewed-by: Baolin Wang <[email protected]>
Tested-by: Baolin Wang <[email protected]>

Reply via email to