On 29 Oct 2026, at 20:07, Ritesh Harjani (IBM) wrote:
> Unmapping a device-dax mapping with 1G alignment on powerpc radix kernel
> built with CONFIG_DEBUG_VM triggers this warning on every munmap:
>
> WARNING: mm/mmu_gather.c:176 at __tlb_remove_folio_pages_size+0x38/0x230
> NIP [c00000000063d508] __tlb_remove_folio_pages_size+0x38/0x230
> LR [c0000000006fb688] zap_huge_pud+0x1b8/0x2d0
> Call Trace:
> zap_huge_pud+0x170/0x2d0 (unreliable)
> __zap_vma_range+0x1604/0x1e20
> unmap_vmas+0xa0/0x1f0
> unmap_region+0xb0/0x130
> vms_complete_munmap_vmas+0x120/0x310
> do_vmi_align_munmap+0x1ec/0x240
> __vm_munmap+0x148/0x220
> sys_munmap+0x28/0x40
>
> To trigger this - it is enough to mmap() /dev/dax0.0, touch the first
> byte so that the whole 1G is mapped by a single PUD and then munmap()
> it.
>
> PowerPC needs MMU_GATHER_PAGE_SIZE in which mmu_gather needs to record
> the page size for which tlb flush is needed. zap_huge_pmd(),
> zap_pte_range(), change_huge_pud() etc all do this already. However,
> since commit:
> dbe54153296d ("mm/huge_memory: add vmf_insert_folio_pud()")
>
> a device-dax PUD maps a real folio and zap_huge_pud() now hands it to
> tlb_remove_page_size(tlb, page, HPAGE_PUD_SIZE). At that point
> tlb->page_size is still whatever the previous user left behind, which is
> 0 for the fresh gather set up by munmap() and so the check fires.
>
> Fix this in the same way like how other similar paths do.
>
> Fixes: dbe54153296d0 ("mm/huge_memory: add vmf_insert_folio_pud()")
> Reported-by: Pavithra <[email protected]>
> Signed-off-by: Ritesh Harjani (IBM) <[email protected]>
> ---
> [v1]->v2:
> =========
> - Split the 2 part patch series. Patch-1 is now superseded by a different
> patch
> from Muchun which he already posted [2].
> - No difference in this patch from v1.
>
> [v1]:
> https://lore.kernel.org/all/97f85592bb78a273be8519e6897e7f9b9bd31469.1793070429.git.ritesh.l...@gmail.com/
> [2]:
> https://lore.kernel.org/all/[email protected]/
>
> mm/huge_memory.c | 2 ++
> 1 file changed, 2 insertions(+)
>
Makes sense. Thanks.
Acked-by: Zi Yan <[email protected]>
Best Regards,
Yan, Zi