mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Christophe Leroy (CS GROUP)" <chleroy@kernel.org>
To: Wen Jiang <jiangwenxiaomi@gmail.com>,
	akpm@linux-foundation.org, catalin.marinas@arm.com,
	linux-mm@kvack.org, urezki@gmail.com, will@kernel.org
Cc: Xueyuan.chen21@gmail.com, ajd@linux.ibm.com,
	anshuman.khandual@arm.com, baohua@kernel.org, david@kernel.org,
	dev.jain@arm.com, jiangwen6@xiaomi.com, leo.yan@arm.com,
	linux-arm-kernel@lists.infradead.org,
	linux-kernel@vger.kernel.org, linuxppc-dev@lists.ozlabs.org,
	maddy@linux.ibm.com, mpe@ellerman.id.au, npiggin@gmail.com,
	rppt@kernel.org, ryan.roberts@arm.com
Subject: Re: [PATCH v8 02/10] powerpc/8xx: add pte_set_huge()
Date: Fri, 18 Sep 2026 08:14:31 +0200	[thread overview]
Message-ID: <58e3b456-7389-4752-8de5-1cc82964c3c7@kernel.org> (raw)
In-Reply-To: <20260917052933.188679-3-jiangwenxiaomi@gmail.com>



Le 17/09/2026 à 07:29, Wen Jiang a écrit :
> From: Wen Jiang <jiangwen6@xiaomi.com>
> 
> vmap installs PTE-level block mappings (SZ_16K/SZ_512K on powerpc/8xx)
> by reusing set_huge_pte_at(), a HugeTLB helper 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() to powerpc/8xx, next to the existing
> pmd_clear_huge()/pud_clear_huge() in mm/nohash/8xx.c. It builds the huge
> PTE and writes it into the backing cells directly, without going through
> set_huge_pte_at(), so it does not depend on CONFIG_HUGETLB_PAGE.
> 
> No pte_clear_huge() is needed: 8xx does not implement
> arch_vmap_pte_range_unmap_size(), so the vmap unmap path never takes the
> block-mapping branch.
> 
> In practice PPC_8xx selects HUGETLBFS unconditionally, so
> CONFIG_HUGETLB_PAGE=n does not occur there today; this is a decoupling
> cleanup rather than a new configuration.

8xx selects CONFIG_HUGETLB_PAGE because it uses set_huge_pte_at() to map 
kernel text with large pages. That was added by commit 34536d780683 
("powerpc/8xx: Add a function to early map kernel via huge pages")

But now pte_set_huge() could be used instead in 
__early_map_kernel_hugepage() and then CONFIG_HUGETLB_PAGE could be removed.

> 
> 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 <jiangwen6@xiaomi.com>

Reviewed-by: Christophe Leroy (CS GROUP) <chleroy@kernel.org>

