mm: zswap: clean up zswap_entry_put()
authorJohannes Weiner <hannes@cmpxchg.org>
Tue, 30 Jan 2024 01:36:41 +0000 (20:36 -0500)
committerAndrew Morton <akpm@linux-foundation.org>
Thu, 22 Feb 2024 18:24:43 +0000 (10:24 -0800)
Remove stale comment and unnecessary local variable.

Link: https://lkml.kernel.org/r/20240130014208.565554-6-hannes@cmpxchg.org
Signed-off-by: Johannes Weiner <hannes@cmpxchg.org>
Acked-by: Yosry Ahmed <yosryahmed@google.com>
Reviewed-by: Nhat Pham <nphamcs@gmail.com>
Reviewed-by: Chengming Zhou <zhouchengming@bytedance.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
mm/zswap.c

index 70e409add32b2edd65b35912740d915336ff48b0..32bcc291397ffc4ebbe6083d15beba7b741d16b0 100644 (file)
@@ -545,15 +545,11 @@ static void zswap_entry_get(struct zswap_entry *entry)
        entry->refcount++;
 }
 
-/* caller must hold the tree lock
-* remove from the tree and free it, if nobody reference the entry
-*/
+/* caller must hold the tree lock */
 static void zswap_entry_put(struct zswap_entry *entry)
 {
-       int refcount = --entry->refcount;
-
-       WARN_ON_ONCE(refcount < 0);
-       if (refcount == 0) {
+       WARN_ON_ONCE(!entry->refcount);
+       if (--entry->refcount == 0) {
                WARN_ON_ONCE(!RB_EMPTY_NODE(&entry->rbnode));
                zswap_entry_free(entry);
        }