[PATCH v4 1/2] huge_mm: add stubs for THP-disabled configs

From: WANG Rui

Date: Mon Mar 09 2026 - 23:13:26 EST


hugepage_global_enabled() and hugepage_global_always() only exist
when CONFIG_TRANSPARENT_HUGEPAGE is set. Add inline stubs that
return false to let code compile when THP is disabled.

Signed-off-by: WANG Rui <r@xxxxxx>
---
include/linux/huge_mm.h | 10 ++++++++++
1 file changed, 10 insertions(+)

diff --git a/include/linux/huge_mm.h b/include/linux/huge_mm.h
index a4d9f964dfde..badeebd4ea98 100644
--- a/include/linux/huge_mm.h
+++ b/include/linux/huge_mm.h
@@ -570,6 +570,16 @@ void map_anon_folio_pmd_nopf(struct folio *folio, pmd_t *pmd,

#else /* CONFIG_TRANSPARENT_HUGEPAGE */

+static inline bool hugepage_global_enabled(void)
+{
+ return false;
+}
+
+static inline bool hugepage_global_always(void)
+{
+ return false;
+}
+
static inline bool folio_test_pmd_mappable(struct folio *folio)
{
return false;
--
2.53.0