[PATCH RFC v3 3/4] x86/mm: Remove pte_clrhuge() and clean up init_64.c
Yin Tirui
yintirui at huawei.com
Fri Feb 27 23:09:05 PST 2026
With `pfn_pte()` now guaranteeing that it will natively filter out
huge page attributes like `_PAGE_PSE`, the `pte_clrhuge()` helper has
become obsolete.
Remove `pte_clrhuge()` entirely. Concurrently, clean up the ugly type-casting
anti-pattern in `arch/x86/mm/init_64.c` where `(pte_t *)` was forcibly
cast from `pmd_t *` to call `pte_clrhuge()`. Now, we can simply extract
the pgprot directly via `pmd_pgprot()` and safely pass it downstream, knowing
that `pfn_pte()` will strip the huge bit automatically.
Signed-off-by: Yin Tirui <yintirui at huawei.com>
---
arch/x86/include/asm/pgtable.h | 5 -----
arch/x86/mm/init_64.c | 4 ++--
2 files changed, 2 insertions(+), 7 deletions(-)
diff --git a/arch/x86/include/asm/pgtable.h b/arch/x86/include/asm/pgtable.h
index a4dbd81d42bf..e8564d4ce318 100644
--- a/arch/x86/include/asm/pgtable.h
+++ b/arch/x86/include/asm/pgtable.h
@@ -483,11 +483,6 @@ static inline pte_t pte_mkhuge(pte_t pte)
return pte_set_flags(pte, _PAGE_PSE);
}
-static inline pte_t pte_clrhuge(pte_t pte)
-{
- return pte_clear_flags(pte, _PAGE_PSE);
-}
-
static inline pte_t pte_mkglobal(pte_t pte)
{
return pte_set_flags(pte, _PAGE_GLOBAL);
diff --git a/arch/x86/mm/init_64.c b/arch/x86/mm/init_64.c
index d65f3d05c66f..a1ddcf793a8a 100644
--- a/arch/x86/mm/init_64.c
+++ b/arch/x86/mm/init_64.c
@@ -572,7 +572,7 @@ phys_pmd_init(pmd_t *pmd_page, unsigned long paddr, unsigned long paddr_end,
paddr_last = paddr_next;
continue;
}
- new_prot = pte_pgprot(pte_clrhuge(*(pte_t *)pmd));
+ new_prot = pmd_pgprot(*pmd);
}
if (page_size_mask & (1<<PG_LEVEL_2M)) {
@@ -658,7 +658,7 @@ phys_pud_init(pud_t *pud_page, unsigned long paddr, unsigned long paddr_end,
paddr_last = paddr_next;
continue;
}
- prot = pte_pgprot(pte_clrhuge(*(pte_t *)pud));
+ prot = pud_pgprot(*pud);
}
if (page_size_mask & (1<<PG_LEVEL_1G)) {
--
2.22.0
More information about the linux-arm-kernel
mailing list