Re: [PATCH 1/1] selftests: mm: hugepage-vmemmap fails on 64K page size systems.

From: Muchun Song
Date: Wed Jan 10 2024 - 21:08:48 EST




> On Jan 10, 2024, at 23:53, Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx> wrote:
>
> (cc Muchun)
> On Wed, 10 Jan 2024 14:03:35 +0530 Donet Tom <donettom@xxxxxxxxxxxxxxxxxx> wrote:
>
>> The kernel sefltest mm/hugepage-vmemmap fails on architectures
>> which has different page size other than 4K. In hugepage-vmemmap
>> page size used is 4k so the pfn calculation will go wrong on systems
>> which has different page size .The length of MAP_HUGETLB memory must
>> be hugepage aligned but in hugepage-vmemmap map length is 2M so this
>> will not get aligned if the system has differnet hugepage size.
>>
>> Added psize() to get the page size and default_huge_page_size() to
>> get the default hugepage size at run time, hugepage-vmemmap test pass
>> on powerpc with 64K page size and x86 with 4K page size.
>>
>> Result on powerpc without patch (page size 64K)
>> *# ./hugepage-vmemmap
>> Returned address is 0x7effff000000 whose pfn is 0
>> Head page flags (100000000) is invalid
>> check_page_flags: Invalid argument
>> *#
>>
>> Result on powerpc with patch (page size 64K)
>> *# ./hugepage-vmemmap
>> Returned address is 0x7effff000000 whose pfn is 600
>> *#
>>
>> Result on x86 with patch (page size 4K)
>> *# ./hugepage-vmemmap
>> Returned address is 0x7fc7c2c00000 whose pfn is 1dac00
>> *#
>>
>> Signed-off-by: Donet Tom <donettom@xxxxxxxxxxxxxxxxxx>
>> Reported-by : Geetika Moolchandani (geetika@xxxxxxxxxxxxx)
>> Tested-by : Geetika Moolchandani (geetika@xxxxxxxxxxxxx)

Acked-by: Muchun Song <muchun.song@xxxxxxxxx>

>
> I'll add
>
> Fixes: b147c89cd429 ("selftests: vm: add a hugetlb test case")
> Cc: <stable@xxxxxxxxxxxxxxx>

Yes. It should be a real bug fix.

Thanks.