Re: [PATCH v9 04/10] arm64/hugetlb: drop the init_mm special case in clear_flush()
From: Barry Song
Date: Wed Sep 23 2026 - 17:24:33 EST
On Wed, Sep 23, 2026 at 2:29 PM Wen Jiang <jiangwenxiaomi@xxxxxxxxx> wrote:
>
> clear_flush() calls flush_tlb_kernel_range() when mm is &init_mm. This
> was added by commit 06fc959fcff7 ("arm64/mm: Support huge pte-mapped
> pages in vmap") because vmap called set_huge_pte_at(&init_mm, ...).
>
> Now that vmap uses pte_set_huge()/pte_clear_huge(), mm/vmalloc.c is no
> longer a caller of set_huge_pte_at() on arm64. The only remaining
> callers passing &init_mm are in arch/powerpc, which uses its own
> implementation. Remove the dead branch.
>
> No functional change.
>
> Signed-off-by: Wen Jiang <jiangwen6@xxxxxxxxxx>
LGTM. Please see the comments below.
Reviewed-by: Barry Song <baohua@xxxxxxxxxx>
> ---
> arch/arm64/mm/hugetlbpage.c | 5 +----
> 1 file changed, 1 insertion(+), 4 deletions(-)
>
> diff --git a/arch/arm64/mm/hugetlbpage.c b/arch/arm64/mm/hugetlbpage.c
> index 8e799c1fe0aa6..ce247b06fe03d 100644
> --- a/arch/arm64/mm/hugetlbpage.c
> +++ b/arch/arm64/mm/hugetlbpage.c
> @@ -206,10 +206,7 @@ static void clear_flush(struct mm_struct *mm,
> for (i = 0; i < ncontig; i++, addr += pgsize, ptep++)
> __ptep_get_and_clear_anysz(mm, addr, ptep, pgsize);
>
> - if (mm == &init_mm)
> - flush_tlb_kernel_range(saddr, addr);
> - else
> - __flush_hugetlb_tlb_range(&vma, saddr, addr, pgsize, TLBF_NOWALKCACHE);
> + __flush_hugetlb_tlb_range(&vma, saddr, addr, pgsize, TLBF_NOWALKCACHE);
For the vmap case, we are not mapping over a valid mapping, so there is no
case where `pte_present()` can be true. But I guess we can strengthen the
check in patch 1 by adding a `VM_WARN_ON()` for `pte_valid()` and some
comments.
/* For vmap, there is no valid -> valid transition */
VM_WARN_ON (pte_valid(__ptep_get(ptep)));
Best Regards
Barry