From: Matthew Wilcox (Oracle) Date: Fri, 26 Feb 2021 01:15:33 +0000 (-0800) Subject: mm/swap: optimise get_shadow_from_swap_cache X-Git-Url: http://git.maquefel.me/?a=commitdiff_plain;h=8c647dd1e39573f23a4ca25c09f82716b70e702c;p=linux.git 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) Reviewed-by: Christoph Hellwig Cc: Dave Chinner Cc: Hugh Dickins Cc: Jan Kara Cc: Johannes Weiner Cc: Kirill A. Shutemov Cc: William Kucharski Cc: Yang Shi Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- diff --git a/mm/swap_state.c b/mm/swap_state.c index c1a648d9092bd..f270c30d46813 100644 --- a/mm/swap_state.c +++ b/mm/swap_state.c @@ -87,11 +87,9 @@ void *get_shadow_from_swap_cache(swp_entry_t entry) pgoff_t idx = swp_offset(entry); struct page *page; - page = find_get_entry(address_space, idx); + page = xa_load(&address_space->i_pages, idx); if (xa_is_value(page)) return page; - if (page) - put_page(page); return NULL; }