summaryrefslogtreecommitdiff
path: root/mm
diff options
context:
space:
mode:
authorMatthew Wilcox (Oracle) <willy@infradead.org>2024-02-27 17:42:40 +0000
committerAndrew Morton <akpm@linux-foundation.org>2024-03-04 17:01:23 -0800
commit7c33b8c4229af19797c78de48827ca70228c1f47 (patch)
tree15ad5d9a31cac443f63e93bf9db6b11eb68bba23 /mm
parent4882c80975e2bf7241a5b043eb1dbe8df2726a29 (diff)
mm: remove use of folio list from folios_put()
Instead of putting the interesting folios on a list, delete the uninteresting one from the folio_batch. Link: https://lkml.kernel.org/r/20240227174254.710559-7-willy@infradead.org Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org> Reviewed-by: Ryan Roberts <ryan.roberts@arm.com> Cc: David Hildenbrand <david@redhat.com> Cc: Mel Gorman <mgorman@suse.de> Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Diffstat (limited to 'mm')
-rw-r--r--mm/swap.c19
1 files changed, 12 insertions, 7 deletions
diff --git a/mm/swap.c b/mm/swap.c
index 1cfb7b897ebd..ee8b131bf32c 100644
--- a/mm/swap.c
+++ b/mm/swap.c
@@ -961,12 +961,11 @@ void lru_cache_disable(void)
*/
void folios_put_refs(struct folio_batch *folios, unsigned int *refs)
{
- int i;
- LIST_HEAD(pages_to_free);
+ int i, j;
struct lruvec *lruvec = NULL;
unsigned long flags = 0;
- for (i = 0; i < folios->nr; i++) {
+ for (i = 0, j = 0; i < folios->nr; i++) {
struct folio *folio = folios->folios[i];
unsigned int nr_refs = refs ? refs[i] : 1;
@@ -1016,14 +1015,20 @@ void folios_put_refs(struct folio_batch *folios, unsigned int *refs)
count_vm_event(UNEVICTABLE_PGCLEARED);
}
- list_add(&folio->lru, &pages_to_free);
+ if (j != i)
+ folios->folios[j] = folio;
+ j++;
}
if (lruvec)
unlock_page_lruvec_irqrestore(lruvec, flags);
+ if (!j) {
+ folio_batch_reinit(folios);
+ return;
+ }
- mem_cgroup_uncharge_list(&pages_to_free);
- free_unref_page_list(&pages_to_free);
- folio_batch_reinit(folios);
+ folios->nr = j;
+ mem_cgroup_uncharge_folios(folios);
+ free_unref_folios(folios);
}
EXPORT_SYMBOL(folios_put_refs);