@@ -1925,16 +1925,20 @@ static inline bool is_zero_folio(const struct folio *folio)
return is_zero_page(&folio->page);
}
-/* MIGRATE_CMA and ZONE_MOVABLE do not allow pin folios */
+/* MIGRATE_CMA, MIGRATE_METADATA and ZONE_MOVABLE do not allow pin folios */
#ifdef CONFIG_MIGRATION
static inline bool folio_is_longterm_pinnable(struct folio *folio)
{
-#ifdef CONFIG_CMA
+#if defined(CONFIG_CMA) || defined(CONFIG_MEMORY_METADATA)
int mt = folio_migratetype(folio);
- if (mt == MIGRATE_CMA || mt == MIGRATE_ISOLATE)
+ if (mt == MIGRATE_ISOLATE)
+ return false;
+
+ if (is_migrate_cma(mt) || is_migrate_metadata(mt))
return false;
#endif
+
/* The zero page can be "pinned" but gets special handling. */
if (is_zero_folio(folio))
return true;
@@ -1238,6 +1238,8 @@ config LOCK_MM_AND_FIND_VMA
config MEMORY_METADATA
bool
+ select MEMORY_ISOLATION
+ select MIGRATION
source "mm/damon/Kconfig"
Treat MIGRATE_METADATA pages just like movable or CMA pages and don't allow them to be pinned longterm. No special handling needed for migrate_longterm_unpinnable_pages() because the gfp mask for allocating the destination pages is GFP_USER. GFP_USER doesn't include __GFP_MOVABLE, which makes it impossible to accidently allocate metadata pages for migrating the pinned pages. Signed-off-by: Alexandru Elisei <alexandru.elisei@arm.com> --- include/linux/mm.h | 10 +++++++--- mm/Kconfig | 2 ++ 2 files changed, 9 insertions(+), 3 deletions(-)