Re: [PATCH v5 3/3] kselftest: mm: introduce alloc_isolated_mem()

From: David Hildenbrand (Arm)

Date: Thu Sep 10 2026 - 07:23:02 EST


On 9/10/26 13:02, Yeoreum Yun wrote:
>>> diff --git a/tools/testing/selftests/mm/soft-dirty.c b/tools/testing/selftests/mm/soft-dirty.c
>>> index 5f278913c4d7..b6fad38c8bee 100644
>>> --- a/tools/testing/selftests/mm/soft-dirty.c
>>> +++ b/tools/testing/selftests/mm/soft-dirty.c
>>> @@ -92,9 +92,9 @@ static void test_hugepage(int pagemap_fd, int pagesize)
>>> if (!hpage_len)
>>> ksft_exit_fail_msg("Reading PMD pagesize failed");
>>>
>>> - map = memalign(hpage_len, hpage_len);
>>> + map = alloc_isolated_mem(hpage_len, hpage_len);
>>> if (!map)
>>> - ksft_exit_fail_msg("memalign failed\n");
>>> + ksft_exit_fail_msg("alloc_isolated_mem failed\n");
>>>
>>> ret = madvise(map, hpage_len, MADV_HUGEPAGE);
>>> if (ret)
>>> @@ -130,7 +130,7 @@ static void test_hugepage(int pagemap_fd, int pagesize)
>>> ksft_test_result_skip("Test %s huge page allocation\n", __func__);
>>> ksft_test_result_skip("Test %s huge page dirty bit\n", __func__);
>>> }
>>> - free(map);
>>> + free_isolated_mem(map, hpage_len);
>>> }
>>
>> smaps is really only problematic with merged VMAs when relying on exact page
>> statistics. For other properties (vm flags, MMUPageSize) it's not a problem as
>> long as our smap search just finds the VMA that covers an address.
>>
>> Assuming we fixed check_huge_anon() to not use smaps, why is this change here
>> required?
>
> Since there is no interface to get vm_flags not via /proc/self/smaps,
> It might be good to have it for preventing unwanted VMA merge.
>
> And might be useful for future to prevent unwated VMA merge.

See my reply on why vm flags are generally not a problem. Just like other
properties that are not changed during VMA merging.

Let's not perform random code changes without a clear picture.

And just to emphasize again: VMA merging could already be a problem before
memalign() internal changes.

(also observe here how we do a MADV_HUGEPAGE, so this is all rather arbitrary,
which is not good)

--
Cheers,

David