]> www.infradead.org Git - users/willy/pagecache.git/commitdiff
mm/swap: Add release_folios folio
authorMatthew Wilcox (Oracle) <willy@infradead.org>
Thu, 17 Dec 2020 18:13:44 +0000 (13:13 -0500)
committerMatthew Wilcox (Oracle) <willy@infradead.org>
Tue, 28 Sep 2021 16:45:42 +0000 (12:45 -0400)
Turn release_pages() into a wrapper around release_folios().

Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
include/linux/pagemap.h
mm/swap.c

index 8d520c6047521d06e4ce7e00d9da564fb74699e7..bafa502d501fed8637dbc840e910036d255f4f41 100644 (file)
@@ -165,6 +165,7 @@ static inline void filemap_nr_thps_dec(struct address_space *mapping)
 #endif
 }
 
+void release_folios(struct folio **folios, int nr);
 void release_pages(struct page **pages, int nr);
 
 struct address_space *page_mapping(struct page *);
index 59b1a6ec2a89620c8f1f588590d8e9a1cd5fe200..5115cb2d2fa092eeb34db1f8c508246c671626cb 100644 (file)
--- a/mm/swap.c
+++ b/mm/swap.c
@@ -870,14 +870,14 @@ void lru_cache_disable(void)
 }
 
 /**
- * release_pages - batched put_page()
- * @pages: array of pages to release
- * @nr: number of pages
+ * release_folios - batched folio_put()
+ * @folios: array of folios to release
+ * @nr: number of folios
  *
- * Decrement the reference count on all the pages in @pages.  If it
- * fell to zero, remove the page from the LRU and free it.
+ * Decrement the reference count on all the folios in @folios.  If it
+ * fell to zero, remove the folio from the LRU and free it.
  */
-void release_pages(struct page **pages, int nr)
+void release_folios(struct folio **folios, int nr)
 {
        int i;
        LIST_HEAD(pages_to_free);
@@ -886,11 +886,11 @@ void release_pages(struct page **pages, int nr)
        unsigned int lock_batch;
 
        for (i = 0; i < nr; i++) {
-               struct folio *folio = page_folio(pages[i]);
+               struct folio *folio = folios[i];
 
                /*
                 * Make sure the IRQ-safe lock-holding time does not get
-                * excessive with a continuous string of pages from the
+                * excessive with a continuous string of folios from the
                 * same lruvec. The lock is held only if lruvec != NULL.
                 */
                if (lruvec && ++lock_batch == SWAP_CLUSTER_MAX) {
@@ -955,6 +955,16 @@ void release_pages(struct page **pages, int nr)
        mem_cgroup_uncharge_list(&pages_to_free);
        free_unref_page_list(&pages_to_free);
 }
+EXPORT_SYMBOL(release_folios);
+
+void release_pages(struct page **pages, int nr)
+{
+       int i;
+
+       for (i = 0; i < nr; i++)
+               pages[i] = &page_folio(pages[i])->page;
+       release_folios((struct folio **)pages, nr);
+}
 EXPORT_SYMBOL(release_pages);
 
 /*