aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthew Wilcox <willy@linux.intel.com>2016-05-20 20:03:22 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2016-05-20 20:58:30 -0400
commit30ff46ccb303fb6f6c28b9aa9f2cdc4ba900ed3f (patch)
treea401a527d4f4cafeab2a15befdd15ed29c2eade3
parentd0891265bbc988dc91ed8580b38eb3dac128581b (diff)
radix-tree: rename INDIRECT_PTR to INTERNAL_NODE
The name RADIX_TREE_INDIRECT_PTR doesn't really match the meaning. RADIX_TREE_INTERNAL_NODE is a better name. Signed-off-by: Matthew Wilcox <willy@linux.intel.com> Cc: Konstantin Khlebnikov <koct9i@gmail.com> Cc: Kirill Shutemov <kirill.shutemov@linux.intel.com> Cc: Jan Kara <jack@suse.com> Cc: Neil Brown <neilb@suse.de> Cc: Ross Zwisler <ross.zwisler@linux.intel.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
-rw-r--r--include/linux/radix-tree.h30
-rw-r--r--lib/radix-tree.c2
2 files changed, 14 insertions, 18 deletions
diff --git a/include/linux/radix-tree.h b/include/linux/radix-tree.h
index c0d223cfac00..c8cc879046c7 100644
--- a/include/linux/radix-tree.h
+++ b/include/linux/radix-tree.h
@@ -29,20 +29,16 @@
29#include <linux/rcupdate.h> 29#include <linux/rcupdate.h>
30 30
31/* 31/*
32 * An indirect pointer (root->rnode pointing to a radix_tree_node, rather 32 * Entries in the radix tree have the low bit set if they refer to a
33 * than a data item) is signalled by the low bit set in the root->rnode 33 * radix_tree_node. If the low bit is clear then the entry is user data.
34 * pointer. 34 *
35 * 35 * We also use the low bit to indicate that the slot will be freed in the
36 * In this case root->height is > 0, but the indirect pointer tests are 36 * next RCU idle period, and users need to re-walk the tree to find the
37 * needed for RCU lookups (because root->height is unreliable). The only 37 * new slot for the index that they were looking for. See the comment in
38 * time callers need worry about this is when doing a lookup_slot under 38 * radix_tree_shrink() for details.
39 * RCU.
40 *
41 * Indirect pointer in fact is also used to tag the last pointer of a node
42 * when it is shrunk, before we rcu free the node. See shrink code for
43 * details.
44 */ 39 */
45#define RADIX_TREE_INDIRECT_PTR 1 40#define RADIX_TREE_INTERNAL_NODE 1
41
46/* 42/*
47 * A common use of the radix tree is to store pointers to struct pages; 43 * A common use of the radix tree is to store pointers to struct pages;
48 * but shmem/tmpfs needs also to store swap entries in the same tree: 44 * but shmem/tmpfs needs also to store swap entries in the same tree:
@@ -63,7 +59,7 @@
63 59
64static inline int radix_tree_is_indirect_ptr(void *ptr) 60static inline int radix_tree_is_indirect_ptr(void *ptr)
65{ 61{
66 return (int)((unsigned long)ptr & RADIX_TREE_INDIRECT_PTR); 62 return (int)((unsigned long)ptr & RADIX_TREE_INTERNAL_NODE);
67} 63}
68 64
69/*** radix-tree API starts here ***/ 65/*** radix-tree API starts here ***/
@@ -228,7 +224,7 @@ static inline void *radix_tree_deref_slot_protected(void **pslot,
228 */ 224 */
229static inline int radix_tree_deref_retry(void *arg) 225static inline int radix_tree_deref_retry(void *arg)
230{ 226{
231 return unlikely((unsigned long)arg & RADIX_TREE_INDIRECT_PTR); 227 return unlikely(radix_tree_is_indirect_ptr(arg));
232} 228}
233 229
234/** 230/**
@@ -250,7 +246,7 @@ static inline int radix_tree_exceptional_entry(void *arg)
250static inline int radix_tree_exception(void *arg) 246static inline int radix_tree_exception(void *arg)
251{ 247{
252 return unlikely((unsigned long)arg & 248 return unlikely((unsigned long)arg &
253 (RADIX_TREE_INDIRECT_PTR | RADIX_TREE_EXCEPTIONAL_ENTRY)); 249 (RADIX_TREE_INTERNAL_NODE | RADIX_TREE_EXCEPTIONAL_ENTRY));
254} 250}
255 251
256/** 252/**
@@ -448,7 +444,7 @@ radix_tree_chunk_size(struct radix_tree_iter *iter)
448 444
449static inline void *indirect_to_ptr(void *ptr) 445static inline void *indirect_to_ptr(void *ptr)
450{ 446{
451 return (void *)((unsigned long)ptr & ~RADIX_TREE_INDIRECT_PTR); 447 return (void *)((unsigned long)ptr & ~RADIX_TREE_INTERNAL_NODE);
452} 448}
453 449
454/** 450/**
diff --git a/lib/radix-tree.c b/lib/radix-tree.c
index 58f79fee8c71..31d5929a625b 100644
--- a/lib/radix-tree.c
+++ b/lib/radix-tree.c
@@ -68,7 +68,7 @@ static DEFINE_PER_CPU(struct radix_tree_preload, radix_tree_preloads) = { 0, };
68 68
69static inline void *ptr_to_indirect(void *ptr) 69static inline void *ptr_to_indirect(void *ptr)
70{ 70{
71 return (void *)((unsigned long)ptr | RADIX_TREE_INDIRECT_PTR); 71 return (void *)((unsigned long)ptr | RADIX_TREE_INTERNAL_NODE);
72} 72}
73 73
74#define RADIX_TREE_RETRY ptr_to_indirect(NULL) 74#define RADIX_TREE_RETRY ptr_to_indirect(NULL)