On 9/25/26 16:23, Yeoreum Yun wrote:
> On Fri, Sep 25, 2026 at 06:08:44PM +0530, Sarthak Sharma wrote:
>>
>>
>> On 9/25/26 12:41 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.
>>
>> s/accroding/according
> 
> Okay.
> 
>>
>>>
>>> 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")
>>
>> Checkpatch gives a warning saying it requires atleast 12 characters of
>> commit SHA.
> 
> Oops. I'll update.
> 
>>
>>> Suggested-by: David Hildenbrand (Arm) <[email protected]>
>>> Signed-off-by: Yeoreum Yun <[email protected]>
>>> ---
>>
>> [...]
>>
>>> +static bool __check_pmd_huge(void *addr, size_t len, int nr_hpages,
>>> +             uint64_t hpage_size, enum check_huge_type type)
>>> +{
>>> +   int pagemap_fd;
>>> +   int nr_pmd_mappings = 0;
>>> +   uint64_t categories;
>>> +   char *start = addr;
>>> +   char *end = start + len;
>>> +
>>> +   pagemap_fd = open(PAGEMAP_PATH, O_RDONLY);
>>> +   if (pagemap_fd < 0)
>>> +           ksft_exit_fail_msg("open pagemap fail\n");
>>
>> Can we use ksft_exit_fail_perror("open pagemap") here? Will help in
>> diagnosing failures as well.
> 
> I see thanks!
> 
> 
>>
>> Apart from these nits, rest looks good.
>>
>> Reviewed-by: Sarthak Sharma <[email protected]>
> 

With these things

Acked-by: David Hildenbrand (Arm) <[email protected]>

Thanks Sarthak for the review!

-- 
Cheers,

David

Reply via email to