diff options
author | Matthew Wilcox (Oracle) <willy@infradead.org> | 2022-06-17 19:50:10 +0200 |
---|---|---|
committer | akpm <akpm@linux-foundation.org> | 2022-07-04 03:08:47 +0200 |
commit | 2397f780e1e05c7bd7ffebd931931b5d8a45ad8c (patch) | |
tree | e239337e4f9326466454a9369fb3df6811287706 /mm/swapfile.c | |
parent | mm/swap: optimise lru_add_drain_cpu() (diff) | |
download | linux-2397f780e1e05c7bd7ffebd931931b5d8a45ad8c.tar.xz linux-2397f780e1e05c7bd7ffebd931931b5d8a45ad8c.zip |
mm/swap: convert try_to_free_swap to use a folio
Save a few calls to compound_head by converting the passed page to
a folio. Reduces kernel text size by 74 bytes.
Link: https://lkml.kernel.org/r/20220617175020.717127-13-willy@infradead.org
Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Diffstat (limited to 'mm/swapfile.c')
-rw-r--r-- | mm/swapfile.c | 23 |
1 files changed, 11 insertions, 12 deletions
diff --git a/mm/swapfile.c b/mm/swapfile.c index 6a7579951fa4..af6e83911ad2 100644 --- a/mm/swapfile.c +++ b/mm/swapfile.c @@ -1568,16 +1568,15 @@ unlock_out: return ret; } -static bool page_swapped(struct page *page) +static bool folio_swapped(struct folio *folio) { swp_entry_t entry; struct swap_info_struct *si; - if (!IS_ENABLED(CONFIG_THP_SWAP) || likely(!PageTransCompound(page))) - return page_swapcount(page) != 0; + if (!IS_ENABLED(CONFIG_THP_SWAP) || likely(!folio_test_large(folio))) + return page_swapcount(&folio->page) != 0; - page = compound_head(page); - entry.val = page_private(page); + entry = folio_swap_entry(folio); si = _swap_info_get(entry); if (si) return swap_page_trans_huge_swapped(si, entry); @@ -1590,13 +1589,14 @@ static bool page_swapped(struct page *page) */ int try_to_free_swap(struct page *page) { - VM_BUG_ON_PAGE(!PageLocked(page), page); + struct folio *folio = page_folio(page); + VM_BUG_ON_FOLIO(!folio_test_locked(folio), folio); - if (!PageSwapCache(page)) + if (!folio_test_swapcache(folio)) return 0; - if (PageWriteback(page)) + if (folio_test_writeback(folio)) return 0; - if (page_swapped(page)) + if (folio_swapped(folio)) return 0; /* @@ -1617,9 +1617,8 @@ int try_to_free_swap(struct page *page) if (pm_suspended_storage()) return 0; - page = compound_head(page); - delete_from_swap_cache(page); - SetPageDirty(page); + delete_from_swap_cache(&folio->page); + folio_set_dirty(folio); return 1; } |