xref: /linux/tools/testing/radix-tree/test.h (revision c532de5a67a70f8533d495f8f2aaa9a0491c3ad0)
1 /* SPDX-License-Identifier: GPL-2.0 */
2 #include <linux/gfp.h>
3 #include <linux/types.h>
4 #include <linux/radix-tree.h>
5 #include <linux/rcupdate.h>
6 
7 struct item {
8 	struct rcu_head	rcu_head;
9 	unsigned long index;
10 	unsigned int order;
11 };
12 
13 struct item *item_create(unsigned long index, unsigned int order);
14 int item_insert(struct radix_tree_root *root, unsigned long index);
15 void item_sanity(struct item *item, unsigned long index);
16 void item_free(struct item *item, unsigned long index);
17 int item_delete(struct radix_tree_root *root, unsigned long index);
18 int item_delete_rcu(struct xarray *xa, unsigned long index);
19 struct item *item_lookup(struct radix_tree_root *root, unsigned long index);
20 
21 void item_check_present(struct radix_tree_root *root, unsigned long index);
22 void item_check_absent(struct radix_tree_root *root, unsigned long index);
23 void item_gang_check_present(struct radix_tree_root *root,
24 			unsigned long start, unsigned long nr,
25 			int chunk, int hop);
26 void item_full_scan(struct radix_tree_root *root, unsigned long start,
27 			unsigned long nr, int chunk);
28 void item_kill_tree(struct radix_tree_root *root);
29 
30 int tag_tagged_items(struct xarray *, unsigned long start, unsigned long end,
31 		unsigned batch, xa_mark_t iftag, xa_mark_t thentag);
32 
33 void xarray_tests(void);
34 void tag_check(void);
35 void multiorder_checks(void);
36 void iteration_test(unsigned order, unsigned duration);
37 void iteration_test2(unsigned duration);
38 void benchmark(void);
39 void idr_checks(void);
40 void ida_tests(void);
41 
42 struct item *
43 item_tag_set(struct radix_tree_root *root, unsigned long index, int tag);
44 struct item *
45 item_tag_clear(struct radix_tree_root *root, unsigned long index, int tag);
46 int item_tag_get(struct radix_tree_root *root, unsigned long index, int tag);
47 void tree_verify_min_height(struct radix_tree_root *root, int maxindex);
48 void verify_tag_consistency(struct radix_tree_root *root, unsigned int tag);
49 
50 extern int nr_allocated;
51 
52 /* Normally private parts of lib/radix-tree.c */
53 struct radix_tree_node *entry_to_node(void *ptr);
54 void radix_tree_dump(struct radix_tree_root *root);
55 int root_tag_get(struct radix_tree_root *root, unsigned int tag);
56 unsigned long node_maxindex(struct radix_tree_node *);
57 unsigned long shift_maxindex(unsigned int shift);
58 int radix_tree_cpu_dead(unsigned int cpu);
59 extern struct radix_tree_preload radix_tree_preloads;
60