[PATCH] mm/migrate: Add native folio functions

From: yahia

Date: Sun Jun 07 2026 - 20:13:07 EST


Hello,

I aim provides in this patch to provide native
folio abstractions for page functions like movable_ops
by wrapping folio->page structure in the native page function

Signed-off-by: yahia <yahia.a.abdrabou@xxxxxxxxx>
---
include/linux/page-flags.h | 7 +++++++
mm/migrate.c | 5 +++++
2 files changed, 12 insertions(+)

diff --git a/include/linux/page-flags.h b/include/linux/page-flags.h
index 7223f6f4e2b4..6776cf821edd 100644
--- a/include/linux/page-flags.h
+++ b/include/linux/page-flags.h
@@ -1110,6 +1110,7 @@ bool is_free_buddy_page(const struct page *page);
*/
TESTPAGEFLAG(MovableOps, movable_ops, PF_NO_TAIL);
SETPAGEFLAG(MovableOps, movable_ops, PF_NO_TAIL);
+FOLIO_TEST_FLAG(MovableOpsIsolated, movable_ops_isolated)
/*
* A movable_ops page has this flag set while it is isolated for migration.
* This flag primarily protects against concurrent migration attempts.
@@ -1139,6 +1140,12 @@ static inline bool page_has_movable_ops(const struct page *page)
(PageOffline(page) || PageZsmalloc(page));
}

+static inline bool folio_has_movable_ops(struct folio *folio)
+{
+ return PageMovableOps(&folio->page) &&
+ (PageOffline(&folio->page) || PageZsmalloc(&folio->page));
+}
+
static __always_inline int PageAnonExclusive(const struct page *page)
{
VM_BUG_ON_PGFLAGS(!PageAnon(page), page);
diff --git a/mm/migrate.c b/mm/migrate.c
index 8a64291ab5b4..817a8c0b84d9 100644
--- a/mm/migrate.c
+++ b/mm/migrate.c
@@ -96,6 +96,11 @@ static const struct movable_operations *page_movable_ops(struct page *page)
return NULL;
}

+static const struct movable_operations *folio_movable_ops(struct folio *folio)
+{
+ return page_movable_ops(&folio->page);
+}
+
/**
* isolate_movable_ops_page - isolate a movable_ops page for migration
* @page: The page.
--
2.54.0