> ---
>   arch/powerpc/include/asm/nohash/32/pte-8xx.h |  4 +++
>   arch/powerpc/mm/nohash/8xx.c                 | 29 ++++++++++++++++++++
>   2 files changed, 33 insertions(+)
> 
> diff --git a/arch/powerpc/include/asm/nohash/32/pte-8xx.h b/arch/powerpc/include/asm/nohash/32/pte-8xx.h
> index e2ea8ba9f8cae..1ee3f8f0de974 100644
> --- a/arch/powerpc/include/asm/nohash/32/pte-8xx.h
> +++ b/arch/powerpc/include/asm/nohash/32/pte-8xx.h
> @@ -235,6 +235,10 @@ static inline pte_t ptep_get(pte_t *ptep)
>   }
>   #endif /* CONFIG_PPC_16K_PAGES */
>   
> +#define __HAVE_ARCH_PTE_SET_HUGE
> +void pte_set_huge(pte_t *ptep, unsigned long addr, phys_addr_t phys,
> +		  pgprot_t prot, unsigned long size);
> +
>   #endif
>   
>   #endif /* __KERNEL__ */
> diff --git a/arch/powerpc/mm/nohash/8xx.c b/arch/powerpc/mm/nohash/8xx.c
> index a9d3f4729eada..2518d2a6bdb41 100644
> --- a/arch/powerpc/mm/nohash/8xx.c
> +++ b/arch/powerpc/mm/nohash/8xx.c
> @@ -220,3 +220,32 @@ int pmd_clear_huge(pmd_t *pmd)
>   {
>   	 return 0;
>   }
> +
> +/*
> + * vmap PTE-level block mapping. Sets a present kernel mapping directly,
> + * so unlike set_huge_pte_at() it needs neither CONFIG_HUGETLB_PAGE nor
> + * set_pte_filter() (a no-op for non-exec kernel mappings).
> + */
> +void pte_set_huge(pte_t *ptep, unsigned long addr, phys_addr_t phys,
> +		  pgprot_t prot, unsigned long size)
> +{
> +	pmd_t *pmdp = pmd_off(&init_mm, addr);
> +	pte_t pte = pfn_pte(PHYS_PFN(phys), prot);
> +	pte_basic_t val;
> +	pte_basic_t *entry = (pte_basic_t *)ptep;
> +	int num, i;
> +
> +	pte = arch_make_huge_pte(pte, ilog2(size), 0);
> +	val = pte_val(pte);
> +
> +	/*
> +	 * Make sure hardware valid bit is not set. We don't do
> +	 * tlb flush for this update.
> +	 */
> +	VM_WARN_ON(pte_hw_valid(*ptep) && !pte_protnone(*ptep));
> +
> +	num = number_of_cells_per_pte(pmdp, val, 1);
> +
> +	for (i = 0; i < num; i++, entry++, val += SZ_4K)
> +		*entry = val;
> +}


  parent reply	other threads:[~2026-09-18  6:14 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-17  5:29 [PATCH v8 00/10] mm/vmalloc: Speed up ioremap, vmalloc and vmap with contiguous memory Wen Jiang
2026-09-17  5:29 ` [PATCH v8 01/10] arm64/mm: add pte_set_huge() and pte_clear_huge() Wen Jiang
2026-09-17 23:22   ` Barry Song
2026-09-18  7:48     ` Wen Jiang
2026-09-17  5:29 ` [PATCH v8 02/10] powerpc/8xx: add pte_set_huge() Wen Jiang
2026-09-17 23:28   ` Barry Song
2026-09-18  8:20     ` Wen Jiang
2026-09-18  6:14   ` Christophe Leroy (CS GROUP) [this message]
2026-09-18  8:44     ` Barry Song
2026-09-18  9:11       ` Christophe Leroy (CS GROUP)
2026-09-17  5:29 ` [PATCH v8 03/10] mm/vmalloc: use pte_set_huge()/pte_clear_huge() for PTE-level block mappings Wen Jiang
2026-09-17 14:00   ` Christophe Leroy (CS GROUP)
2026-09-17 14:40     ` Wen Jiang
2026-09-17 21:44       ` Barry Song
2026-09-18  6:05         ` Christophe Leroy (CS GROUP)
2026-09-18  6:14           ` Barry Song
2026-09-18  7:03             ` Christophe Leroy (CS GROUP)
2026-09-18  8:37               ` Wen Jiang
2026-09-17  5:29 ` [PATCH v8 04/10] arm64/hugetlb: drop the init_mm special case in clear_flush() Wen Jiang
2026-09-17  5:29 ` [PATCH v8 05/10] arm64/vmalloc: allow arch_vmap_pte_range_map_size() to batch multiple CONT_PTE Wen Jiang
2026-09-17  5:29 ` [PATCH v8 06/10] mm/vmalloc: extract vmap_set_ptes() to consolidate PTE mapping logic Wen Jiang
2026-09-17  5:29 ` [PATCH v8 07/10] mm/vmalloc: extend page table walk to support larger page_shift sizes and eliminate page table rewalk Wen Jiang
2026-09-17  5:29 ` [PATCH v8 08/10] mm/vmalloc: extract vm_shift() to consolidate mapping shift selection Wen Jiang
2026-09-17  5:29 ` [PATCH v8 09/10] mm/vmalloc: map contiguous pages in batches for vmap() if possible Wen Jiang
2026-09-17  5:29 ` [PATCH v8 10/10] mm/vmalloc: align vm_area so vmap() can batch mappings Wen Jiang
2026-09-17 12:17 ` [PATCH v8 00/10] mm/vmalloc: Speed up ioremap, vmalloc and vmap with contiguous memory Christophe Leroy (CS GROUP)
2026-09-17 13:55   ` Christophe Leroy (CS GROUP)
2026-09-17 14:30     ` Wen Jiang

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=58e3b456-7389-4752-8de5-1cc82964c3c7@kernel.org \
    --to=chleroy@kernel.org \
    --cc=Xueyuan.chen21@gmail.com \
    --cc=ajd@linux.ibm.com \
    --cc=akpm@linux-foundation.org \
    --cc=anshuman.khandual@arm.com \
    --cc=baohua@kernel.org \
    --cc=catalin.marinas@arm.com \
    --cc=david@kernel.org \
    --cc=dev.jain@arm.com \
    --cc=jiangwen6@xiaomi.com \
    --cc=jiangwenxiaomi@gmail.com \
    --cc=leo.yan@arm.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=linuxppc-dev@lists.ozlabs.org \
    --cc=maddy@linux.ibm.com \
    --cc=mpe@ellerman.id.au \
    --cc=npiggin@gmail.com \
    --cc=rppt@kernel.org \
    --cc=ryan.roberts@arm.com \
    --cc=urezki@gmail.com \
    --cc=will@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®