Skip to contentSkip to conversation

+ mm-zswap-use-postorder-iteration-when-destroying-rbtree.patch added to -mm tree

PATCH [email protected] 1 participant 1 message Jul 29, 2013

Subsystems (2)
lore
Share & tools
lore

[email protected]

author maintainer
#0 lore raw

Subject: + mm-zswap-use-postorder-iteration-when-destroying-rbtree.patch added to -mm tree
To: [email protected],[email protected],[email protected],[email protected],[email protected]
From: [email protected]
Date: Mon, 29 Jul 2013 15:43:59 -0700

The patch titled
Subject: mm/zswap: use postorder iteration when destroying rbtree
has been added to the -mm tree. Its filename is
mm-zswap-use-postorder-iteration-when-destroying-rbtree.patch

This patch should soon appear at
http://ozlabs.org/~akpm/mmots/broken-out/mm-zswap-use-postorder-iteration-when-destroying-rbtree.patch
and later at
http://ozlabs.org/~akpm/mmotm/broken-out/mm-zswap-use-postorder-iteration-when-destroying-rbtree.patch

Before you just go and hit "reply", please:
a) Consider who else should be cc'ed
b) Prefer to cc a suitable mailing list as well
c) Ideally: find the original patch on the mailing list and do a reply-to-all to that, adding suitable additional cc's

*** Remember to use Documentation/SubmitChecklist when testing your code ***

The -mm tree is included into linux-next and is updated there every 3-4 working days

------------------------------------------------------
From: Cody P Schafer <[email protected]>
Subject: mm/zswap: use postorder iteration when destroying rbtree

---

 mm/zswap.c |   16 ++--------------
 1 file changed, 2 insertions(+), 14 deletions(-)
mm/zswap.c renamed from mm/zswap.c~mm-zswap-use-postorder-iteration-when-destroying-rbtree +2 -14
diff -puN mm/zswap.c~mm-zswap-use-postorder-iteration-when-destroying-rbtree mm/zswap.c
@@ -790,26 +790,14 @@ static void zswap_frontswap_invalidate_p
 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);

_

Patches currently in -mm which might be from [email protected] are

mm-page_alloc-restructure-free-page-stealing-code-and-fix-a-bug.patch mm-page_alloc-restructure-free-page-stealing-code-and-fix-a-bug-fix.patch mm-fix-the-value-of-fallback_migratetype-in-alloc_extfrag-tracepoint.patch rbtree-add-postorder-iteration-functions.patch rbtree-add-rbtree_postorder_for_each_entry_safe-helper.patch rbtree_test-add-test-for-postorder-iteration.patch rbtree-allow-tests-to-run-as-builtin.patch mm-zswap-use-postorder-iteration-when-destroying-rbtree.patch