From 8aaaf0b71250da3559fe17a02f1f94eb30a6fe7e Mon Sep 17 00:00:00 2001 From: "Matthew Wilcox (Oracle)" Date: Thu, 17 Dec 2020 13:13:44 -0500 Subject: [PATCH] mm/swap: Add release_folios Turn release_pages() into a wrapper around release_folios(). Signed-off-by: Matthew Wilcox (Oracle) --- include/linux/pagemap.h | 1 + mm/swap.c | 26 ++++++++++++++++++-------- 2 files changed, 19 insertions(+), 8 deletions(-) diff --git a/include/linux/pagemap.h b/include/linux/pagemap.h index 8d520c6047521..bafa502d501fe 100644 --- a/include/linux/pagemap.h +++ b/include/linux/pagemap.h @@ -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 *); diff --git a/mm/swap.c b/mm/swap.c index 59b1a6ec2a896..5115cb2d2fa09 100644 --- 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); /* -- 2.51.0