Commit 000085b9 authored by Matthew Wilcox (Oracle)'s avatar Matthew Wilcox (Oracle) Committed by Andrew Morton

swapfile: convert try_to_unuse() to use a folio

Saves five calls to compound_head().

Link: https://lkml.kernel.org/r/20220902194653.1739778-35-willy@infradead.orgSigned-off-by: default avatarMatthew Wilcox (Oracle) <willy@infradead.org>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
parent 923e2f0e
...@@ -2032,7 +2032,7 @@ static int try_to_unuse(unsigned int type) ...@@ -2032,7 +2032,7 @@ static int try_to_unuse(unsigned int type)
struct list_head *p; struct list_head *p;
int retval = 0; int retval = 0;
struct swap_info_struct *si = swap_info[type]; struct swap_info_struct *si = swap_info[type];
struct page *page; struct folio *folio;
swp_entry_t entry; swp_entry_t entry;
unsigned int i; unsigned int i;
...@@ -2082,21 +2082,21 @@ static int try_to_unuse(unsigned int type) ...@@ -2082,21 +2082,21 @@ static int try_to_unuse(unsigned int type)
(i = find_next_to_unuse(si, i)) != 0) { (i = find_next_to_unuse(si, i)) != 0) {
entry = swp_entry(type, i); entry = swp_entry(type, i);
page = find_get_page(swap_address_space(entry), i); folio = filemap_get_folio(swap_address_space(entry), i);
if (!page) if (!folio)
continue; continue;
/* /*
* It is conceivable that a racing task removed this page from * It is conceivable that a racing task removed this folio from
* swap cache just before we acquired the page lock. The page * swap cache just before we acquired the page lock. The folio
* might even be back in swap cache on another swap area. But * might even be back in swap cache on another swap area. But
* that is okay, try_to_free_swap() only removes stale pages. * that is okay, folio_free_swap() only removes stale folios.
*/ */
lock_page(page); folio_lock(folio);
wait_on_page_writeback(page); folio_wait_writeback(folio);
try_to_free_swap(page); folio_free_swap(folio);
unlock_page(page); folio_unlock(folio);
put_page(page); folio_put(folio);
} }
/* /*
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment