aboutsummaryrefslogtreecommitdiff
path: root/mm/swap.c
diff options
context:
space:
mode:
authorGravatar Matthew Wilcox (Oracle) <willy@infradead.org> 2024-04-05 16:32:26 +0100
committerGravatar Andrew Morton <akpm@linux-foundation.org> 2024-04-25 20:56:44 -0700
commit79a48287515848c18a49d75c1fdf176c82bb13cf (patch)
tree0cc08f7bd8737e2c113b0c6e8530c00ca1be5e28 /mm/swap.c
parentmm: inline destroy_large_folio() into __folio_put_large() (diff)
downloadlinux-79a48287515848c18a49d75c1fdf176c82bb13cf.tar.gz
linux-79a48287515848c18a49d75c1fdf176c82bb13cf.tar.bz2
linux-79a48287515848c18a49d75c1fdf176c82bb13cf.zip
mm: combine __folio_put_small, __folio_put_large and __folio_put
It's now obvious that __folio_put_small() and __folio_put_large() do almost exactly the same thing. Inline them both into __folio_put(). Link: https://lkml.kernel.org/r/20240405153228.2563754-5-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>
Diffstat (limited to 'mm/swap.c')
-rw-r--r--mm/swap.c32
1 files changed, 6 insertions, 26 deletions
diff --git a/mm/swap.c b/mm/swap.c
index 6e3bd03673ea..4f3964c983d8 100644
--- a/mm/swap.c
+++ b/mm/swap.c
@@ -112,42 +112,22 @@ static void page_cache_release(struct folio *folio)
unlock_page_lruvec_irqrestore(lruvec, flags);
}
-static void __folio_put_small(struct folio *folio)
-{
- page_cache_release(folio);
- mem_cgroup_uncharge(folio);
- free_unref_page(&folio->page, 0);
-}
-
-static void __folio_put_large(struct folio *folio)
+void __folio_put(struct folio *folio)
{
- /*
- * __page_cache_release() is supposed to be called for thp, not for
- * hugetlb. This is because hugetlb page does never have PageLRU set
- * (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)) {
+ if (unlikely(folio_is_zone_device(folio))) {
+ free_zone_device_page(&folio->page);
+ return;
+ } else if (folio_test_hugetlb(folio)) {
free_huge_folio(folio);
return;
}
page_cache_release(folio);
- if (folio_test_large_rmappable(folio))
+ if (folio_test_large(folio) && 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)
-{
- if (unlikely(folio_is_zone_device(folio)))
- free_zone_device_page(&folio->page);
- else if (unlikely(folio_test_large(folio)))
- __folio_put_large(folio);
- else
- __folio_put_small(folio);
-}
EXPORT_SYMBOL(__folio_put);
/**