linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [RESEND PATCH v2 1/1] mm/rmap: add CONFIG_MM_ID guard for folio_test_large_maybe_mapped_shared()
@ 2025-04-18 15:22 Lance Yang
  2025-04-20 23:29 ` Andrew Morton
  0 siblings, 1 reply; 10+ messages in thread
From: Lance Yang @ 2025-04-18 15:22 UTC (permalink / raw)
  To: akpm; +Cc: mingzhe.yang, linux-mm, linux-kernel, David Hildenbrand, Lance Yang

From: Lance Yang <lance.yang@linux.dev>

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.

Suggested-by: David Hildenbrand <david@redhat.com>
Signed-off-by: Lance Yang <lance.yang@linux.dev>
Acked-by: David Hildenbrand <david@redhat.com>
---
v1 -> v2:
 * Update the changelog, suggested by Andrew and David
 * https://lore.kernel.org/linux-mm/20250417124908.58543-1-ioworker0@gmail.com

 include/linux/page-flags.h | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/include/linux/page-flags.h b/include/linux/page-flags.h
index d3909cb1e576..6bd9b9043976 100644
--- a/include/linux/page-flags.h
+++ b/include/linux/page-flags.h
@@ -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
-- 
2.49.0



^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2025-04-22 23:20 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-04-18 15:22 [RESEND PATCH v2 1/1] mm/rmap: add CONFIG_MM_ID guard for folio_test_large_maybe_mapped_shared() Lance Yang
2025-04-20 23:29 ` Andrew Morton
2025-04-21  5:13   ` Lance Yang
2025-04-21  5:16     ` Lance Yang
2025-04-21  7:17       ` David Hildenbrand
2025-04-21  7:50         ` Lance Yang
2025-04-21 19:22     ` Andrew Morton
2025-04-22  4:35       ` Lance Yang
2025-04-22  7:00         ` David Hildenbrand
2025-04-22 23:20           ` Andrew Morton

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox