mm/swap: optimise get_shadow_from_swap_cache
authorMatthew Wilcox (Oracle) <willy@infradead.org>
Fri, 26 Feb 2021 01:15:33 +0000 (17:15 -0800)
committerLinus Torvalds <torvalds@linux-foundation.org>
Fri, 26 Feb 2021 17:40:59 +0000 (09:40 -0800)
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>
mm/swap_state.c

index c1a648d..f270c30 100644 (file)
@@ -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;
 }