On Thu, 24 Sept 2026 at 05:30, Barry Song <[email protected]> wrote: > > On Wed, Sep 23, 2026 at 2:28 PM Wen Jiang <[email protected]> wrote: > > > > vmap installs PTE-level block mappings (PTE_CONT on arm64) by reusing > > set_huge_pte_at() and huge_ptep_get_and_clear(), which are HugeTLB > > helpers gated by CONFIG_HUGETLB_PAGE. This makes the feature silently > > unavailable on CONFIG_HUGETLB_PAGE=n kernels and couples mm/vmalloc.c to > > HugeTLB internals it does not otherwise need. > > > > Add pte_set_huge()/pte_clear_huge() to arm64, joining the existing > > pmd_set_huge()/pud_set_huge() family in mm/mmu.c. They build on > > __set_ptes() and __get_and_clear_full_ptes() directly, so they do not > > depend on CONFIG_HUGETLB_PAGE. > > > > There is no caller yet: mm/vmalloc.c is converted later in this series, > > once the generic fallbacks are in place. > > > > Signed-off-by: Wen Jiang <[email protected]> > > LGTM. Please see the comment below. > > Reviewed-by: Barry Song <[email protected]> > > [...] > > > +void pte_set_huge(pte_t *ptep, unsigned long addr, phys_addr_t phys, > > + pgprot_t prot, unsigned long size) > > +{ > > + unsigned long pfn = __phys_to_pfn(phys); > > + pte_t pte = pte_mkcont(pfn_pte(pfn, prot)); > > + unsigned int nr = size >> PAGE_SHIFT; > > + > > + VM_WARN_ON(!IS_ALIGNED(size, CONT_PTE_SIZE)); > > + VM_WARN_ON(!IS_ALIGNED(addr, CONT_PTE_SIZE)); > > + VM_WARN_ON(!IS_ALIGNED(pfn, CONT_PTES)); > > + > > + __set_ptes(&init_mm, addr, ptep, pte, nr); > > You have patch 4 to revert the `clear_flush()` modification from > 06fc959fcff ("arm64/mm: Support huge pte-mapped pages in vmap"). > > I guess you may still need to guard against the case I mentioned in my > reply to patch 4: > https://lore.kernel.org/linux-mm/cagsj_4xilscr2prpu7eem73gvpctsuyd3j05kw3sc4qss5q...@mail.gmail.com/ > > Something like this: > VM_WARN_ON (pte_valid(__ptep_get(ptep))); >
Hi Barry, Agreed. I'll add this. The vmap path should never see a valid→valid transition, but an explicit assert makes that contract visible. Thanks, Wen.
