blob: 31f1d9b6f506ef884c978b568aa9dc5d89fd8312 [file] [log] [blame]
Greg Kroah-Hartmanb2441312017-11-01 15:07:57 +01001/* SPDX-License-Identifier: GPL-2.0 */
Matthew Wilcox1366c372016-03-17 14:21:45 -07002#include <linux/gfp.h>
3#include <linux/types.h>
4#include <linux/radix-tree.h>
5#include <linux/rcupdate.h>
6
7struct item {
Ross Zwisler3e252fa2018-05-18 16:08:58 -07008 struct rcu_head rcu_head;
Matthew Wilcox1366c372016-03-17 14:21:45 -07009 unsigned long index;
Matthew Wilcox101d9602016-12-14 15:08:23 -080010 unsigned int order;
Matthew Wilcox1366c372016-03-17 14:21:45 -070011};
12
Matthew Wilcox101d9602016-12-14 15:08:23 -080013struct item *item_create(unsigned long index, unsigned int order);
14int __item_insert(struct radix_tree_root *root, struct item *item);
Matthew Wilcox1366c372016-03-17 14:21:45 -070015int item_insert(struct radix_tree_root *root, unsigned long index);
Ross Zwislerfd8f58c2018-05-18 16:09:01 -070016void item_sanity(struct item *item, unsigned long index);
Matthew Wilcox4f3755d2016-05-20 17:02:14 -070017int item_insert_order(struct radix_tree_root *root, unsigned long index,
18 unsigned order);
Matthew Wilcox1366c372016-03-17 14:21:45 -070019int item_delete(struct radix_tree_root *root, unsigned long index);
Ross Zwisler3e252fa2018-05-18 16:08:58 -070020int item_delete_rcu(struct radix_tree_root *root, unsigned long index);
Matthew Wilcox1366c372016-03-17 14:21:45 -070021struct item *item_lookup(struct radix_tree_root *root, unsigned long index);
22
23void item_check_present(struct radix_tree_root *root, unsigned long index);
24void item_check_absent(struct radix_tree_root *root, unsigned long index);
25void item_gang_check_present(struct radix_tree_root *root,
26 unsigned long start, unsigned long nr,
27 int chunk, int hop);
28void item_full_scan(struct radix_tree_root *root, unsigned long start,
29 unsigned long nr, int chunk);
30void item_kill_tree(struct radix_tree_root *root);
31
Matthew Wilcox268f42d2016-12-14 15:08:55 -080032int tag_tagged_items(struct radix_tree_root *, pthread_mutex_t *,
33 unsigned long start, unsigned long end, unsigned batch,
34 unsigned iftag, unsigned thentag);
Matthew Wilcox478922e2016-12-14 15:08:52 -080035unsigned long find_item(struct radix_tree_root *, void *item);
36
Matthew Wilcox1366c372016-03-17 14:21:45 -070037void tag_check(void);
Matthew Wilcox4f3755d2016-05-20 17:02:14 -070038void multiorder_checks(void);
Matthew Wilcox3e3cdc62016-12-14 15:09:10 -080039void iteration_test(unsigned order, unsigned duration);
Konstantin Khlebnikovcfa40bc2016-12-14 15:08:14 -080040void benchmark(void);
Matthew Wilcox0a835c42016-12-20 10:27:56 -050041void idr_checks(void);
42void ida_checks(void);
Matthew Wilcox4ecd9542017-03-03 12:16:10 -050043void ida_thread_tests(void);
Matthew Wilcox1366c372016-03-17 14:21:45 -070044
45struct item *
46item_tag_set(struct radix_tree_root *root, unsigned long index, int tag);
47struct item *
48item_tag_clear(struct radix_tree_root *root, unsigned long index, int tag);
49int item_tag_get(struct radix_tree_root *root, unsigned long index, int tag);
50void tree_verify_min_height(struct radix_tree_root *root, int maxindex);
51void verify_tag_consistency(struct radix_tree_root *root, unsigned int tag);
52
53extern int nr_allocated;
54
55/* Normally private parts of lib/radix-tree.c */
Matthew Wilcox148deab2016-12-14 15:08:49 -080056struct radix_tree_node *entry_to_node(void *ptr);
Ross Zwisler0796c582016-05-20 17:02:55 -070057void radix_tree_dump(struct radix_tree_root *root);
Matthew Wilcox1366c372016-03-17 14:21:45 -070058int root_tag_get(struct radix_tree_root *root, unsigned int tag);
Matthew Wilcox0694f0c2016-05-20 17:03:16 -070059unsigned long node_maxindex(struct radix_tree_node *);
60unsigned long shift_maxindex(unsigned int shift);
Matthew Wilcox6df5ee72016-12-14 15:08:05 -080061int radix_tree_cpu_dead(unsigned int cpu);
Matthew Wilcox2791653a2016-12-14 15:09:04 -080062struct radix_tree_preload {
63 unsigned nr;
64 struct radix_tree_node *nodes;
65};
66extern struct radix_tree_preload radix_tree_preloads;