Re: [PATCH] mm/page_vma_mapped: guard check_pmd() with CONFIG_TRANSPARENT_HUGEPAGE

From: Andrew Morton

Date: Wed Jun 24 2026 - 16:15:07 EST


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.

hm,

#ifdef CONFIG_PGTABLE_HAS_HUGE_LEAVES
#define HPAGE_PMD_SHIFT PMD_SHIFT
#define HPAGE_PUD_SHIFT PUD_SHIFT
#else
#define HPAGE_PMD_SHIFT ({ BUILD_BUG(); 0; })
#define HPAGE_PUD_SHIFT ({ BUILD_BUG(); 0; })
#endif

> +#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

I'll leave it to others to decide if this is the most appropriate fix.

Sashiko had an off-topic complaint about the surrounding code:
https://lore.kernel.org/oe-kbuild-all/202606240042.ffPsEXVc-lkp@xxxxxxxxx/