Skip to content

Commit 8c647dd

Browse files
Matthew Wilcox (Oracle)torvalds
authored andcommitted
mm/swap: optimise get_shadow_from_swap_cache
There's no need to get a reference to the page, just load the entry and see if it's a shadow entry. Link: https://lkml.kernel.org/r/20201112212641.27837-4-willy@infradead.org Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org> Reviewed-by: Christoph Hellwig <hch@lst.de> Cc: Dave Chinner <dchinner@redhat.com> Cc: Hugh Dickins <hughd@google.com> Cc: Jan Kara <jack@suse.cz> Cc: Johannes Weiner <hannes@cmpxchg.org> Cc: Kirill A. Shutemov <kirill.shutemov@linux.intel.com> Cc: William Kucharski <william.kucharski@oracle.com> Cc: Yang Shi <yang.shi@linux.alibaba.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
1 parent 96888e0 commit 8c647dd

File tree

1 file changed

+1
-3
lines changed

1 file changed

+1
-3
lines changed

mm/swap_state.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -87,11 +87,9 @@ void *get_shadow_from_swap_cache(swp_entry_t entry)
8787
pgoff_t idx = swp_offset(entry);
8888
struct page *page;
8989

90-
page = find_get_entry(address_space, idx);
90+
page = xa_load(&address_space->i_pages, idx);
9191
if (xa_is_value(page))
9292
return page;
93-
if (page)
94-
put_page(page);
9593
return NULL;
9694
}
9795

0 commit comments

Comments
 (0)