Subject: + mm-zswap-use-postorder-iteration-when-destroying-rbtree.patch added to -mm tree To: cody@xxxxxxxxxxxxxxxxxx,David.Woodhouse@xxxxxxxxx,riel@xxxxxxxxxx,sjenning@xxxxxxxxxxxxxxxxxx,walken@xxxxxxxxxx From: akpm@xxxxxxxxxxxxxxxxxxxx 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 <cody@xxxxxxxxxxxxxxxxxx> Subject: mm/zswap: use postorder iteration when destroying rbtree Signed-off-by: Cody P Schafer <cody@xxxxxxxxxxxxxxxxxx> Reviewed-by: Seth Jennings <sjenning@xxxxxxxxxxxxxxxxxx> Cc: David Woodhouse <David.Woodhouse@xxxxxxxxx> Cc: Rik van Riel <riel@xxxxxxxxxx> Cc: Michel Lespinasse <walken@xxxxxxxxxx> Signed-off-by: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx> --- mm/zswap.c | 16 ++-------------- 1 file changed, 2 insertions(+), 14 deletions(-) diff -puN mm/zswap.c~mm-zswap-use-postorder-iteration-when-destroying-rbtree mm/zswap.c --- a/mm/zswap.c~mm-zswap-use-postorder-iteration-when-destroying-rbtree +++ a/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 cody@xxxxxxxxxxxxxxxxxx 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 -- To unsubscribe from this list: send the line "unsubscribe mm-commits" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html