summaryrefslogtreecommitdiff
path: root/mm
diff options
context:
space:
mode:
authorCody P Schafer <cody@linux.vnet.ibm.com>2013-09-11 14:25:33 -0700
committerChanho Park <chanho61.park@samsung.com>2014-11-18 11:47:20 +0900
commitb0fb92919f3ac9070b158f0b5c2007e9a206fc78 (patch)
tree8e4aae8ed08967dbf09d02856eeccc415379c90c /mm
parentbed3a3fec3fa0360fe66a3cfd89896e7511922dc (diff)
downloadlinux-3.10-b0fb92919f3ac9070b158f0b5c2007e9a206fc78.tar.gz
linux-3.10-b0fb92919f3ac9070b158f0b5c2007e9a206fc78.tar.bz2
linux-3.10-b0fb92919f3ac9070b158f0b5c2007e9a206fc78.zip
mm/zswap: use postorder iteration when destroying rbtree
Change-Id: I83b93b7eaadb7c66981f1119eda1119c978d1b9c Signed-off-by: Cody P Schafer <cody@linux.vnet.ibm.com> Reviewed-by: Seth Jennings <sjenning@linux.vnet.ibm.com> Cc: David Woodhouse <David.Woodhouse@intel.com> Cc: Rik van Riel <riel@redhat.com> Cc: Michel Lespinasse <walken@google.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'mm')
-rw-r--r--mm/zswap.c16
1 files changed, 2 insertions, 14 deletions
diff --git a/mm/zswap.c b/mm/zswap.c
index efed4c8b7f5..841e35f1db2 100644
--- a/mm/zswap.c
+++ b/mm/zswap.c
@@ -790,26 +790,14 @@ static void zswap_frontswap_invalidate_page(unsigned type, pgoff_t offset)
static void zswap_frontswap_invalidate_area(unsigned type)
{
struct zswap_tree *tree = zswap_trees[type];
- struct rb_node *node;
- struct zswap_entry *entry;
+ struct zswap_entry *entry, *n;
if (!tree)
return;
/* walk the tree and free everything */
spin_lock(&tree->lock);
- /*
- * TODO: Even though this code should not be executed because
- * the try_to_unuse() in swapoff should have emptied the tree,
- * it is very wasteful to rebalance the tree after every
- * removal when we are freeing the whole tree.
- *
- * If post-order traversal code is ever added to the rbtree
- * implementation, it should be used here.
- */
- while ((node = rb_first(&tree->rbroot))) {
- entry = rb_entry(node, struct zswap_entry, rbnode);
- rb_erase(&entry->rbnode, &tree->rbroot);
+ rbtree_postorder_for_each_entry_safe(entry, n, &tree->rbroot, rbnode) {
zbud_free(tree->pool, entry->handle);
zswap_entry_cache_free(entry);
atomic_dec(&zswap_stored_pages);