mm/migrate: add folio_movable_ops()
authorVishal Moola (Oracle) <vishal.moola@gmail.com>
Mon, 30 Jan 2023 21:43:50 +0000 (13:43 -0800)
committerAndrew Morton <akpm@linux-foundation.org>
Mon, 13 Feb 2023 23:54:31 +0000 (15:54 -0800)
folio_movable_ops() does the same as page_movable_ops() except uses folios
instead of pages.  This function will help make folio conversions in
migrate.c more readable.

Link: https://lkml.kernel.org/r/20230130214352.40538-3-vishal.moola@gmail.com
Signed-off-by: Vishal Moola (Oracle) <vishal.moola@gmail.com>
Cc: Matthew Wilcox <willy@infradead.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
include/linux/migrate.h
mm/migrate.c

index 3ef77f5..bdff950 100644 (file)
@@ -123,6 +123,15 @@ static inline bool folio_test_movable(struct folio *folio)
 }
 
 static inline
+const struct movable_operations *folio_movable_ops(struct folio *folio)
+{
+       VM_BUG_ON(!__folio_test_movable(folio));
+
+       return (const struct movable_operations *)
+               ((unsigned long)folio->mapping - PAGE_MAPPING_MOVABLE);
+}
+
+static inline
 const struct movable_operations *page_movable_ops(struct page *page)
 {
        VM_BUG_ON(!__PageMovable(page));
index c09872c..d2b1167 100644 (file)
@@ -990,7 +990,7 @@ static int move_to_new_folio(struct folio *dst, struct folio *src,
                        goto out;
                }
 
-               mops = page_movable_ops(&src->page);
+               mops = folio_movable_ops(src);
                rc = mops->migrate_page(&dst->page, &src->page, mode);
                WARN_ON_ONCE(rc == MIGRATEPAGE_SUCCESS &&
                                !folio_test_isolated(src));