mm: zswap: use zswap_invalidate_entry() for duplicates
authorJohannes Weiner <hannes@cmpxchg.org>
Thu, 27 Jul 2023 16:22:23 +0000 (12:22 -0400)
committerAndrew Morton <akpm@linux-foundation.org>
Mon, 21 Aug 2023 20:37:28 +0000 (13:37 -0700)
Patch series "mm: zswap: three cleanups".

Three small cleanups to zswap, the first one suggested by Yosry during the
frontswap removal.

This patch (of 3):

Minor cleanup.  Instead of open-coding the tree deletion and the put, use
the zswap_invalidate_entry() convenience helper.

Link: https://lkml.kernel.org/r/20230727162343.1415598-1-hannes@cmpxchg.org
Link: https://lkml.kernel.org/r/20230727162343.1415598-2-hannes@cmpxchg.org
Signed-off-by: Johannes Weiner <hannes@cmpxchg.org>
Suggested-by: Yosry Ahmed <yosryahmed@google.com>
Reviewed-by: Yosry Ahmed <yosryahmed@google.com>
Cc: Domenico Cerasuolo <cerasuolodomenico@gmail.com>
Cc: Nhat Pham <nphamcs@gmail.com>
Cc: Barry Song <song.bao.hua@hisilicon.com>
Cc: Seth Jennings <sjenning@redhat.com>
Cc: Vitaly Wool <vitaly.wool@konsulko.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
mm/zswap.c

index 7cc4a2baa7132206e32888b7e633287aa1b67b6b..93707a1799b8a51233f96acfef739c3bc3c47e54 100644 (file)
@@ -1370,9 +1370,7 @@ insert_entry:
        spin_lock(&tree->lock);
        while (zswap_rb_insert(&tree->rbroot, entry, &dupentry) == -EEXIST) {
                zswap_duplicate_entry++;
-               /* remove from rbtree */
-               zswap_rb_erase(&tree->rbroot, dupentry);
-               zswap_entry_put(tree, dupentry);
+               zswap_invalidate_entry(tree, dupentry);
        }
        if (entry->length) {
                spin_lock(&entry->pool->lru_lock);