From: Yin Tirui <yintirui@huawei.com>
To: <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>, <willy@infradead.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>
Cc: <wangkefeng.wang@huawei.com>, <chenjun102@huawei.com>,
<yintirui@huawei.com>
Subject: [PATCH RFC 1/2] pgtable: add pte_clrhuge() implementation for arm64 and riscv
Date: Thu, 16 Oct 2025 19:27:03 +0800 [thread overview]
Message-ID: <20251016112704.179280-2-yintirui@huawei.com> (raw)
In-Reply-To: <20251016112704.179280-1-yintirui@huawei.com>
Add pte_clrhuge() helper function for architectures that enable
ARCH_SUPPORTS_HUGE_PFNMAP to clear huge page attributes from PTE
entries.
This function provides the inverse operation of pte_mkhuge() and will
be needed for upcoming huge page splitting, where PTE entries derived
from huge page mappings need to have their huge page attributes cleared.
Future work will refactor pfn_pte() to automatically filter huge bits,
removing the need for pte_clrhuge() across all architectures.
Signed-off-by: Yin Tirui <yintirui@huawei.com>
---
arch/arm64/include/asm/pgtable.h | 8 ++++++++
arch/riscv/include/asm/pgtable.h | 5 +++++
2 files changed, 13 insertions(+)
diff --git a/arch/arm64/include/asm/pgtable.h b/arch/arm64/include/asm/pgtable.h
index abd2dee416b3..244755bad46f 100644
--- a/arch/arm64/include/asm/pgtable.h
+++ b/arch/arm64/include/asm/pgtable.h
@@ -366,6 +366,14 @@ static inline pte_t pte_mkinvalid(pte_t pte)
return pte;
}
+static inline pte_t pte_clrhuge(pte_t pte)
+{
+ pteval_t mask = PTE_TYPE_MASK & ~PTE_VALID;
+ pteval_t val = PTE_TYPE_PAGE & ~PTE_VALID;
+
+ return __pte((pte_val(pte) & ~mask) | val);
+}
+
static inline pmd_t pmd_mkcont(pmd_t pmd)
{
return __pmd(pmd_val(pmd) | PMD_SECT_CONT);
diff --git a/arch/riscv/include/asm/pgtable.h b/arch/riscv/include/asm/pgtable.h
index 815067742939..b0a20ddf780a 100644
--- a/arch/riscv/include/asm/pgtable.h
+++ b/arch/riscv/include/asm/pgtable.h
@@ -455,6 +455,11 @@ static inline pte_t pte_mkhuge(pte_t pte)
return pte;
}
+static inline pte_t pte_clrhuge(pte_t pte)
+{
+ return pte;
+}
+
#ifdef CONFIG_RISCV_ISA_SVNAPOT
#define pte_leaf_size(pte) (pte_napot(pte) ? \
napot_cont_size(napot_cont_order(pte)) :\
--
2.43.0
WARNING: multiple messages have this Message-ID (diff)
From: Yin Tirui <yintirui@huawei.com>
To: <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>, <willy@infradead.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>
Cc: <wangkefeng.wang@huawei.com>, <chenjun102@huawei.com>,
<yintirui@huawei.com>
Subject: [PATCH RFC 1/2] pgtable: add pte_clrhuge() implementation for arm64 and riscv
Date: Thu, 16 Oct 2025 19:27:03 +0800 [thread overview]
Message-ID: <20251016112704.179280-2-yintirui@huawei.com> (raw)
In-Reply-To: <20251016112704.179280-1-yintirui@huawei.com>
Add pte_clrhuge() helper function for architectures that enable
ARCH_SUPPORTS_HUGE_PFNMAP to clear huge page attributes from PTE
entries.
This function provides the inverse operation of pte_mkhuge() and will
be needed for upcoming huge page splitting, where PTE entries derived
from huge page mappings need to have their huge page attributes cleared.
Future work will refactor pfn_pte() to automatically filter huge bits,
removing the need for pte_clrhuge() across all architectures.
Signed-off-by: Yin Tirui <yintirui@huawei.com>
---
arch/arm64/include/asm/pgtable.h | 8 ++++++++
arch/riscv/include/asm/pgtable.h | 5 +++++
2 files changed, 13 insertions(+)
diff --git a/arch/arm64/include/asm/pgtable.h b/arch/arm64/include/asm/pgtable.h
index abd2dee416b3..244755bad46f 100644
--- a/arch/arm64/include/asm/pgtable.h
+++ b/arch/arm64/include/asm/pgtable.h
@@ -366,6 +366,14 @@ static inline pte_t pte_mkinvalid(pte_t pte)
return pte;
}
+static inline pte_t pte_clrhuge(pte_t pte)
+{
+ pteval_t mask = PTE_TYPE_MASK & ~PTE_VALID;
+ pteval_t val = PTE_TYPE_PAGE & ~PTE_VALID;
+
+ return __pte((pte_val(pte) & ~mask) | val);
+}
+
static inline pmd_t pmd_mkcont(pmd_t pmd)
{
return __pmd(pmd_val(pmd) | PMD_SECT_CONT);
diff --git a/arch/riscv/include/asm/pgtable.h b/arch/riscv/include/asm/pgtable.h
index 815067742939..b0a20ddf780a 100644
--- a/arch/riscv/include/asm/pgtable.h
+++ b/arch/riscv/include/asm/pgtable.h
@@ -455,6 +455,11 @@ static inline pte_t pte_mkhuge(pte_t pte)
return pte;
}
+static inline pte_t pte_clrhuge(pte_t pte)
+{
+ return pte;
+}
+
#ifdef CONFIG_RISCV_ISA_SVNAPOT
#define pte_leaf_size(pte) (pte_napot(pte) ? \
napot_cont_size(napot_cont_order(pte)) :\
--
2.43.0
_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv
next prev parent reply other threads:[~2025-10-16 11:33 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-10-16 11:27 [PATCH RFC v2 0/2] mm: add huge pfnmap support for remap_pfn_range() Yin Tirui
2025-10-16 11:27 ` Yin Tirui
2025-10-16 11:27 ` Yin Tirui [this message]
2025-10-16 11:27 ` [PATCH RFC 1/2] pgtable: add pte_clrhuge() implementation for arm64 and riscv Yin Tirui
2025-10-16 18:22 ` Matthew Wilcox
2025-10-16 18:22 ` Matthew Wilcox
2025-10-18 3:12 ` Yin Tirui
2025-10-18 3:12 ` Yin Tirui
2025-10-16 11:27 ` [PATCH RFC 2/2] mm: add PMD-level huge page support for remap_pfn_range() Yin Tirui
2025-10-16 11:27 ` Yin Tirui
2025-10-17 7:50 ` kernel test robot
2025-10-16 16:23 ` [syzbot ci] Re: mm: add huge pfnmap " syzbot ci
2025-10-16 16:23 ` syzbot ci
-- strict thread matches above, loose matches on Subject: below --
2025-09-23 13:31 [PATCH RFC 0/2] " 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 ` 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=20251016112704.179280-2-yintirui@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.