Re: [PATCH v7 10/14] mips: move has_transparent_hugepage() out of THP guard
From: Lance Yang
Date: Tue Sep 01 2026 - 07:47:04 EST
On 2026/9/1 11:12, Luiz Capitulino wrote:
A future commit will introduce a kernel API to allow for checking if the
CPU supports PMD-sized pages. This API will be based on the
has_transparent_hugepage() implementation but will be orthogonal to THP
and therefore must work when CONFIG_TRANSPARENT_HUGEPAGE=n.
Move its definition out of the THP guard.
Signed-off-by: Luiz Capitulino <luizcap@xxxxxxxxxx>
---
arch/mips/include/asm/pgtable.h | 6 +++---
arch/mips/mm/tlb-r4k.c | 4 ----
2 files changed, 3 insertions(+), 7 deletions(-)
diff --git a/arch/mips/include/asm/pgtable.h b/arch/mips/include/asm/pgtable.h
index fa7b935f947c..b038da872ec6 100644
--- a/arch/mips/include/asm/pgtable.h
+++ b/arch/mips/include/asm/pgtable.h
@@ -615,9 +615,6 @@ unsigned long io_remap_pfn_range_pfn(unsigned long pfn, unsigned long size);
/* We don't have hardware dirty/accessed bits, generic_pmdp_establish is fine.*/
#define pmdp_establish generic_pmdp_establish
-#define has_transparent_hugepage has_transparent_hugepage
-extern int has_transparent_hugepage(void);
Assume a decstation_defconfig build. CPU_R3000 selects CPU_R3K_TLB, so the
Makefile builds tlb-r3k.o but not tlb-r4k.o IIUC ...
The only MIPS definition is in tlb-r4k.c, so R3000 would fail to link with
an undefined reference ... no?
Cheers, Lance
-
static inline int pmd_trans_huge(pmd_t pmd)
{
return !!(pmd_val(pmd) & _PAGE_HUGE);
@@ -743,6 +740,9 @@ static inline pmd_t pmdp_huge_get_and_clear(struct mm_struct *mm,
#endif /* CONFIG_TRANSPARENT_HUGEPAGE */
+#define has_transparent_hugepage has_transparent_hugepage
+extern int has_transparent_hugepage(void);
+
#ifdef _PAGE_HUGE
#define pmd_leaf(pmd) ((pmd_val(pmd) & _PAGE_HUGE) != 0)
#define pud_leaf(pud) ((pud_val(pud) & _PAGE_HUGE) != 0)
diff --git a/arch/mips/mm/tlb-r4k.c b/arch/mips/mm/tlb-r4k.c
index 24fe85fa169d..f4e369342a56 100644
--- a/arch/mips/mm/tlb-r4k.c
+++ b/arch/mips/mm/tlb-r4k.c
@@ -432,8 +432,6 @@ void add_wired_entry(unsigned long entrylo0, unsigned long entrylo1,
#endif
}
-#ifdef CONFIG_TRANSPARENT_HUGEPAGE
-
int has_transparent_hugepage(void)
{
static unsigned int mask = -1;
@@ -452,8 +450,6 @@ int has_transparent_hugepage(void)
}
EXPORT_SYMBOL(has_transparent_hugepage);
-#endif /* CONFIG_TRANSPARENT_HUGEPAGE */
-
/*
* Used for loading TLB entries before trap_init() has started, when we
* don't actually want to add a wired entry which remains throughout the