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

From: Lorenzo Stoakes

Date: Thu Jun 25 2026 - 09:45:39 EST


On Wed, Jun 24, 2026 at 08:23:59AM +0000, Wei Yang wrote:
> The kernel test robot reported a build failure on the parisc architecture
> when expanding HPAGE_PMD_NR in check_pmd().

Let me first say that I absolutely hate that we continue to support museum
piece architectures to the point that we have to make changes in core code
to accommodate them.

It's not unreasonable to ask retro people to either use older kernels or
make a downstream fork.

People having to think about this upstream is so incredibly silly. As if we
don't have enough work already...

Anyway, with that said...

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

I think the fact this wasn't detected for 4 odd years goes to show how well
tested stuff on this arch is... (unless this is a very unusual
configuration at least).

>
> 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/
> ---
> mm/page_vma_mapped.c | 7 +++++++
> 1 file changed, 7 insertions(+)
>
> diff --git a/mm/page_vma_mapped.c b/mm/page_vma_mapped.c
> index 17dff8aab9f9..4aac94d9e8a9 100644
> --- 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

As per Andrew, this should be CONFIG_PGTABLE_HAS_HUGE_LEAVES I think.

I don't like that CONFIG_T..HP is taken to mean 'anything to do with leaf
page tables'. That's a mess and one we should unwind.

So don't make it worse, use CONFIG_PGTABLE_HAS_HUGE_LEAVES.

> /* 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;

Should have a WARN_ON_ONCE("bug in stupid arch") or similar here ;)

> +}
> +#endif
>
> static void step_forward(struct page_vma_mapped_walk *pvmw, unsigned long size)
> {
> --
> 2.34.1
>

Thanks, Lorenzo