From: Yin Tirui <yintirui@huawei.com>
To: Matthew Wilcox <willy@infradead.org>
Cc: <akpm@linux-foundation.org>, <david@redhat.com>,
<lorenzo.stoakes@oracle.com>, <Liam.Howlett@oracle.com>,
<vbabka@suse.cz>, <rppt@kernel.org>, <surenb@google.com>,
<mhocko@suse.com>, <ziy@nvidia.com>,
<baolin.wang@linux.alibaba.com>, <npache@redhat.com>,
<ryan.roberts@arm.com>, <dev.jain@arm.com>, <baohua@kernel.org>,
<catalin.marinas@arm.com>, <will@kernel.org>,
<paul.walmsley@sifive.com>, <palmer@dabbelt.com>,
<aou@eecs.berkeley.edu>, <alex@ghiti.fr>,
<anshuman.khandual@arm.com>, <yangyicong@hisilicon.com>,
<ardb@kernel.org>, <apopple@nvidia.com>,
<samuel.holland@sifive.com>, <luxu.kernel@bytedance.com>,
<abrestic@rivosinc.com>, <yongxuan.wang@sifive.com>,
<linux-mm@kvack.org>, <linux-kernel@vger.kernel.org>,
<linux-arm-kernel@lists.infradead.org>,
<linux-riscv@lists.infradead.org>, <wangkefeng.wang@huawei.com>,
<chenjun102@huawei.com>
Subject: Re: [PATCH RFC 2/2] mm: add PMD-level huge page support for remap_pfn_range()
Date: Thu, 25 Sep 2025 10:17:31 +0800 [thread overview]
Message-ID: <620d202a-6078-4b5d-a42a-8a52543bc14a@huawei.com> (raw)
In-Reply-To: <aNMhiZ4FiEE1Rk_T@casper.infradead.org>
On 9/24/2025 6:39 AM, Matthew Wilcox wrote:
> On Tue, Sep 23, 2025 at 09:31:04PM +0800, Yin Tirui wrote:
>> + entry = pte_clrhuge(pfn_pte(pmd_pfn(old_pmd), pmd_pgprot(old_pmd)));
>
> This doesn't make sense. And I'm not saying you got this wrong; I
> suspect in terms of how things work today it's actually necessary.
> But the way we handle this stuff is so insane.
Thank you for pointing this out and the broader context.
>
> pte_clrhuge() should not exist. If we have a PTE, it can't have the
> huge bit set, by definition (don't anybody mention hugetlbfs because
> that is an entirely separate pile of broken horrors). I understand what
> you're trying to do here. You want to construct a PTE that points to
> the same address as the first page of the PMD and has the same
> permissions. But that *should* be written as:
>
> entry = pfn_pte(pmd_pfn(old_pmd), pmd_pgprot(old_pmd)));
>
> right? Now, pmd_pgprot() might or might not want to return the huge bit
> set. I'm not sure. Perhaps you could have a look through and figure it
I've tested this on arm64, and pmd_pgprot() does return the huge bit
set, which is exactly why I added pte_clrhuge().
> out. But pfn_pte() should never return a PTE with the huge bit set.
> So if it is set in the pgorot on entry, it should filter it out.
>
> There are going to be consequences to this. Maybe there's code
> somewhere that relies on pfn_pte() returning a PTE with the huge bit
> set. Perhaps it's hugetlbfs.
I'll try to refactor pfn_pte() and related functions to filter out the
huge bit set and test its impact on hugetlbfs.
>
> But we have to start cleaning this garbage up. I did some work with
> e3981db444a0 and the commits leading up to that. See
> https://lkml.kernel.org/r/20250402181709.2386022-12-willy@infradead.org
>
> I'd like pte_clrhuge() to be deleted from x86, not added to arm and
> riscv.
>
I completely agree with the goal of deleting pte_clrhuge() rather than
expanding it. I'll study your referenced work and align my approach with
your efforts.
Would you recommend I address the pfn_pte() and related function
refactoring as part of this patch series, or should I submit it as a
separate patch series?
--
Best regards,
Yin Tirui
next prev parent reply other threads:[~2025-09-25 2:17 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-09-23 13:31 [PATCH RFC 0/2] mm: add huge pfnmap " Yin Tirui
2025-09-23 13:31 ` [PATCH RFC 1/2] pgtable: add pte_clrhuge() implementation for arm64 and riscv Yin Tirui
2025-09-23 13:31 ` [PATCH RFC 2/2] mm: add PMD-level huge page support for remap_pfn_range() Yin Tirui
2025-09-23 22:39 ` Matthew Wilcox
2025-09-25 2:17 ` Yin Tirui [this message]
2025-09-24 9:50 ` David Hildenbrand
2025-09-25 1:43 ` Yin Tirui
2025-09-25 9:38 ` David Hildenbrand
2025-09-23 22:53 ` [syzbot ci] Re: mm: add huge pfnmap " syzbot ci
2025-10-16 11:27 [PATCH RFC v2 0/2] " Yin Tirui
2025-10-16 11:27 ` [PATCH RFC 2/2] mm: add PMD-level huge page " Yin Tirui
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=620d202a-6078-4b5d-a42a-8a52543bc14a@huawei.com \
--to=yintirui@huawei.com \
--cc=Liam.Howlett@oracle.com \
--cc=abrestic@rivosinc.com \
--cc=akpm@linux-foundation.org \
--cc=alex@ghiti.fr \
--cc=anshuman.khandual@arm.com \
--cc=aou@eecs.berkeley.edu \
--cc=apopple@nvidia.com \
--cc=ardb@kernel.org \
--cc=baohua@kernel.org \
--cc=baolin.wang@linux.alibaba.com \
--cc=catalin.marinas@arm.com \
--cc=chenjun102@huawei.com \
--cc=david@redhat.com \
--cc=dev.jain@arm.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=linux-riscv@lists.infradead.org \
--cc=lorenzo.stoakes@oracle.com \
--cc=luxu.kernel@bytedance.com \
--cc=mhocko@suse.com \
--cc=npache@redhat.com \
--cc=palmer@dabbelt.com \
--cc=paul.walmsley@sifive.com \
--cc=rppt@kernel.org \
--cc=ryan.roberts@arm.com \
--cc=samuel.holland@sifive.com \
--cc=surenb@google.com \
--cc=vbabka@suse.cz \
--cc=wangkefeng.wang@huawei.com \
--cc=will@kernel.org \
--cc=willy@infradead.org \
--cc=yangyicong@hisilicon.com \
--cc=yongxuan.wang@sifive.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