[PATCH 5/5] swap: avoid ra statistic lost when swapin races

From: Kairui Song
Date: Thu Dec 08 2022 - 13:04:04 EST


From: Kairui Song <kasong@xxxxxxxxxxx>

__read_swap_cache_async should just call swap_cache_get_folio for trying
to look up the swap cache. Because swap_cache_get_folio handles the
readahead statistic, and clears the RA flag, looking up the cache
directly will skip these parts.

And the comment no longer applies after commit 442701e7058b
("mm/swap: remove swap_cache_info statistics"), just remove them.

Fixes: 442701e7058b ("mm/swap: remove swap_cache_info statistics")
Signed-off-by: Kairui Song <kasong@xxxxxxxxxxx>
---
mm/swap_state.c | 7 ++-----
1 file changed, 2 insertions(+), 5 deletions(-)

diff --git a/mm/swap_state.c b/mm/swap_state.c
index eba388f67741..f39cfb62551d 100644
--- a/mm/swap_state.c
+++ b/mm/swap_state.c
@@ -418,15 +418,12 @@ struct page *__read_swap_cache_async(swp_entry_t entry, gfp_t gfp_mask,
for (;;) {
int err;
/*
- * First check the swap cache. Since this is normally
- * called after swap_cache_get_folio() failed, re-calling
- * that would confuse statistics.
+ * First check the swap cache in case of race.
*/
si = get_swap_device(entry);
if (!si)
return NULL;
- folio = filemap_get_folio(swap_address_space(entry),
- swp_offset(entry));
+ folio = swap_cache_get_folio(entry, vma, addr);
put_swap_device(si);
if (folio)
return folio_file_page(folio, swp_offset(entry));
--
2.35.2