Re: [PATCH v9 04/10] arm64/hugetlb: drop the init_mm special case in clear_flush()
From: Barry Song <baohua@kernel.org>
Date: 2026-09-23 21:23:43
Also in:
linux-mm, linuxppc-dev, lkml
On Wed, Sep 23, 2026 at 2:29 PM Wen Jiang [off-list ref] 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 <redacted>LGTM. Please see the comments below. Reviewed-by: Barry Song <baohua@kernel.org>
quoted hunk ↗ jump to hunk
--- 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