Skip to contentSkip to conversation

mm/rmap: add CONFIG_MM_ID guard for folio_test_large_maybe_mapped_shared()

PATCH Superseded Lance Yang 1 participant 1 message Apr 18, 2025

Subsystems (2)
lore
Share & tools
lore

Lance Yang

author
#0 lore raw

PATCH v2 1/1 mm/rmap: add CONFIG_MM_ID guard for folio_test_large_maybe_mapped_shared()

From: Lance Yang <[email protected]>

From: Lance Yang <[email protected]>

To prevent folio_test_large_maybe_mapped_shared() from being used without CONFIG_MM_ID, we add a compile-time check rather than wrapping it in '#ifdef', avoiding even more #ifdef in callers that already use IS_ENABLED(CONFIG_MM_ID).

Also, we used plenty of IS_ENABLED() on purpose to keep the code free of '#ifdef' mess.

---
v1 -> v2:
* Update the changelog, suggested by Andrew and David
* https://lore.kernel.org/linux-mm/[email protected]

 include/linux/page-flags.h | 2 ++
 1 file changed, 2 insertions(+)
include/linux/page-flags.h +2 -0
index d3909cb1e576..6bd9b9043976 100644
@@ -1232,6 +1232,8 @@ static inline int folio_has_private(const struct folio *folio)
 
 static inline bool folio_test_large_maybe_mapped_shared(const struct folio *folio)
 {
+	/* This function should never be called without CONFIG_MM_ID enabled. */
+	BUILD_BUG_ON(!IS_ENABLED(CONFIG_MM_ID));
 	return test_bit(FOLIO_MM_IDS_SHARED_BITNUM, &folio->_mm_ids);
 }
 #undef PF_ANY
Signature · 1 line
2.49.0