mm/rmap: inline folio_test_large_maybe_mapped_shared() into callers
Subsystems (3)
PATCH v3 1/1 mm/rmap: inline folio_test_large_maybe_mapped_shared() into callers
From: Lance Yang <[email protected]>
To prevent the function from being used when CONFIG_MM_ID is disabled, we intend to inline it into its few callers, which also would help maintain the expected code placement.
---
v2 -> v3:
* Inline the function, suggested by David
* https://lore.kernel.org/all/[email protected]
v1 -> v2:
* Update the changelog, suggested by Andrew and David
* https://lore.kernel.org/linux-mm/[email protected]
include/linux/mm.h | 2 +- include/linux/page-flags.h | 4 ---- include/linux/rmap.h | 2 +- mm/memory.c | 4 ++-- 4 files changed, 4 insertions(+), 8 deletions(-)
include/linux/mm.h +1 -1
@@ -2303,7 +2303,7 @@ static inline bool folio_maybe_mapped_shared(struct folio *folio)*/ if (mapcount <=1 )return false; -return folio_test_large_maybe_mapped_shared (folio); +return test_bit (FOLIO_MM_IDS_SHARED_BITNUM , &folio->_mm_ids); }#ifndef HAVE_ARCH_MAKE_FOLIO_ACCESSIBLE
include/linux/page-flags.h +0 -4
@@ -1230,10 +1230,6 @@ static inline int folio_has_private(const struct folio *folio)return !!(folio->flags &PAGE_FLAGS_PRIVATE ); } -static inline bool folio_test_large_maybe_mapped_shared (const struct folio *folio) -{ -return test_bit (FOLIO_MM_IDS_SHARED_BITNUM , &folio->_mm_ids); -}#undef PF_ANY#undef PF_HEAD#undef PF_NO_TAIL
include/linux/rmap.h +1 -1
@@ -223,7 +223,7 @@ static inline void __folio_large_mapcount_sanity_checks(const struct folio *foliVM_WARN_ON_ONCE (folio_mm_id (folio,1 ) !=MM_ID_DUMMY && folio->_mm_id_mapcount[1 ] <0 );VM_WARN_ON_ONCE (!folio_mapped (folio) && -folio_test_large_maybe_mapped_shared (folio)); +test_bit (FOLIO_MM_IDS_SHARED_BITNUM , &folio->_mm_ids)); } static __always_inline void folio_set_large_mapcount(struct folio *folio,
mm/memory.c +2 -2
@@ -3730,7 +3730,7 @@ static bool __wp_can_reuse_large_anon_folio(struct folio *folio,* If all folio references are from mappings, and all mappings are in * the page tables of this MM, then this folio is exclusive to this MM. */ -if (folio_test_large_maybe_mapped_shared (folio)) +if (test_bit (FOLIO_MM_IDS_SHARED_BITNUM , &folio->_mm_ids))return false;VM_WARN_ON_ONCE (folio_test_ksm (folio));
@@ -3753,7 +3753,7 @@ static bool __wp_can_reuse_large_anon_folio(struct folio *folio,folio_lock_large_mapcount (folio);VM_WARN_ON_ONCE (folio_large_mapcount (folio) <folio_ref_count (folio)); -if (folio_test_large_maybe_mapped_shared (folio)) +if (test_bit (FOLIO_MM_IDS_SHARED_BITNUM , &folio->_mm_ids)) goto unlock;if (folio_large_mapcount (folio) !=folio_ref_count (folio)) goto unlock;
Signature · 1 line
2.49.0
Quoted 9 lines · Lance Yang
From: Lance Yang <[email protected]>
To prevent the function from being used when
CONFIG_MM_IDis disabled, we intend to inline it into its few callers, which also would help maintain the expected code placement.Suggested-by David Hildenbrand <[email protected]>Signed-off-by Lance Yang <[email protected]>---
Yeah, this way it's harder to abuse ... having the test functions is a leftover from when I had set/clear functions during development and experimented with using a pageflag (which involves atomics even on tail pages unfortunately).
Signature · 3 lines
Cheers, David / dhildenb