mm: inline destroy_large_folio() into __folio_put_large()
authorMatthew Wilcox (Oracle) <willy@infradead.org>
Fri, 5 Apr 2024 15:32:25 +0000 (16:32 +0100)
committerAndrew Morton <akpm@linux-foundation.org>
Fri, 26 Apr 2024 03:56:44 +0000 (20:56 -0700)
destroy_large_folio() has only one caller, move its contents there.

Link: https://lkml.kernel.org/r/20240405153228.2563754-4-willy@infradead.org
Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
Reviewed-by: Zi Yan <ziy@nvidia.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
include/linux/mm.h
mm/page_alloc.c
mm/swap.c

index 4f4e460d78531bf3c489f24ceeee09cad19e4087..cc9410d772ddf0c29b56871c974fc686d78e5e36 100644 (file)
@@ -1318,8 +1318,6 @@ void folio_copy(struct folio *dst, struct folio *src);
 
 unsigned long nr_free_buffer_pages(void);
 
-void destroy_large_folio(struct folio *folio);
-
 /* Returns the number of bytes in this potentially compound page. */
 static inline unsigned long page_size(struct page *page)
 {
index c01757251de29d32f84cc5d5cba5632bde886cee..22e8b9f1d710b9ed746f8e4ff5aa47181051cc90 100644 (file)
@@ -565,20 +565,6 @@ void prep_compound_page(struct page *page, unsigned int order)
        prep_compound_head(page, order);
 }
 
-void destroy_large_folio(struct folio *folio)
-{
-       if (folio_test_hugetlb(folio)) {
-               free_huge_folio(folio);
-               return;
-       }
-
-       if (folio_test_large_rmappable(folio))
-               folio_undo_large_rmappable(folio);
-
-       mem_cgroup_uncharge(folio);
-       free_unref_page(&folio->page, folio_order(folio));
-}
-
 static inline void set_buddy_order(struct page *page, unsigned int order)
 {
        set_page_private(page, order);
index d7db3cd4e80a61c8b5d9fb497f1dc40a1467156f..6e3bd03673eab0fabc772b573352b5baced76e82 100644 (file)
--- a/mm/swap.c
+++ b/mm/swap.c
@@ -127,9 +127,16 @@ static void __folio_put_large(struct folio *folio)
         * (it's never listed to any LRU lists) and no memcg routines should
         * be called for hugetlb (it has a separate hugetlb_cgroup.)
         */
-       if (!folio_test_hugetlb(folio))
-               page_cache_release(folio);
-       destroy_large_folio(folio);
+       if (folio_test_hugetlb(folio)) {
+               free_huge_folio(folio);
+               return;
+       }
+
+       page_cache_release(folio);
+       if (folio_test_large_rmappable(folio))
+               folio_undo_large_rmappable(folio);
+       mem_cgroup_uncharge(folio);
+       free_unref_page(&folio->page, folio_order(folio));
 }
 
 void __folio_put(struct folio *folio)