On Fri, Aug 29, 2025 at 08:09:53PM -0700, Andrew Morton wrote:
>On Sat, 30 Aug 2025 02:31:02 +0000 Wei Yang <richard.weiy...@gmail.com> wrote:
>
>> The check of is_backed_by_folio() is done on each page.
>> 
>> Directly move pointer to next page instead of increase one and check if
>> it is page size aligned.
>
>Why?
>
>> --- a/tools/testing/selftests/mm/split_huge_page_test.c
>> +++ b/tools/testing/selftests/mm/split_huge_page_test.c
>> @@ -423,9 +423,8 @@ static void split_pte_mapped_thp(void)
>>  
>>      /* smap does not show THPs after mremap, use kpageflags instead */
>>      thp_size = 0;
>> -    for (i = 0; i < pagesize * 4; i++)
>> -            if (i % pagesize == 0 &&
>> -                is_backed_by_folio(&pte_mapped[i], pmd_order, pagemap_fd, 
>> kpageflags_fd))
>> +    for (i = 0; i < pagesize * 4; i += pagesize)
>> +            if (is_backed_by_folio(&pte_mapped[i], pmd_order, pagemap_fd, 
>> kpageflags_fd))
>>                      thp_size++;
>
>Looks like we're doing more work.  Is there something wrong with the
>existing code?

Excuse me if I misunderstand the code.

Originally, i iterate from 0 to pagesize * 4 one by one and call
is_backed_by_folio() when i is 0, 4096, 8192, 12288.

The change makes i just iterate on 0, 4096, 8192, 12288 and call
is_backed_by_folio() respectively.

Current code is not wrong, but not necessary to iterate one by one.

-- 
Wei Yang
Help you, Help me

Reply via email to