Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1378911 > unrolled thread
| Started by | Matthew Wilcox <willy@linux.intel.com> |
|---|---|
| First post | 2016-04-14 16:30 +0200 |
| Last post | 2016-04-14 16:30 +0200 |
| Articles | 1 — 1 participant |
Back to article view | Back to linux.kernel
This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by
below is the oldest one visible, not the original post.
[PATCH v2 21/29] radix-tree: Rewrite radix_tree_tag_set Matthew Wilcox <willy@linux.intel.com> - 2016-04-14 16:30 +0200
| From | Matthew Wilcox <willy@linux.intel.com> |
|---|---|
| Date | 2016-04-14 16:30 +0200 |
| Subject | [PATCH v2 21/29] radix-tree: Rewrite radix_tree_tag_set |
| Message-ID | <rnQro-2ZQ-31@gated-at.bofh.it> |
From: Ross Zwisler <ross.zwisler@linux.intel.com>
Use the new multi-order support functions to rewrite radix_tree_tag_set()
Signed-off-by: Ross Zwisler <ross.zwisler@linux.intel.com>
Signed-off-by: Matthew Wilcox <willy@linux.intel.com>
---
lib/radix-tree.c | 37 +++++++++++++++++--------------------
1 file changed, 17 insertions(+), 20 deletions(-)
diff --git a/lib/radix-tree.c b/lib/radix-tree.c
index a4da86e..5234a95 100644
--- a/lib/radix-tree.c
+++ b/lib/radix-tree.c
@@ -722,35 +722,32 @@ EXPORT_SYMBOL(radix_tree_lookup);
void *radix_tree_tag_set(struct radix_tree_root *root,
unsigned long index, unsigned int tag)
{
- unsigned int height, shift;
- struct radix_tree_node *slot;
-
- height = root->height;
- BUG_ON(index > radix_tree_maxindex(height));
+ struct radix_tree_node *node, *parent;
+ unsigned long maxindex;
+ unsigned int shift;
- slot = indirect_to_ptr(root->rnode);
- shift = (height - 1) * RADIX_TREE_MAP_SHIFT;
+ shift = radix_tree_load_root(root, &node, &maxindex);
+ BUG_ON(index > maxindex);
- while (height > 0) {
- int offset;
+ while (radix_tree_is_indirect_ptr(node)) {
+ unsigned offset;
- offset = (index >> shift) & RADIX_TREE_MAP_MASK;
- if (!tag_get(slot, tag, offset))
- tag_set(slot, tag, offset);
- slot = slot->slots[offset];
- BUG_ON(slot == NULL);
- if (!radix_tree_is_indirect_ptr(slot))
- break;
- slot = indirect_to_ptr(slot);
shift -= RADIX_TREE_MAP_SHIFT;
- height--;
+ offset = (index >> shift) & RADIX_TREE_MAP_MASK;
+
+ parent = indirect_to_ptr(node);
+ offset = radix_tree_descend(parent, &node, offset);
+ BUG_ON(!node);
+
+ if (!tag_get(parent, tag, offset))
+ tag_set(parent, tag, offset);
}
/* set the root's tag bit */
- if (slot && !root_tag_get(root, tag))
+ if (!root_tag_get(root, tag))
root_tag_set(root, tag);
- return slot;
+ return node;
}
EXPORT_SYMBOL(radix_tree_tag_set);
--
2.8.0.rc3
Back to top | Article view | linux.kernel
csiph-web