Re: [PATCH 5/5] mm/zswap: use postorder iteration when destroying rbtree

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Fri, Jul 26, 2013 at 02:13:43PM -0700, Cody P Schafer wrote:
> Signed-off-by: Cody P Schafer <cody@xxxxxxxxxxxxxxxxxx>
> ---
>  mm/zswap.c | 15 ++-------------
>  1 file changed, 2 insertions(+), 13 deletions(-)
> 
> diff --git a/mm/zswap.c b/mm/zswap.c
> index deda2b6..98d99c4 100644
> --- a/mm/zswap.c
> +++ b/mm/zswap.c
> @@ -791,25 +791,14 @@ static void zswap_frontswap_invalidate_area(unsigned type)
>  {
>  	struct zswap_tree *tree = zswap_trees[type];
>  	struct rb_node *node;

Getting used variable warning on this now.  Just need to remove it.

Seth

> -	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);
> -- 
> 1.8.3.4
> 
> --
> To unsubscribe, send a message with 'unsubscribe linux-mm' in
> the body to majordomo@xxxxxxxxx.  For more info on Linux MM,
> see: http://www.linux-mm.org/ .
> Don't email: <a href=mailto:"dont@xxxxxxxxx";> email@xxxxxxxxx </a>
> 

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@xxxxxxxxx.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@xxxxxxxxx";> email@xxxxxxxxx </a>




[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Bugtraq]     [Linux]     [Linux OMAP]     [Linux MIPS]     [ECOS]     [Asterisk Internet PBX]     [Linux API]