mm: Add split_folio_to_list()
authorMatthew Wilcox (Oracle) <willy@infradead.org>
Tue, 18 Jan 2022 13:56:47 +0000 (08:56 -0500)
committerMatthew Wilcox (Oracle) <willy@infradead.org>
Mon, 21 Mar 2022 16:59:02 +0000 (12:59 -0400)
This is a convenience function; split_huge_page_to_list() can take
any page in a folio (and does so on purpose because that page will
be the one which keeps the refcount).  But it's convenient for the
callers to pass the folio instead of the first page in the folio.

Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
include/linux/huge_mm.h
mm/vmscan.c

index e4c18ba..71c073d 100644 (file)
@@ -483,6 +483,12 @@ static inline bool thp_migration_supported(void)
 }
 #endif /* CONFIG_TRANSPARENT_HUGEPAGE */
 
+static inline int split_folio_to_list(struct folio *folio,
+               struct list_head *list)
+{
+       return split_huge_page_to_list(&folio->page, list);
+}
+
 /**
  * thp_size - Size of a transparent huge page.
  * @page: Head page of a transparent huge page.
index 815fe89..94729d2 100644 (file)
@@ -1715,16 +1715,16 @@ retry:
                                         * tail pages can be freed without IO.
                                         */
                                        if (!compound_mapcount(page) &&
-                                           split_huge_page_to_list(page,
-                                                                   page_list))
+                                           split_folio_to_list(folio,
+                                                               page_list))
                                                goto activate_locked;
                                }
                                if (!add_to_swap(page)) {
                                        if (!PageTransHuge(page))
                                                goto activate_locked_split;
                                        /* Fallback to swap normal pages */
-                                       if (split_huge_page_to_list(page,
-                                                                   page_list))
+                                       if (split_folio_to_list(folio,
+                                                               page_list))
                                                goto activate_locked;
 #ifdef CONFIG_TRANSPARENT_HUGEPAGE
                                        count_vm_event(THP_SWPOUT_FALLBACK);
@@ -1740,7 +1740,7 @@ retry:
                        }
                } else if (unlikely(PageTransHuge(page))) {
                        /* Split file THP */
-                       if (split_huge_page_to_list(page, page_list))
+                       if (split_folio_to_list(folio, page_list))
                                goto keep_locked;
                }