summaryrefslogtreecommitdiffstats
path: root/lib/radix-tree.c
diff options
context:
space:
mode:
Diffstat (limited to 'lib/radix-tree.c')
-rw-r--r--lib/radix-tree.c71
1 files changed, 0 insertions, 71 deletions
diff --git a/lib/radix-tree.c b/lib/radix-tree.c
index 3479d93c32b9..68702061464f 100644
--- a/lib/radix-tree.c
+++ b/lib/radix-tree.c
@@ -255,54 +255,6 @@ static unsigned long next_index(unsigned long index,
255 return (index & ~node_maxindex(node)) + (offset << node->shift); 255 return (index & ~node_maxindex(node)) + (offset << node->shift);
256} 256}
257 257
258#ifndef __KERNEL__
259static void dump_ida_node(void *entry, unsigned long index)
260{
261 unsigned long i;
262
263 if (!entry)
264 return;
265
266 if (radix_tree_is_internal_node(entry)) {
267 struct radix_tree_node *node = entry_to_node(entry);
268
269 pr_debug("ida node: %p offset %d indices %lu-%lu parent %p free %lx shift %d count %d\n",
270 node, node->offset, index * IDA_BITMAP_BITS,
271 ((index | node_maxindex(node)) + 1) *
272 IDA_BITMAP_BITS - 1,
273 node->parent, node->tags[0][0], node->shift,
274 node->count);
275 for (i = 0; i < RADIX_TREE_MAP_SIZE; i++)
276 dump_ida_node(node->slots[i],
277 index | (i << node->shift));
278 } else if (xa_is_value(entry)) {
279 pr_debug("ida excp: %p offset %d indices %lu-%lu data %lx\n",
280 entry, (int)(index & RADIX_TREE_MAP_MASK),
281 index * IDA_BITMAP_BITS,
282 index * IDA_BITMAP_BITS + BITS_PER_XA_VALUE,
283 xa_to_value(entry));
284 } else {
285 struct ida_bitmap *bitmap = entry;
286
287 pr_debug("ida btmp: %p offset %d indices %lu-%lu data", bitmap,
288 (int)(index & RADIX_TREE_MAP_MASK),
289 index * IDA_BITMAP_BITS,
290 (index + 1) * IDA_BITMAP_BITS - 1);
291 for (i = 0; i < IDA_BITMAP_LONGS; i++)
292 pr_cont(" %lx", bitmap->bitmap[i]);
293 pr_cont("\n");
294 }
295}
296
297static void ida_dump(struct ida *ida)
298{
299 struct radix_tree_root *root = &ida->ida_rt;
300 pr_debug("ida: %p node %p free %d\n", ida, root->xa_head,
301 root->xa_flags >> ROOT_TAG_SHIFT);
302 dump_ida_node(root->xa_head, 0);
303}
304#endif
305
306/* 258/*
307 * This assumes that the caller has performed appropriate preallocation, and 259 * This assumes that the caller has performed appropriate preallocation, and
308 * that the caller has pinned this thread of control to the current CPU. 260 * that the caller has pinned this thread of control to the current CPU.
@@ -2039,27 +1991,6 @@ void idr_preload(gfp_t gfp_mask)
2039} 1991}
2040EXPORT_SYMBOL(idr_preload); 1992EXPORT_SYMBOL(idr_preload);
2041 1993
2042int ida_pre_get(struct ida *ida, gfp_t gfp)
2043{
2044 /*
2045 * The IDA API has no preload_end() equivalent. Instead,
2046 * ida_get_new() can return -EAGAIN, prompting the caller
2047 * to return to the ida_pre_get() step.
2048 */
2049 if (!__radix_tree_preload(gfp, IDA_PRELOAD_SIZE))
2050 preempt_enable();
2051
2052 if (!this_cpu_read(ida_bitmap)) {
2053 struct ida_bitmap *bitmap = kzalloc(sizeof(*bitmap), gfp);
2054 if (!bitmap)
2055 return 0;
2056 if (this_cpu_cmpxchg(ida_bitmap, NULL, bitmap))
2057 kfree(bitmap);
2058 }
2059
2060 return 1;
2061}
2062
2063void __rcu **idr_get_free(struct radix_tree_root *root, 1994void __rcu **idr_get_free(struct radix_tree_root *root,
2064 struct radix_tree_iter *iter, gfp_t gfp, 1995 struct radix_tree_iter *iter, gfp_t gfp,
2065 unsigned long max) 1996 unsigned long max)
@@ -2201,8 +2132,6 @@ static int radix_tree_cpu_dead(unsigned int cpu)
2201 kmem_cache_free(radix_tree_node_cachep, node); 2132 kmem_cache_free(radix_tree_node_cachep, node);
2202 rtp->nr--; 2133 rtp->nr--;
2203 } 2134 }
2204 kfree(per_cpu(ida_bitmap, cpu));
2205 per_cpu(ida_bitmap, cpu) = NULL;
2206 return 0; 2135 return 0;
2207} 2136}
2208 2137