mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-09-27 21:03:32 +00:00
mm: use free_unref_folios() in put_pages_list()
Break up the list of folios into batches here so that the folios are more likely to be cache hot when doing the rest of the processing. Link: https://lkml.kernel.org/r/20240227174254.710559-8-willy@infradead.org Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org> Cc: David Hildenbrand <david@redhat.com> Cc: Mel Gorman <mgorman@suse.de> Cc: Ryan Roberts <ryan.roberts@arm.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
This commit is contained in:
parent
7c33b8c422
commit
24835f899c
1 changed files with 10 additions and 7 deletions
17
mm/swap.c
17
mm/swap.c
|
@ -138,22 +138,25 @@ EXPORT_SYMBOL(__folio_put);
|
||||||
*/
|
*/
|
||||||
void put_pages_list(struct list_head *pages)
|
void put_pages_list(struct list_head *pages)
|
||||||
{
|
{
|
||||||
struct folio *folio, *next;
|
struct folio_batch fbatch;
|
||||||
|
struct folio *folio;
|
||||||
|
|
||||||
list_for_each_entry_safe(folio, next, pages, lru) {
|
folio_batch_init(&fbatch);
|
||||||
if (!folio_put_testzero(folio)) {
|
list_for_each_entry(folio, pages, lru) {
|
||||||
list_del(&folio->lru);
|
if (!folio_put_testzero(folio))
|
||||||
continue;
|
continue;
|
||||||
}
|
|
||||||
if (folio_test_large(folio)) {
|
if (folio_test_large(folio)) {
|
||||||
list_del(&folio->lru);
|
|
||||||
__folio_put_large(folio);
|
__folio_put_large(folio);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
/* LRU flag must be clear because it's passed using the lru */
|
/* LRU flag must be clear because it's passed using the lru */
|
||||||
|
if (folio_batch_add(&fbatch, folio) > 0)
|
||||||
|
continue;
|
||||||
|
free_unref_folios(&fbatch);
|
||||||
}
|
}
|
||||||
|
|
||||||
free_unref_page_list(pages);
|
if (fbatch.nr)
|
||||||
|
free_unref_folios(&fbatch);
|
||||||
INIT_LIST_HEAD(pages);
|
INIT_LIST_HEAD(pages);
|
||||||
}
|
}
|
||||||
EXPORT_SYMBOL(put_pages_list);
|
EXPORT_SYMBOL(put_pages_list);
|
||||||
|
|
Loading…
Reference in a new issue