[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <f8571506-30c0-4dc8-9995-41a6469f8fc7@redhat.com>
Date: Wed, 24 Sep 2025 11:50:58 +0200
From: David Hildenbrand <david@...hat.com>
To: Yin Tirui <yintirui@...wei.com>, akpm@...ux-foundation.org,
lorenzo.stoakes@...cle.com, Liam.Howlett@...cle.com, vbabka@...e.cz,
rppt@...nel.org, surenb@...gle.com, mhocko@...e.com, ziy@...dia.com,
baolin.wang@...ux.alibaba.com, npache@...hat.com, ryan.roberts@....com,
dev.jain@....com, baohua@...nel.org, catalin.marinas@....com,
will@...nel.org, paul.walmsley@...ive.com, palmer@...belt.com,
aou@...s.berkeley.edu, alex@...ti.fr, anshuman.khandual@....com,
yangyicong@...ilicon.com, ardb@...nel.org, willy@...radead.org,
apopple@...dia.com, samuel.holland@...ive.com, luxu.kernel@...edance.com,
abrestic@...osinc.com, yongxuan.wang@...ive.com, linux-mm@...ck.org,
linux-kernel@...r.kernel.org, linux-arm-kernel@...ts.infradead.org,
linux-riscv@...ts.infradead.org
Cc: wangkefeng.wang@...wei.com, chenjun102@...wei.com
Subject: Re: [PATCH RFC 2/2] mm: add PMD-level huge page support for
remap_pfn_range()
On 23.09.25 15:31, Yin Tirui wrote:
> Add PMD-level huge page support to remap_pfn_range(), automatically
> creating huge mappings when prerequisites are satisfied (size, alignment,
> architecture support, etc.) and falling back to normal page mappings
> otherwise.
>
> Implement special huge PMD splitting by utilizing the pgtable deposit/
> withdraw mechanism. When splitting is needed, the deposited pgtable is
> withdrawn and populated with individual PTEs created from the original
> huge mapping, using pte_clrhuge() to clear huge page attributes.
>
> Update arch_needs_pgtable_deposit() to return true when PMD pfnmap
> support is enabled, ensuring proper pgtable management for huge
> pfnmap operations.
>
> Introduce pfnmap_max_page_shift parameter to control maximum page
> size and "nohugepfnmap" boot option to disable huge pfnmap entirely.
Why? If an arch supports it we should just do it. Or what's the reason
behind that?
>
> Signed-off-by: Yin Tirui <yintirui@...wei.com>
> ---
> include/linux/pgtable.h | 6 +++-
> mm/huge_memory.c | 22 ++++++++----
> mm/memory.c | 74 ++++++++++++++++++++++++++++++++++++-----
> 3 files changed, 85 insertions(+), 17 deletions(-)
>
> diff --git a/include/linux/pgtable.h b/include/linux/pgtable.h
> index 4c035637eeb7..4028318552ca 100644
> --- a/include/linux/pgtable.h
> +++ b/include/linux/pgtable.h
> @@ -1025,7 +1025,11 @@ extern pgtable_t pgtable_trans_huge_withdraw(struct mm_struct *mm, pmd_t *pmdp);
> #endif
>
> #ifndef arch_needs_pgtable_deposit
> -#define arch_needs_pgtable_deposit() (false)
> +#define arch_needs_pgtable_deposit arch_needs_pgtable_deposit
> +static inline bool arch_needs_pgtable_deposit(void)
> +{
> + return IS_ENABLED(CONFIG_ARCH_SUPPORTS_PMD_PFNMAP);
> +}
> #endif
>
> #ifdef CONFIG_TRANSPARENT_HUGEPAGE
> diff --git a/mm/huge_memory.c b/mm/huge_memory.c
> index 9c38a95e9f09..9f20adcbbb55 100644
> --- a/mm/huge_memory.c
> +++ b/mm/huge_memory.c
> @@ -2857,14 +2857,22 @@ static void __split_huge_pmd_locked(struct vm_area_struct *vma, pmd_t *pmd,
>
> if (!vma_is_anonymous(vma)) {
> old_pmd = pmdp_huge_clear_flush(vma, haddr, pmd);
> - /*
> - * We are going to unmap this huge page. So
> - * just go ahead and zap it
> - */
> - if (arch_needs_pgtable_deposit())
> - zap_deposited_table(mm, pmd);
Are you sure we can just entirely remove this block for
!vma_is_anonymous(vma)?
--
Cheers
David / dhildenb
Powered by blists - more mailing lists