Merge tag 'xarray-4.20-rc7' of git://git.infradead.org/users/willy/linux-dax
Pull XArray fixes from Matthew Wilcox: "Two bugfixes, each with test-suite updates, two improvements to the test-suite without associated bugs, and one patch adding a missing API" * tag 'xarray-4.20-rc7' of git://git.infradead.org/users/willy/linux-dax: XArray: Fix xa_alloc when id exceeds max XArray tests: Check iterating over multiorder entries XArray tests: Handle larger indices more elegantly XArray: Add xa_cmpxchg_irq and xa_cmpxchg_bh radix tree: Don't return retry entries from lookup
This commit is contained in:
@@ -7,6 +7,7 @@ LDLIBS+= -lpthread -lurcu
|
||||
TARGETS = main idr-test multiorder xarray
|
||||
CORE_OFILES := xarray.o radix-tree.o idr.o linux.o test.o find_bit.o bitmap.o
|
||||
OFILES = main.o $(CORE_OFILES) regression1.o regression2.o regression3.o \
|
||||
regression4.o \
|
||||
tag_check.o multiorder.o idr-test.o iteration_check.o benchmark.o
|
||||
|
||||
ifndef SHIFT
|
||||
|
@@ -308,6 +308,7 @@ int main(int argc, char **argv)
|
||||
regression1_test();
|
||||
regression2_test();
|
||||
regression3_test();
|
||||
regression4_test();
|
||||
iteration_test(0, 10 + 90 * long_run);
|
||||
iteration_test(7, 10 + 90 * long_run);
|
||||
single_thread_tests(long_run);
|
||||
|
@@ -5,5 +5,6 @@
|
||||
void regression1_test(void);
|
||||
void regression2_test(void);
|
||||
void regression3_test(void);
|
||||
void regression4_test(void);
|
||||
|
||||
#endif
|
||||
|
79
tools/testing/radix-tree/regression4.c
Normal file
79
tools/testing/radix-tree/regression4.c
Normal file
@@ -0,0 +1,79 @@
|
||||
// SPDX-License-Identifier: GPL-2.0
|
||||
#include <linux/kernel.h>
|
||||
#include <linux/gfp.h>
|
||||
#include <linux/slab.h>
|
||||
#include <linux/radix-tree.h>
|
||||
#include <linux/rcupdate.h>
|
||||
#include <stdlib.h>
|
||||
#include <pthread.h>
|
||||
#include <stdio.h>
|
||||
#include <assert.h>
|
||||
|
||||
#include "regression.h"
|
||||
|
||||
static pthread_barrier_t worker_barrier;
|
||||
static int obj0, obj1;
|
||||
static RADIX_TREE(mt_tree, GFP_KERNEL);
|
||||
|
||||
static void *reader_fn(void *arg)
|
||||
{
|
||||
int i;
|
||||
void *entry;
|
||||
|
||||
rcu_register_thread();
|
||||
pthread_barrier_wait(&worker_barrier);
|
||||
|
||||
for (i = 0; i < 1000000; i++) {
|
||||
rcu_read_lock();
|
||||
entry = radix_tree_lookup(&mt_tree, 0);
|
||||
rcu_read_unlock();
|
||||
if (entry != &obj0) {
|
||||
printf("iteration %d bad entry = %p\n", i, entry);
|
||||
abort();
|
||||
}
|
||||
}
|
||||
|
||||
rcu_unregister_thread();
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static void *writer_fn(void *arg)
|
||||
{
|
||||
int i;
|
||||
|
||||
rcu_register_thread();
|
||||
pthread_barrier_wait(&worker_barrier);
|
||||
|
||||
for (i = 0; i < 1000000; i++) {
|
||||
radix_tree_insert(&mt_tree, 1, &obj1);
|
||||
radix_tree_delete(&mt_tree, 1);
|
||||
}
|
||||
|
||||
rcu_unregister_thread();
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void regression4_test(void)
|
||||
{
|
||||
pthread_t reader, writer;
|
||||
|
||||
printv(1, "regression test 4 starting\n");
|
||||
|
||||
radix_tree_insert(&mt_tree, 0, &obj0);
|
||||
pthread_barrier_init(&worker_barrier, NULL, 2);
|
||||
|
||||
if (pthread_create(&reader, NULL, reader_fn, NULL) ||
|
||||
pthread_create(&writer, NULL, writer_fn, NULL)) {
|
||||
perror("pthread_create");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
if (pthread_join(reader, NULL) || pthread_join(writer, NULL)) {
|
||||
perror("pthread_join");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
printv(1, "regression test 4 passed\n");
|
||||
}
|
Reference in New Issue
Block a user