summaryrefslogtreecommitdiffstats
path: root/mm/zswap.c
diff options
context:
space:
mode:
authorYosry Ahmed <yosryahmed@google.com>2024-01-24 04:51:12 +0000
committerAndrew Morton <akpm@linux-foundation.org>2024-02-22 10:24:39 -0800
commit83e68f25decdc8d133dbfedd18b93f5267430049 (patch)
treed724a23f790ad35341791a0a375d442af49bffff /mm/zswap.c
parent64cf264c8fefd013208904e2d1b5ba4ee26ca079 (diff)
downloadlinux-83e68f25decdc8d133dbfedd18b93f5267430049.tar.gz
linux-83e68f25decdc8d133dbfedd18b93f5267430049.tar.bz2
linux-83e68f25decdc8d133dbfedd18b93f5267430049.zip
mm: zswap: remove unnecessary trees cleanups in zswap_swapoff()
During swapoff, try_to_unuse() makes sure that zswap_invalidate() is called for all swap entries before zswap_swapoff() is called. This means that all zswap entries should already be removed from the tree. Simplify zswap_swapoff() by removing the trees cleanup code, and leave an assertion in its place. Link: https://lkml.kernel.org/r/20240124045113.415378-3-yosryahmed@google.com Signed-off-by: Yosry Ahmed <yosryahmed@google.com> Reviewed-by: Chengming Zhou <zhouchengming@bytedance.com> Cc: Chris Li <chrisl@kernel.org> Cc: "Huang, Ying" <ying.huang@intel.com> Cc: Johannes Weiner <hannes@cmpxchg.org> Cc: Nhat Pham <nphamcs@gmail.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Diffstat (limited to 'mm/zswap.c')
-rw-r--r--mm/zswap.c16
1 files changed, 3 insertions, 13 deletions
diff --git a/mm/zswap.c b/mm/zswap.c
index 464179d43399..0e4a869b6fd8 100644
--- a/mm/zswap.c
+++ b/mm/zswap.c
@@ -1808,19 +1808,9 @@ void zswap_swapoff(int type)
if (!trees)
return;
- for (i = 0; i < nr_zswap_trees[type]; i++) {
- struct zswap_tree *tree = trees + i;
- struct zswap_entry *entry, *n;
-
- /* walk the tree and free everything */
- spin_lock(&tree->lock);
- rbtree_postorder_for_each_entry_safe(entry, n,
- &tree->rbroot,
- rbnode)
- zswap_free_entry(entry);
- tree->rbroot = RB_ROOT;
- spin_unlock(&tree->lock);
- }
+ /* try_to_unuse() invalidated all the entries already */
+ for (i = 0; i < nr_zswap_trees[type]; i++)
+ WARN_ON_ONCE(!RB_EMPTY_ROOT(&trees[i].rbroot));
kvfree(trees);
nr_zswap_trees[type] = 0;