mirror of
https://github.com/hardkernel/linux.git
synced 2026-03-24 19:40:21 +09:00
swap_state: convert free_swap_cache() to use a folio
Saves several calls to compound_head(). Link: https://lkml.kernel.org/r/20220902194653.1739778-40-willy@infradead.org Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
This commit is contained in:
committed by
Andrew Morton
parent
cb691e2f28
commit
aedd74d439
@@ -272,16 +272,19 @@ void clear_shadow_from_swap_cache(int type, unsigned long begin,
|
|||||||
/*
|
/*
|
||||||
* If we are the only user, then try to free up the swap cache.
|
* If we are the only user, then try to free up the swap cache.
|
||||||
*
|
*
|
||||||
* Its ok to check for PageSwapCache without the page lock
|
* Its ok to check the swapcache flag without the folio lock
|
||||||
* here because we are going to recheck again inside
|
* here because we are going to recheck again inside
|
||||||
* try_to_free_swap() _with_ the lock.
|
* folio_free_swap() _with_ the lock.
|
||||||
* - Marcelo
|
* - Marcelo
|
||||||
*/
|
*/
|
||||||
void free_swap_cache(struct page *page)
|
void free_swap_cache(struct page *page)
|
||||||
{
|
{
|
||||||
if (PageSwapCache(page) && !page_mapped(page) && trylock_page(page)) {
|
struct folio *folio = page_folio(page);
|
||||||
try_to_free_swap(page);
|
|
||||||
unlock_page(page);
|
if (folio_test_swapcache(folio) && !folio_mapped(folio) &&
|
||||||
|
folio_trylock(folio)) {
|
||||||
|
folio_free_swap(folio);
|
||||||
|
folio_unlock(folio);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user