Commit 3d2c9087 authored by David Hildenbrand's avatar David Hildenbrand Committed by Andrew Morton

mm/swap: inline folio_set_swap_entry() and folio_swap_entry()

Let's simply work on the folio directly and remove the helpers.

Link: https://lkml.kernel.org/r/20230821160849.531668-4-david@redhat.comSigned-off-by: default avatarDavid Hildenbrand <david@redhat.com>
Suggested-by: default avatarMatthew Wilcox <willy@infradead.org>
Reviewed-by: default avatarChris Li <chrisl@kernel.org>
Cc: Catalin Marinas <catalin.marinas@arm.com>
Cc: Dan Streetman <ddstreet@ieee.org>
Cc: Hugh Dickins <hughd@google.com>
Cc: Peter Xu <peterx@redhat.com>
Cc: Seth Jennings <sjenning@redhat.com>
Cc: Vitaly Wool <vitaly.wool@konsulko.com>
Cc: Will Deacon <will@kernel.org>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
parent 85a13334
...@@ -333,25 +333,15 @@ struct swap_info_struct { ...@@ -333,25 +333,15 @@ struct swap_info_struct {
*/ */
}; };
static inline swp_entry_t folio_swap_entry(struct folio *folio)
{
return folio->swap;
}
static inline swp_entry_t page_swap_entry(struct page *page) static inline swp_entry_t page_swap_entry(struct page *page)
{ {
struct folio *folio = page_folio(page); struct folio *folio = page_folio(page);
swp_entry_t entry = folio_swap_entry(folio); swp_entry_t entry = folio->swap;
entry.val += folio_page_idx(folio, page); entry.val += folio_page_idx(folio, page);
return entry; return entry;
} }
static inline void folio_set_swap_entry(struct folio *folio, swp_entry_t entry)
{
folio->swap = entry;
}
/* linux/mm/workingset.c */ /* linux/mm/workingset.c */
bool workingset_test_recent(void *shadow, bool file, bool *workingset); bool workingset_test_recent(void *shadow, bool file, bool *workingset);
void workingset_age_nonresident(struct lruvec *lruvec, unsigned long nr_pages); void workingset_age_nonresident(struct lruvec *lruvec, unsigned long nr_pages);
......
...@@ -3828,7 +3828,7 @@ vm_fault_t do_swap_page(struct vm_fault *vmf) ...@@ -3828,7 +3828,7 @@ vm_fault_t do_swap_page(struct vm_fault *vmf)
folio_add_lru(folio); folio_add_lru(folio);
/* To provide entry to swap_readpage() */ /* To provide entry to swap_readpage() */
folio_set_swap_entry(folio, entry); folio->swap = entry;
swap_readpage(page, true, NULL); swap_readpage(page, true, NULL);
folio->private = NULL; folio->private = NULL;
} }
......
...@@ -1642,7 +1642,7 @@ static int shmem_replace_folio(struct folio **foliop, gfp_t gfp, ...@@ -1642,7 +1642,7 @@ static int shmem_replace_folio(struct folio **foliop, gfp_t gfp,
int error; int error;
old = *foliop; old = *foliop;
entry = folio_swap_entry(old); entry = old->swap;
swap_index = swp_offset(entry); swap_index = swp_offset(entry);
swap_mapping = swap_address_space(entry); swap_mapping = swap_address_space(entry);
...@@ -1663,7 +1663,7 @@ static int shmem_replace_folio(struct folio **foliop, gfp_t gfp, ...@@ -1663,7 +1663,7 @@ static int shmem_replace_folio(struct folio **foliop, gfp_t gfp,
__folio_set_locked(new); __folio_set_locked(new);
__folio_set_swapbacked(new); __folio_set_swapbacked(new);
folio_mark_uptodate(new); folio_mark_uptodate(new);
folio_set_swap_entry(new, entry); new->swap = entry;
folio_set_swapcache(new); folio_set_swapcache(new);
/* /*
...@@ -1785,7 +1785,7 @@ static int shmem_swapin_folio(struct inode *inode, pgoff_t index, ...@@ -1785,7 +1785,7 @@ static int shmem_swapin_folio(struct inode *inode, pgoff_t index,
/* We have to do this with folio locked to prevent races */ /* We have to do this with folio locked to prevent races */
folio_lock(folio); folio_lock(folio);
if (!folio_test_swapcache(folio) || if (!folio_test_swapcache(folio) ||
folio_swap_entry(folio).val != swap.val || folio->swap.val != swap.val ||
!shmem_confirm_swap(mapping, index, swap)) { !shmem_confirm_swap(mapping, index, swap)) {
error = -EEXIST; error = -EEXIST;
goto unlock; goto unlock;
......
...@@ -100,7 +100,7 @@ int add_to_swap_cache(struct folio *folio, swp_entry_t entry, ...@@ -100,7 +100,7 @@ int add_to_swap_cache(struct folio *folio, swp_entry_t entry,
folio_ref_add(folio, nr); folio_ref_add(folio, nr);
folio_set_swapcache(folio); folio_set_swapcache(folio);
folio_set_swap_entry(folio, entry); folio->swap = entry;
do { do {
xas_lock_irq(&xas); xas_lock_irq(&xas);
...@@ -156,8 +156,7 @@ void __delete_from_swap_cache(struct folio *folio, ...@@ -156,8 +156,7 @@ void __delete_from_swap_cache(struct folio *folio,
VM_BUG_ON_PAGE(entry != folio, entry); VM_BUG_ON_PAGE(entry != folio, entry);
xas_next(&xas); xas_next(&xas);
} }
entry.val = 0; folio->swap.val = 0;
folio_set_swap_entry(folio, entry);
folio_clear_swapcache(folio); folio_clear_swapcache(folio);
address_space->nrpages -= nr; address_space->nrpages -= nr;
__node_stat_mod_folio(folio, NR_FILE_PAGES, -nr); __node_stat_mod_folio(folio, NR_FILE_PAGES, -nr);
...@@ -233,7 +232,7 @@ bool add_to_swap(struct folio *folio) ...@@ -233,7 +232,7 @@ bool add_to_swap(struct folio *folio)
*/ */
void delete_from_swap_cache(struct folio *folio) void delete_from_swap_cache(struct folio *folio)
{ {
swp_entry_t entry = folio_swap_entry(folio); swp_entry_t entry = folio->swap;
struct address_space *address_space = swap_address_space(entry); struct address_space *address_space = swap_address_space(entry);
xa_lock_irq(&address_space->i_pages); xa_lock_irq(&address_space->i_pages);
......
...@@ -1536,7 +1536,7 @@ static bool swap_page_trans_huge_swapped(struct swap_info_struct *si, ...@@ -1536,7 +1536,7 @@ static bool swap_page_trans_huge_swapped(struct swap_info_struct *si,
static bool folio_swapped(struct folio *folio) static bool folio_swapped(struct folio *folio)
{ {
swp_entry_t entry = folio_swap_entry(folio); swp_entry_t entry = folio->swap;
struct swap_info_struct *si = _swap_info_get(entry); struct swap_info_struct *si = _swap_info_get(entry);
if (!si) if (!si)
......
...@@ -764,7 +764,7 @@ struct address_space *folio_mapping(struct folio *folio) ...@@ -764,7 +764,7 @@ struct address_space *folio_mapping(struct folio *folio)
return NULL; return NULL;
if (unlikely(folio_test_swapcache(folio))) if (unlikely(folio_test_swapcache(folio)))
return swap_address_space(folio_swap_entry(folio)); return swap_address_space(folio->swap);
mapping = folio->mapping; mapping = folio->mapping;
if ((unsigned long)mapping & PAGE_MAPPING_FLAGS) if ((unsigned long)mapping & PAGE_MAPPING_FLAGS)
......
...@@ -1423,7 +1423,7 @@ static int __remove_mapping(struct address_space *mapping, struct folio *folio, ...@@ -1423,7 +1423,7 @@ static int __remove_mapping(struct address_space *mapping, struct folio *folio,
} }
if (folio_test_swapcache(folio)) { if (folio_test_swapcache(folio)) {
swp_entry_t swap = folio_swap_entry(folio); swp_entry_t swap = folio->swap;
if (reclaimed && !mapping_exiting(mapping)) if (reclaimed && !mapping_exiting(mapping))
shadow = workingset_eviction(folio, target_memcg); shadow = workingset_eviction(folio, target_memcg);
......
...@@ -1190,7 +1190,7 @@ static void zswap_fill_page(void *ptr, unsigned long value) ...@@ -1190,7 +1190,7 @@ static void zswap_fill_page(void *ptr, unsigned long value)
bool zswap_store(struct folio *folio) bool zswap_store(struct folio *folio)
{ {
swp_entry_t swp = folio_swap_entry(folio); swp_entry_t swp = folio->swap;
int type = swp_type(swp); int type = swp_type(swp);
pgoff_t offset = swp_offset(swp); pgoff_t offset = swp_offset(swp);
struct page *page = &folio->page; struct page *page = &folio->page;
...@@ -1370,7 +1370,7 @@ bool zswap_store(struct folio *folio) ...@@ -1370,7 +1370,7 @@ bool zswap_store(struct folio *folio)
bool zswap_load(struct folio *folio) bool zswap_load(struct folio *folio)
{ {
swp_entry_t swp = folio_swap_entry(folio); swp_entry_t swp = folio->swap;
int type = swp_type(swp); int type = swp_type(swp);
pgoff_t offset = swp_offset(swp); pgoff_t offset = swp_offset(swp);
struct page *page = &folio->page; struct page *page = &folio->page;
......
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