Re: [PATCH v2 4/4] selftests: mm: add mTHP collapse test cases

Zi Yan <[email protected]>
Newsgroups gmane.linux.kernel,gmane.linux.kernel.mm
Message-ID <[email protected]>
On 5 Aug 2026, at 21:17, Baolin Wang wrote:

> On 8/6/26 12:46 AM, Zi Yan wrote:
>> On Sat Aug 1, 2026 at 2:26 AM EDT, Baolin Wang wrote:
>>> Added a new command 'mthp_khugepaged' for mTHP collapse, along with the '-c'
>>> parameter to specify the collapse order. Additionally, added mTHP collapse
>>> test cases for 'collapse_full', 'collapse_empty', and 'collapse_single_mthp'
>>> for anonymous folios. All khugepaged test cases passed.
>>>
>>> Signed-off-by: Baolin Wang <[email protected]>
>>> ---
>>>   tools/testing/selftests/mm/khugepaged.c   | 130 ++++++++++++++++++----
>>>   tools/testing/selftests/mm/run_vmtests.sh |   2 +
>>>   2 files changed, 113 insertions(+), 19 deletions(-)
>>>
>>> diff --git a/tools/testing/selftests/mm/khugepaged.c b/tools/testing/selftests/mm/khugepaged.c
>>> index f69be6be0ecd..64d6da6aa90d 100644
>>> --- a/tools/testing/selftests/mm/khugepaged.c
>>> +++ b/tools/testing/selftests/mm/khugepaged.c
>>> @@ -26,9 +26,11 @@
>>>    #define BASE_ADDR ((void *)(1UL << 30))
>>>   static unsigned long hpage_pmd_size;
>>> +static int hpage_pmd_order;
>>>   static unsigned long page_size;
>>>   static int hpage_pmd_nr;
>>>   static int anon_order;
>>> +static int collapse_order;
>>
>> <snip>
>>
>>>  diff --git a/tools/testing/selftests/mm/run_vmtests.sh b/tools/testing/selftests/mm/run_vmtests.sh
>>> index 687d115e3bd8..d09f9f6a384e 100755
>>> --- a/tools/testing/selftests/mm/run_vmtests.sh
>>> +++ b/tools/testing/selftests/mm/run_vmtests.sh
>>> @@ -410,6 +410,8 @@ CATEGORY="thp" run_test ./khugepaged all:shmem
>>>    CATEGORY="thp" run_test ./khugepaged -s 4 all:shmem
>>>  +CATEGORY="thp" run_test ./khugepaged -c 4 mthp_khugepaged:anon
>>
>> Why only testing collapse_order == 4? It is more useful to test all
>> possible mTHP orders. -c can accept common separated order and a range.
>
> This also follows the previous '-s' parameter configuration, which is used to specify the mTHP order allocation.
>
> I think specifying a single order size already tests the overall mTHP collapse

Got it. If a single order covers the flow, I am fine with it.

> flow, so I'm not sure whether testing all orders is worthwhile. Maybe I can add a few more orders?
> ./khugepaged -c 2 mthp_khugepaged:anon
> ./khugepaged -c 4 mthp_khugepaged:anon
> ./khugepaged -c 8 mthp_khugepaged:anon
>
>> Why only testing mthp_khugepaged:anon? IIRC, file and shmem are not
>> supported, so khugepaged should reject them, right?
>
> Currently, I have not added test cases for shmem mTHP collapse, so adding file or shmem would be no-ops and might mislead others. I will add the shmem/file mTHP collapse feature and test cases in a following patchset.

Right. I mean when one specifies ./khugepaged mthp_khugepaged:file/shmem, the
program should show some error like “file/shmem not supported”.


Best Regards,
Yan, Zi
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.