Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1378954

[PATCH 05/19] radix-tree: Remove a use of root->height from delete_node

From Matthew Wilcox <willy@linux.intel.com>
Newsgroups linux.kernel
Subject [PATCH 05/19] radix-tree: Remove a use of root->height from delete_node
Date 2016-04-14 16:40 +0200
Message-ID <rnQB6-33W-65@gated-at.bofh.it> (permalink)
References <rnQB5-33W-35@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


If radix_tree_shrink returns whether it managed to shrink, then
__radix_tree_delete_node doesn't ned to query the tree to find out
whether it did any work or not.

Signed-off-by: Matthew Wilcox <willy@linux.intel.com>
---
 lib/radix-tree.c | 14 ++++++++------
 1 file changed, 8 insertions(+), 6 deletions(-)

diff --git a/lib/radix-tree.c b/lib/radix-tree.c
index e963823..f85c8f5 100644
--- a/lib/radix-tree.c
+++ b/lib/radix-tree.c
@@ -1416,8 +1416,10 @@ unsigned long radix_tree_locate_item(struct radix_tree_root *root, void *item)
  *	radix_tree_shrink    -    shrink height of a radix tree to minimal
  *	@root		radix tree root
  */
-static inline void radix_tree_shrink(struct radix_tree_root *root)
+static inline bool radix_tree_shrink(struct radix_tree_root *root)
 {
+	bool shrunk = false;
+
 	/* try to shrink tree height */
 	while (root->height > 0) {
 		struct radix_tree_node *to_free = root->rnode;
@@ -1477,7 +1479,10 @@ static inline void radix_tree_shrink(struct radix_tree_root *root)
 			to_free->slots[0] = RADIX_TREE_RETRY;
 
 		radix_tree_node_free(to_free);
+		shrunk = true;
 	}
+
+	return shrunk;
 }
 
 /**
@@ -1500,11 +1505,8 @@ bool __radix_tree_delete_node(struct radix_tree_root *root,
 		struct radix_tree_node *parent;
 
 		if (node->count) {
-			if (node == indirect_to_ptr(root->rnode)) {
-				radix_tree_shrink(root);
-				if (root->height == 0)
-					deleted = true;
-			}
+			if (node == indirect_to_ptr(root->rnode))
+				deleted |= radix_tree_shrink(root);
 			return deleted;
 		}
 
-- 
2.8.0.rc3

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH 00/19] Radix tree cleanups Matthew Wilcox <willy@linux.intel.com> - 2016-04-14 16:40 +0200
  [PATCH 12/19] radix-tree: Change naming conventions in radix_tree_shrink Matthew Wilcox <willy@linux.intel.com> - 2016-04-14 16:40 +0200
  [PATCH 16/19] radix-tree: Introduce radix_tree_replace_clear_tags() Matthew Wilcox <willy@linux.intel.com> - 2016-04-14 16:40 +0200
  [PATCH 17/19] radix-tree: Make radix_tree_descend() more useful Matthew Wilcox <willy@linux.intel.com> - 2016-04-14 16:40 +0200
  [PATCH 01/19] drivers/hwspinlock: Use correct radix tree API Matthew Wilcox <willy@linux.intel.com> - 2016-04-14 16:40 +0200
  [PATCH 05/19] radix-tree: Remove a use of root->height from delete_node Matthew Wilcox <willy@linux.intel.com> - 2016-04-14 16:40 +0200
  [PATCH 18/19] dax: move RADIX_DAX_ definitions to dax.c Matthew Wilcox <willy@linux.intel.com> - 2016-04-14 16:40 +0200
  [PATCH 11/19] radix-tree: Rename radix_tree_is_indirect_ptr() Matthew Wilcox <willy@linux.intel.com> - 2016-04-14 16:50 +0200
  [PATCH 06/19] radix tree test suite: Remove dependencies on height Matthew Wilcox <willy@linux.intel.com> - 2016-04-14 16:50 +0200
  [PATCH 02/19] radix-tree: Miscellaneous fixes Matthew Wilcox <willy@linux.intel.com> - 2016-04-14 16:50 +0200
  [PATCH 04/19] radix-tree: Replace node->height with node->shift Matthew Wilcox <willy@linux.intel.com> - 2016-04-14 16:50 +0200
  [PATCH 10/19] radix-tree: Rename indirect_to_ptr() to entry_to_node() Matthew Wilcox <willy@linux.intel.com> - 2016-04-14 16:50 +0200
  [PATCH 13/19] radix-tree: Tidy up next_chunk Matthew Wilcox <willy@linux.intel.com> - 2016-04-14 16:50 +0200
  [PATCH 14/19] radix-tree: Tidy up range_tag_if_tagged Matthew Wilcox <willy@linux.intel.com> - 2016-04-14 16:50 +0200
  [PATCH 15/19] radix-tree: Tidy up __radix_tree_create() Matthew Wilcox <willy@linux.intel.com> - 2016-04-14 16:50 +0200
  [PATCH 08/19] radix-tree: Rename INDIRECT_PTR to INTERNAL_NODE Matthew Wilcox <willy@linux.intel.com> - 2016-04-14 16:50 +0200
  [PATCH 03/19] radix-tree: Split node->path into offset and height Matthew Wilcox <willy@linux.intel.com> - 2016-04-14 16:50 +0200
  [PATCH 09/19] radix-tree: Rename ptr_to_indirect() to node_to_entry() Matthew Wilcox <willy@linux.intel.com> - 2016-04-14 16:50 +0200

csiph-web