From: "David Hildenbrand (Arm)" <david@kernel.org>
To: Yin Tirui <yintirui@gmail.com>, lorenzo.stoakes@oracle.com
Cc: linux-kernel@vger.kernel.org, linux-mm@kvack.org, x86@kernel.org,
linux-arm-kernel@lists.infradead.org, willy@infradead.org,
jgross@suse.com, catalin.marinas@arm.com, will@kernel.org,
tglx@kernel.org, mingo@redhat.com, bp@alien8.de,
dave.hansen@linux.intel.com, hpa@zytor.com, luto@kernel.org,
peterz@infradead.org, akpm@linux-foundation.org, ziy@nvidia.com,
baolin.wang@linux.alibaba.com, Liam.Howlett@oracle.com,
npache@redhat.com, ryan.roberts@arm.com, dev.jain@arm.com,
baohua@kernel.org, lance.yang@linux.dev, vbabka@suse.cz,
rppt@kernel.org, surenb@google.com, mhocko@suse.com,
anshuman.khandual@arm.com, rmclure@linux.ibm.com,
kevin.brodsky@arm.com, apopple@nvidia.com, ajd@linux.ibm.com,
pasha.tatashin@soleen.com, bhe@redhat.com, thuth@redhat.com,
coxu@redhat.com, dan.j.williams@intel.com, yu-cheng.yu@intel.com,
baolu.lu@linux.intel.com, conor.dooley@microchip.com,
Jonathan.Cameron@huawei.com, riel@surriel.com,
wangkefeng.wang@huawei.com, chenjun102@huawei.com
Subject: Re: [RESEND] Re: [PATCH RFC v3 4/4] mm: add PMD-level huge page support for remap_pfn_range()
Date: Mon, 27 Apr 2026 22:32:40 +0200 [thread overview]
Message-ID: <67a655e3-fa23-4d2a-9685-14e6221d5d26@kernel.org> (raw)
In-Reply-To: <39dac497-220c-4e71-9d3e-d9cf32357400@gmail.com>
>>> + pte_t entry;
>>> +
>>> + if (!pmd_special(old_pmd)) {
>>
>> If you are using pmd_special(), you are doing something wrong.
>>
>> Hint: vm_normal_page_pmd() is usually what you want.
>
> Spot on.
>
> While looking into applying vm_normal_folio_pmd() here to avoid the
> magical VMA checks, I realized that both __split_huge_pmd_locked() and
> copy_huge_pmd() currently suffer from the same !vma_is_anonymous(vma)
> top-level entanglement.
Yes, that code is an absolute mess.
> I think these functions could benefit from a
> structural refactoring similar to what Lorenzo is currently doing in
> zap_huge_pmd().
>
> My idea is to flatten both functions into a pmd_present()-driven
> decision tree:
Likely similar to how we handle PTEs.
> 1. Branch strictly on pmd_present().
> 2. For present PMDs, use vm_normal_folio_pmd() as the single source of
> truth.
> 3. If !folio (and not a huge zero page), it cleanly identifies special
> mappings (like PFNMAPs) without relying on vma_is_special_huge(). We can
> handle the split/copy directly and return early.
> 4. Otherwise, proceed with the normal Anon/File THP logic, or handle
> non-present migration entries in the !pmd_present() branch.
Yes, that sounds about right.
>
> I have drafted two preparation patches demonstrating this approach and
> appended the diffs at the end of this email. Does this direction look
> reasonable to you? If so, I will iron out the implementation details and
> include these refactoring patches in my upcoming v4 series.
>
Yes, sounds like nice cleanups.
Maybe the code could then benefit from moving the present vs. non-present
handling into separate functions? Just a thought.
--
Cheers,
David
prev parent reply other threads:[~2026-04-27 20:33 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-02-28 7:09 [PATCH RFC v3 0/4] mm: add huge pfnmap support for remap_pfn_range() Yin Tirui
2026-02-28 7:09 ` [PATCH RFC v3 1/4] x86/mm: Use proper page table helpers for huge page generation Yin Tirui
2026-03-06 9:29 ` Jonathan Cameron
2026-03-10 3:23 ` Yin Tirui
2026-02-28 7:09 ` [PATCH RFC v3 2/4] mm/pgtable: Make pfn_pte() filter out huge page attributes Yin Tirui
2026-03-04 7:52 ` Jürgen Groß
2026-03-04 10:08 ` Yin Tirui
2026-03-05 9:38 ` Yin Tirui
2026-03-05 10:05 ` Jürgen Groß
2026-03-10 3:32 ` Yin Tirui
2026-03-06 4:25 ` Matthew Wilcox
2026-03-10 3:36 ` Yin Tirui
2026-04-20 8:48 ` Will Deacon
2026-04-20 11:43 ` Yin Tirui
2026-02-28 7:09 ` [PATCH RFC v3 3/4] x86/mm: Remove pte_clrhuge() and clean up init_64.c Yin Tirui
2026-02-28 7:09 ` [PATCH RFC v3 4/4] mm: add PMD-level huge page support for remap_pfn_range() Yin Tirui
2026-04-13 20:02 ` David Hildenbrand (Arm)
2026-04-19 11:41 ` [RESEND] " Yin Tirui
2026-04-27 20:32 ` David Hildenbrand (Arm) [this message]
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=67a655e3-fa23-4d2a-9685-14e6221d5d26@kernel.org \
--to=david@kernel.org \
--cc=Jonathan.Cameron@huawei.com \
--cc=Liam.Howlett@oracle.com \
--cc=ajd@linux.ibm.com \
--cc=akpm@linux-foundation.org \
--cc=anshuman.khandual@arm.com \
--cc=apopple@nvidia.com \
--cc=baohua@kernel.org \
--cc=baolin.wang@linux.alibaba.com \
--cc=baolu.lu@linux.intel.com \
--cc=bhe@redhat.com \
--cc=bp@alien8.de \
--cc=catalin.marinas@arm.com \
--cc=chenjun102@huawei.com \
--cc=conor.dooley@microchip.com \
--cc=coxu@redhat.com \
--cc=dan.j.williams@intel.com \
--cc=dave.hansen@linux.intel.com \
--cc=dev.jain@arm.com \
--cc=hpa@zytor.com \
--cc=jgross@suse.com \
--cc=kevin.brodsky@arm.com \
--cc=lance.yang@linux.dev \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=lorenzo.stoakes@oracle.com \
--cc=luto@kernel.org \
--cc=mhocko@suse.com \
--cc=mingo@redhat.com \
--cc=npache@redhat.com \
--cc=pasha.tatashin@soleen.com \
--cc=peterz@infradead.org \
--cc=riel@surriel.com \
--cc=rmclure@linux.ibm.com \
--cc=rppt@kernel.org \
--cc=ryan.roberts@arm.com \
--cc=surenb@google.com \
--cc=tglx@kernel.org \
--cc=thuth@redhat.com \
--cc=vbabka@suse.cz \
--cc=wangkefeng.wang@huawei.com \
--cc=will@kernel.org \
--cc=willy@infradead.org \
--cc=x86@kernel.org \
--cc=yintirui@gmail.com \
--cc=yu-cheng.yu@intel.com \
--cc=ziy@nvidia.com \
/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