Re: [PATCH] mm/page_vma_mapped: guard check_pmd() with CONFIG_TRANSPARENT_HUGEPAGE
From: Wei Yang
Date: Thu Sep 03 2026 - 22:03:30 EST
On Wed, Sep 02, 2026 at 08:02:20PM -0700, Andrew Morton wrote:
>On Wed, 24 Jun 2026 08:23:59 +0000 Wei Yang <richard.weiyang@xxxxxxxxx> wrote:
>
>> The kernel test robot reported a build failure on the parisc architecture
>> when expanding HPAGE_PMD_NR in check_pmd().
>>
>> mm/page_vma_mapped.c:142:13: note: in expansion of macro 'HPAGE_PMD_NR'
>> if ((pfn + HPAGE_PMD_NR - 1) < pvmw->pfn)
>> ^~~~~~~~~~~~
>>
>> The config [1] in report link shows neither TRANSPARENT_HUGEPAGE nor
>> HUGETLB_PAGE is defined. Then trigger the BUILD_BUG.
>>
>> Fix it by define check_pmd() under CONFIG_TRANSPARENT_HUGEPAGE.
>>
>> [1]: https://download.01.org/0day-ci/archive/20260624/202606240042.ffPsEXVc-lkp@xxxxxxxxx/config
>>
>> Fixes: 2aff7a4755be ("mm: Convert page_vma_mapped_walk to work on PFNs")
>> Signed-off-by: Wei Yang <richard.weiyang@xxxxxxxxx>
>> Reported-by: kernel test robot <lkp@xxxxxxxxx>
>> Closes: https://lore.kernel.org/oe-kbuild-all/202606240042.ffPsEXVc-lkp@xxxxxxxxx/
>>
>> ...
>>
>> --- a/mm/page_vma_mapped.c
>> +++ b/mm/page_vma_mapped.c
>> @@ -136,6 +136,7 @@ static bool check_pte(struct page_vma_mapped_walk *pvmw, unsigned long pte_nr)
>> return true;
>> }
>>
>> +#ifdef CONFIG_TRANSPARENT_HUGEPAGE
>> /* Returns true if the two ranges overlap. Careful to not overflow. */
>> static bool check_pmd(unsigned long pfn, struct page_vma_mapped_walk *pvmw)
>> {
>> @@ -145,6 +146,12 @@ static bool check_pmd(unsigned long pfn, struct page_vma_mapped_walk *pvmw)
>> return false;
>> return true;
>> }
>> +#else
>> +static bool check_pmd(unsigned long pfn, struct page_vma_mapped_walk *pvmw)
>> +{
>> + return false;
>> +}
>> +#endif
>>
>> static void step_forward(struct page_vma_mapped_walk *pvmw, unsigned long size)
>> {
>
>lgtm, thanks.
>
>You provoked Sashiko into talking about memory corruption and kernel
>panics in page_vma_mapped.c. Usual stuff.
>
> https://sashiko.dev/#/patchset/20260624082359.2869-1-richard.weiyang@xxxxxxxxx
>
Hi, Andrew
IIUC, the issue reported by Sashiko is fixed by
commit f84ca9b1888d ("mm/page_vma_mapped: fix device-private PMD handling")
>I'll cc likely suspects but boy do we need a way of being more
>organized about this.
The build error fixed here is introduced by v3 [1], in which check_pmd() is
invoked outside a conditional "if".
Then v4 [2] and v5 [3] call check_pmd() in a conditional "if" and at last
David fix this with IS_ENABLED(CONFIG_TRANSPARENT_HUGEPAGE).
Do you suggest still conditionally define check_pmd()? I may not follow your
point.
Have a good day.
[1]: https://lore.kernel.org/all/20260622130651.23359-1-richard.weiyang@xxxxxxxxx/
[2]: https://lore.kernel.org/all/20260624065353.1622-1-richard.weiyang@xxxxxxxxx/T/#u
[3]: https://lore.kernel.org/linux-mm/20260630021540.17297-1-richard.weiyang@xxxxxxxxx/
--
Wei Yang
Help you, Help me