Commit 4081f744 authored by Matthew Wilcox (Oracle)'s avatar Matthew Wilcox (Oracle) Committed by Andrew Morton

mm/swap: convert put_swap_page() to put_swap_folio()

With all callers now using a folio, we can convert this function.

Link: https://lkml.kernel.org/r/20220902194653.1739778-14-willy@infradead.orgSigned-off-by: default avatarMatthew Wilcox (Oracle) <willy@infradead.org>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
parent a4c366f0
...@@ -491,7 +491,7 @@ static inline long get_nr_swap_pages(void) ...@@ -491,7 +491,7 @@ static inline long get_nr_swap_pages(void)
extern void si_swapinfo(struct sysinfo *); extern void si_swapinfo(struct sysinfo *);
swp_entry_t folio_alloc_swap(struct folio *folio); swp_entry_t folio_alloc_swap(struct folio *folio);
bool folio_free_swap(struct folio *folio); bool folio_free_swap(struct folio *folio);
extern void put_swap_page(struct page *page, swp_entry_t entry); void put_swap_folio(struct folio *folio, swp_entry_t entry);
extern swp_entry_t get_swap_page_of_type(int); extern swp_entry_t get_swap_page_of_type(int);
extern int get_swap_pages(int n, swp_entry_t swp_entries[], int entry_size); extern int get_swap_pages(int n, swp_entry_t swp_entries[], int entry_size);
extern int add_swap_count_continuation(swp_entry_t, gfp_t); extern int add_swap_count_continuation(swp_entry_t, gfp_t);
...@@ -576,7 +576,7 @@ static inline void swap_free(swp_entry_t swp) ...@@ -576,7 +576,7 @@ static inline void swap_free(swp_entry_t swp)
{ {
} }
static inline void put_swap_page(struct page *page, swp_entry_t swp) static inline void put_swap_folio(struct folio *folio, swp_entry_t swp)
{ {
} }
......
...@@ -1424,7 +1424,7 @@ static int shmem_writepage(struct page *page, struct writeback_control *wbc) ...@@ -1424,7 +1424,7 @@ static int shmem_writepage(struct page *page, struct writeback_control *wbc)
} }
mutex_unlock(&shmem_swaplist_mutex); mutex_unlock(&shmem_swaplist_mutex);
put_swap_page(&folio->page, swap); put_swap_folio(folio, swap);
redirty: redirty:
folio_mark_dirty(folio); folio_mark_dirty(folio);
if (wbc->for_reclaim) if (wbc->for_reclaim)
......
...@@ -343,7 +343,7 @@ swp_entry_t folio_alloc_swap(struct folio *folio) ...@@ -343,7 +343,7 @@ swp_entry_t folio_alloc_swap(struct folio *folio)
get_swap_pages(1, &entry, 1); get_swap_pages(1, &entry, 1);
out: out:
if (mem_cgroup_try_charge_swap(folio, entry)) { if (mem_cgroup_try_charge_swap(folio, entry)) {
put_swap_page(&folio->page, entry); put_swap_folio(folio, entry);
entry.val = 0; entry.val = 0;
} }
return entry; return entry;
......
...@@ -218,7 +218,7 @@ bool add_to_swap(struct folio *folio) ...@@ -218,7 +218,7 @@ bool add_to_swap(struct folio *folio)
return true; return true;
fail: fail:
put_swap_page(&folio->page, entry); put_swap_folio(folio, entry);
return false; return false;
} }
...@@ -237,7 +237,7 @@ void delete_from_swap_cache(struct folio *folio) ...@@ -237,7 +237,7 @@ void delete_from_swap_cache(struct folio *folio)
__delete_from_swap_cache(folio, entry, NULL); __delete_from_swap_cache(folio, entry, NULL);
xa_unlock_irq(&address_space->i_pages); xa_unlock_irq(&address_space->i_pages);
put_swap_page(&folio->page, entry); put_swap_folio(folio, entry);
folio_ref_sub(folio, folio_nr_pages(folio)); folio_ref_sub(folio, folio_nr_pages(folio));
} }
...@@ -498,7 +498,7 @@ struct page *__read_swap_cache_async(swp_entry_t entry, gfp_t gfp_mask, ...@@ -498,7 +498,7 @@ struct page *__read_swap_cache_async(swp_entry_t entry, gfp_t gfp_mask,
return &folio->page; return &folio->page;
fail_unlock: fail_unlock:
put_swap_page(&folio->page, entry); put_swap_folio(folio, entry);
folio_unlock(folio); folio_unlock(folio);
folio_put(folio); folio_put(folio);
return NULL; return NULL;
......
...@@ -1332,7 +1332,7 @@ void swap_free(swp_entry_t entry) ...@@ -1332,7 +1332,7 @@ void swap_free(swp_entry_t entry)
/* /*
* Called after dropping swapcache to decrease refcnt to swap entries. * Called after dropping swapcache to decrease refcnt to swap entries.
*/ */
void put_swap_page(struct page *page, swp_entry_t entry) void put_swap_folio(struct folio *folio, swp_entry_t entry)
{ {
unsigned long offset = swp_offset(entry); unsigned long offset = swp_offset(entry);
unsigned long idx = offset / SWAPFILE_CLUSTER; unsigned long idx = offset / SWAPFILE_CLUSTER;
...@@ -1341,7 +1341,7 @@ void put_swap_page(struct page *page, swp_entry_t entry) ...@@ -1341,7 +1341,7 @@ void put_swap_page(struct page *page, swp_entry_t entry)
unsigned char *map; unsigned char *map;
unsigned int i, free_entries = 0; unsigned int i, free_entries = 0;
unsigned char val; unsigned char val;
int size = swap_entry_size(thp_nr_pages(page)); int size = swap_entry_size(folio_nr_pages(folio));
si = _swap_info_get(entry); si = _swap_info_get(entry);
if (!si) if (!si)
......
...@@ -1352,7 +1352,7 @@ static int __remove_mapping(struct address_space *mapping, struct folio *folio, ...@@ -1352,7 +1352,7 @@ static int __remove_mapping(struct address_space *mapping, struct folio *folio,
mem_cgroup_swapout(folio, swap); mem_cgroup_swapout(folio, swap);
__delete_from_swap_cache(folio, swap, shadow); __delete_from_swap_cache(folio, swap, shadow);
xa_unlock_irq(&mapping->i_pages); xa_unlock_irq(&mapping->i_pages);
put_swap_page(&folio->page, swap); put_swap_folio(folio, swap);
} else { } else {
void (*free_folio)(struct folio *); void (*free_folio)(struct 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