[patch 003/118] mm/swap: optimise get_shadow_from_swap_cache
From: Andrew Morton <akpm@linux-foundation.org>
Date: 2021-02-26 01:15:37
Also in:
mm-commits
From: Andrew Morton <akpm@linux-foundation.org>
Date: 2021-02-26 01:15:37
Also in:
mm-commits
From: "Matthew Wilcox (Oracle)" <willy@infradead.org> Subject: 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 <redacted> Cc: Hugh Dickins <hughd@google.com> Cc: Jan Kara <jack@suse.cz> Cc: Johannes Weiner <hannes@cmpxchg.org> Cc: Kirill A. Shutemov <redacted> Cc: William Kucharski <redacted> Cc: Yang Shi <redacted> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> --- mm/swap_state.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
--- a/mm/swap_state.c~mm-swap-optimise-get_shadow_from_swap_cache
+++ a/mm/swap_state.c@@ -87,11 +87,9 @@ void *get_shadow_from_swap_cache(swp_ent 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; }
_