xarray: Add XArray load operation
The xa_load function brings with it a lot of infrastructure; xa_empty(), xa_is_err(), and large chunks of the XArray advanced API that are used to implement xa_load. As the test-suite demonstrates, it is possible to use the XArray functions on a radix tree. The radix tree functions depend on the GFP flags being stored in the root of the tree, so it's not possible to use the radix tree functions on an XArray. Signed-off-by: Matthew Wilcox <willy@infradead.org>
This commit is contained in:
1
tools/testing/radix-tree/.gitignore
vendored
1
tools/testing/radix-tree/.gitignore
vendored
@@ -4,3 +4,4 @@ idr-test
|
||||
main
|
||||
multiorder
|
||||
radix-tree.c
|
||||
xarray
|
||||
|
||||
@@ -4,7 +4,7 @@ CFLAGS += -I. -I../../include -g -Og -Wall -D_LGPL_SOURCE -fsanitize=address \
|
||||
-fsanitize=undefined
|
||||
LDFLAGS += -fsanitize=address -fsanitize=undefined
|
||||
LDLIBS+= -lpthread -lurcu
|
||||
TARGETS = main idr-test multiorder
|
||||
TARGETS = main idr-test multiorder xarray
|
||||
CORE_OFILES := xarray.o radix-tree.o idr.o linux.o test.o find_bit.o
|
||||
OFILES = main.o $(CORE_OFILES) regression1.o regression2.o regression3.o \
|
||||
tag_check.o multiorder.o idr-test.o iteration_check.o benchmark.o
|
||||
@@ -25,6 +25,8 @@ main: $(OFILES)
|
||||
idr-test.o: ../../../lib/test_ida.c
|
||||
idr-test: idr-test.o $(CORE_OFILES)
|
||||
|
||||
xarray: $(CORE_OFILES)
|
||||
|
||||
multiorder: multiorder.o $(CORE_OFILES)
|
||||
|
||||
clean:
|
||||
@@ -45,7 +47,7 @@ radix-tree.c: ../../../lib/radix-tree.c
|
||||
idr.c: ../../../lib/idr.c
|
||||
sed -e 's/^static //' -e 's/__always_inline //' -e 's/inline //' < $< > $@
|
||||
|
||||
xarray.o: ../../../lib/xarray.c
|
||||
xarray.o: ../../../lib/xarray.c ../../../lib/test_xarray.c
|
||||
|
||||
generated/map-shift.h:
|
||||
@if ! grep -qws $(SHIFT) generated/map-shift.h; then \
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
#include "../../../include/linux/kconfig.h"
|
||||
|
||||
#define printk printf
|
||||
#define pr_info printk
|
||||
#define pr_debug printk
|
||||
#define pr_cont printk
|
||||
|
||||
|
||||
@@ -6,5 +6,7 @@
|
||||
|
||||
#define rcu_dereference_raw(p) rcu_dereference(p)
|
||||
#define rcu_dereference_protected(p, cond) rcu_dereference(p)
|
||||
#define rcu_dereference_check(p, cond) rcu_dereference(p)
|
||||
#define RCU_INIT_POINTER(p, v) (p) = (v)
|
||||
|
||||
#endif
|
||||
|
||||
@@ -365,6 +365,7 @@ int main(int argc, char **argv)
|
||||
rcu_register_thread();
|
||||
radix_tree_init();
|
||||
|
||||
xarray_tests();
|
||||
regression1_test();
|
||||
regression2_test();
|
||||
regression3_test();
|
||||
|
||||
@@ -34,6 +34,7 @@ int tag_tagged_items(struct radix_tree_root *, pthread_mutex_t *,
|
||||
unsigned iftag, unsigned thentag);
|
||||
unsigned long find_item(struct radix_tree_root *, void *item);
|
||||
|
||||
void xarray_tests(void);
|
||||
void tag_check(void);
|
||||
void multiorder_checks(void);
|
||||
void iteration_test(unsigned order, unsigned duration);
|
||||
|
||||
@@ -4,4 +4,32 @@
|
||||
* Copyright (c) 2018 Matthew Wilcox <willy@infradead.org>
|
||||
*/
|
||||
|
||||
#define XA_DEBUG
|
||||
#include "test.h"
|
||||
|
||||
#define module_init(x)
|
||||
#define module_exit(x)
|
||||
#define MODULE_AUTHOR(x)
|
||||
#define MODULE_LICENSE(x)
|
||||
#define dump_stack() assert(0)
|
||||
|
||||
#include "../../../lib/xarray.c"
|
||||
#undef XA_DEBUG
|
||||
#include "../../../lib/test_xarray.c"
|
||||
|
||||
void xarray_tests(void)
|
||||
{
|
||||
xarray_checks();
|
||||
xarray_exit();
|
||||
}
|
||||
|
||||
int __weak main(void)
|
||||
{
|
||||
radix_tree_init();
|
||||
xarray_tests();
|
||||
radix_tree_cpu_dead(1);
|
||||
rcu_barrier();
|
||||
if (nr_allocated)
|
||||
printf("nr_allocated = %d\n", nr_allocated);
|
||||
return 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user