Merge tag 'trace-v5.16-3' of git://git.kernel.org/pub/scm/linux/kernel/git/rostedt...
[linux-2.6-microblaze.git] / mm / swap.c
index 8ff9ba7..1841c24 100644 (file)
--- a/mm/swap.c
+++ b/mm/swap.c
@@ -135,18 +135,27 @@ EXPORT_SYMBOL(__put_page);
  * put_pages_list() - release a list of pages
  * @pages: list of pages threaded on page->lru
  *
- * Release a list of pages which are strung together on page.lru.  Currently
- * used by read_cache_pages() and related error recovery code.
+ * Release a list of pages which are strung together on page.lru.
  */
 void put_pages_list(struct list_head *pages)
 {
-       while (!list_empty(pages)) {
-               struct page *victim;
+       struct page *page, *next;
 
-               victim = lru_to_page(pages);
-               list_del(&victim->lru);
-               put_page(victim);
+       list_for_each_entry_safe(page, next, pages, lru) {
+               if (!put_page_testzero(page)) {
+                       list_del(&page->lru);
+                       continue;
+               }
+               if (PageHead(page)) {
+                       list_del(&page->lru);
+                       __put_compound_page(page);
+                       continue;
+               }
+               /* Cannot be PageLRU because it's passed to us using the lru */
+               __ClearPageWaiters(page);
        }
+
+       free_unref_page_list(pages);
 }
 EXPORT_SYMBOL(put_pages_list);