Re: [PATCH 28/39] mm: drop some redundant checks around hugetlb VMAs
From: Marc Zyngier
Date: Wed Sep 09 2026 - 08:24:40 EST
On Tue, 08 Sep 2026 21:01:32 +0100,
"Lorenzo Stoakes (ARM)" <ljs@xxxxxxxxxx> wrote:
>
> Adjust code which inadvertently perform redundant checks on hugetlb VMAs
> and clean them up:
>
> * hugetlb VMAs have VMA_DONTEXPAND_BIT set so a VMA_SPECIAL_FLAGS check
> suffices. (migrate_vma_setup() regains an explicit hugetlb test later in
> the series, once VMA_SPECIAL_FLAGS is removed.)
>
> * hugetlb VMAs unconditionally set vma->vm_ops, so they are never
> anonymous.
>
> * hugetlb VMAs do not set VMA_PFNMAP_BIT so checking for this is redundant.
>
> While we're here also drop a VM_BUG_ON() which the simplified check above
> makes unreachable, and use the new VMA flag API.
>
> No functional change intended.
>
> Signed-off-by: Lorenzo Stoakes (ARM) <ljs@xxxxxxxxxx>
> ---
> arch/arm64/kvm/mmu.c | 4 +---
> drivers/gpu/drm/drm_gpusvm.c | 3 +--
> mm/migrate_device.c | 4 ++--
> 3 files changed, 4 insertions(+), 7 deletions(-)
>
> diff --git a/arch/arm64/kvm/mmu.c b/arch/arm64/kvm/mmu.c
> index a7968f8d24bf..3c1240ffc38d 100644
> --- a/arch/arm64/kvm/mmu.c
> +++ b/arch/arm64/kvm/mmu.c
> @@ -1463,14 +1463,12 @@ static int get_vma_page_shift(struct vm_area_struct *vma, unsigned long hva)
> {
> unsigned long pa;
>
> - if (vma_is_hugetlb(vma) && !(vma->vm_flags & VM_PFNMAP))
> + if (vma_is_hugetlb(vma))
> return huge_page_shift(hstate_vma(vma));
>
> if (!(vma->vm_flags & VM_PFNMAP))
> return PAGE_SHIFT;
>
> - VM_BUG_ON(vma_is_hugetlb(vma));
> -
> pa = (vma->vm_pgoff << PAGE_SHIFT) + (hva - vma->vm_start);
>
> #ifndef __PAGETABLE_PMD_FOLDED
Acked-by: Marc Zyngier <maz@xxxxxxxxxx>
M.
--
Without deviation from the norm, progress is not possible.