aboutsummaryrefslogtreecommitdiff
path: root/mm/swapfile.c
diff options
context:
space:
mode:
authorGravatar Chengming Zhou <zhouchengming@bytedance.com> 2024-02-04 03:06:00 +0000
committerGravatar Andrew Morton <akpm@linux-foundation.org> 2024-02-22 10:24:54 -0800
commit0827a1fb143fae588cb6f5b9a97c405d6c2ddec9 (patch)
tree76de3ff51d3ad34fbc26d8743134ce1b383d4fd9 /mm/swapfile.c
parentmm/zswap: add more comments in shrink_memcg_cb() (diff)
downloadlinux-0827a1fb143fae588cb6f5b9a97c405d6c2ddec9.tar.gz
linux-0827a1fb143fae588cb6f5b9a97c405d6c2ddec9.tar.bz2
linux-0827a1fb143fae588cb6f5b9a97c405d6c2ddec9.zip
mm/zswap: invalidate zswap entry when swap entry free
During testing I found there are some times the zswap_writeback_entry() return -ENOMEM, which is not we expected: bpftrace -e 'kr:zswap_writeback_entry {@[(int32)retval]=count()}' @[-12]: 1563 @[0]: 277221 The reason is that __read_swap_cache_async() return NULL because swapcache_prepare() failed. The reason is that we won't invalidate zswap entry when swap entry freed to the per-cpu pool, these zswap entries are still on the zswap tree and lru list. This patch moves the invalidation ahead to when swap entry freed to the per-cpu pool, since there is no any benefit to leave trashy zswap entry on the tree and lru list. With this patch: bpftrace -e 'kr:zswap_writeback_entry {@[(int32)retval]=count()}' @[0]: 259744 Note: large folio can't have zswap entry for now, so don't bother to add zswap entry invalidation in the large folio swap free path. Link: https://lkml.kernel.org/r/20240201-b4-zswap-invalidate-entry-v2-2-99d4084260a0@bytedance.com Signed-off-by: Chengming Zhou <zhouchengming@bytedance.com> Reviewed-by: Nhat Pham <nphamcs@gmail.com> Acked-by: Johannes Weiner <hannes@cmpxchg.org> Acked-by: Yosry Ahmed <yosryahmed@google.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Diffstat (limited to 'mm/swapfile.c')
-rw-r--r--mm/swapfile.c1
1 files changed, 0 insertions, 1 deletions
diff --git a/mm/swapfile.c b/mm/swapfile.c
index a8edaf4e5b8a..d1bd8d1e17bd 100644
--- a/mm/swapfile.c
+++ b/mm/swapfile.c
@@ -744,7 +744,6 @@ static void swap_range_free(struct swap_info_struct *si, unsigned long offset,
swap_slot_free_notify = NULL;
while (offset <= end) {
arch_swap_invalidate_page(si->type, offset);
- zswap_invalidate(si->type, offset);
if (swap_slot_free_notify)
swap_slot_free_notify(si->bdev, offset);
offset++;