xref: /openbmc/linux/tools/testing/radix-tree/main.c (revision 73bc029b76482260a144219786d19951f561716e)
11366c37eSMatthew Wilcox #include <stdio.h>
21366c37eSMatthew Wilcox #include <stdlib.h>
31366c37eSMatthew Wilcox #include <unistd.h>
41366c37eSMatthew Wilcox #include <time.h>
51366c37eSMatthew Wilcox #include <assert.h>
60a835c4fSMatthew Wilcox #include <limits.h>
71366c37eSMatthew Wilcox 
81366c37eSMatthew Wilcox #include <linux/slab.h>
91366c37eSMatthew Wilcox #include <linux/radix-tree.h>
101366c37eSMatthew Wilcox 
111366c37eSMatthew Wilcox #include "test.h"
121366c37eSMatthew Wilcox #include "regression.h"
131366c37eSMatthew Wilcox 
141366c37eSMatthew Wilcox void __gang_check(unsigned long middle, long down, long up, int chunk, int hop)
151366c37eSMatthew Wilcox {
161366c37eSMatthew Wilcox 	long idx;
171366c37eSMatthew Wilcox 	RADIX_TREE(tree, GFP_KERNEL);
181366c37eSMatthew Wilcox 
191366c37eSMatthew Wilcox 	middle = 1 << 30;
201366c37eSMatthew Wilcox 
211366c37eSMatthew Wilcox 	for (idx = -down; idx < up; idx++)
221366c37eSMatthew Wilcox 		item_insert(&tree, middle + idx);
231366c37eSMatthew Wilcox 
241366c37eSMatthew Wilcox 	item_check_absent(&tree, middle - down - 1);
251366c37eSMatthew Wilcox 	for (idx = -down; idx < up; idx++)
261366c37eSMatthew Wilcox 		item_check_present(&tree, middle + idx);
271366c37eSMatthew Wilcox 	item_check_absent(&tree, middle + up);
281366c37eSMatthew Wilcox 
291366c37eSMatthew Wilcox 	item_gang_check_present(&tree, middle - down,
301366c37eSMatthew Wilcox 			up + down, chunk, hop);
311366c37eSMatthew Wilcox 	item_full_scan(&tree, middle - down, down + up, chunk);
321366c37eSMatthew Wilcox 	item_kill_tree(&tree);
331366c37eSMatthew Wilcox }
341366c37eSMatthew Wilcox 
351366c37eSMatthew Wilcox void gang_check(void)
361366c37eSMatthew Wilcox {
371366c37eSMatthew Wilcox 	__gang_check(1 << 30, 128, 128, 35, 2);
381366c37eSMatthew Wilcox 	__gang_check(1 << 31, 128, 128, 32, 32);
391366c37eSMatthew Wilcox 	__gang_check(1 << 31, 128, 128, 32, 100);
401366c37eSMatthew Wilcox 	__gang_check(1 << 31, 128, 128, 17, 7);
411366c37eSMatthew Wilcox 	__gang_check(0xffff0000, 0, 65536, 17, 7);
421366c37eSMatthew Wilcox 	__gang_check(0xfffffffe, 1, 1, 17, 7);
431366c37eSMatthew Wilcox }
441366c37eSMatthew Wilcox 
451366c37eSMatthew Wilcox void __big_gang_check(void)
461366c37eSMatthew Wilcox {
471366c37eSMatthew Wilcox 	unsigned long start;
481366c37eSMatthew Wilcox 	int wrapped = 0;
491366c37eSMatthew Wilcox 
501366c37eSMatthew Wilcox 	start = 0;
511366c37eSMatthew Wilcox 	do {
521366c37eSMatthew Wilcox 		unsigned long old_start;
531366c37eSMatthew Wilcox 
541366c37eSMatthew Wilcox //		printf("0x%08lx\n", start);
551366c37eSMatthew Wilcox 		__gang_check(start, rand() % 113 + 1, rand() % 71,
561366c37eSMatthew Wilcox 				rand() % 157, rand() % 91 + 1);
571366c37eSMatthew Wilcox 		old_start = start;
581366c37eSMatthew Wilcox 		start += rand() % 1000000;
591366c37eSMatthew Wilcox 		start %= 1ULL << 33;
601366c37eSMatthew Wilcox 		if (start < old_start)
611366c37eSMatthew Wilcox 			wrapped = 1;
621366c37eSMatthew Wilcox 	} while (!wrapped);
631366c37eSMatthew Wilcox }
641366c37eSMatthew Wilcox 
65aa1d62d8SRoss Zwisler void big_gang_check(bool long_run)
661366c37eSMatthew Wilcox {
671366c37eSMatthew Wilcox 	int i;
681366c37eSMatthew Wilcox 
69aa1d62d8SRoss Zwisler 	for (i = 0; i < (long_run ? 1000 : 3); i++) {
701366c37eSMatthew Wilcox 		__big_gang_check();
71*73bc029bSRehas Sachdeva 		printv(2, "%d ", i);
721366c37eSMatthew Wilcox 		fflush(stdout);
731366c37eSMatthew Wilcox 	}
741366c37eSMatthew Wilcox }
751366c37eSMatthew Wilcox 
761366c37eSMatthew Wilcox void add_and_check(void)
771366c37eSMatthew Wilcox {
781366c37eSMatthew Wilcox 	RADIX_TREE(tree, GFP_KERNEL);
791366c37eSMatthew Wilcox 
801366c37eSMatthew Wilcox 	item_insert(&tree, 44);
811366c37eSMatthew Wilcox 	item_check_present(&tree, 44);
821366c37eSMatthew Wilcox 	item_check_absent(&tree, 43);
831366c37eSMatthew Wilcox 	item_kill_tree(&tree);
841366c37eSMatthew Wilcox }
851366c37eSMatthew Wilcox 
861366c37eSMatthew Wilcox void dynamic_height_check(void)
871366c37eSMatthew Wilcox {
881366c37eSMatthew Wilcox 	int i;
891366c37eSMatthew Wilcox 	RADIX_TREE(tree, GFP_KERNEL);
901366c37eSMatthew Wilcox 	tree_verify_min_height(&tree, 0);
911366c37eSMatthew Wilcox 
921366c37eSMatthew Wilcox 	item_insert(&tree, 42);
931366c37eSMatthew Wilcox 	tree_verify_min_height(&tree, 42);
941366c37eSMatthew Wilcox 
951366c37eSMatthew Wilcox 	item_insert(&tree, 1000000);
961366c37eSMatthew Wilcox 	tree_verify_min_height(&tree, 1000000);
971366c37eSMatthew Wilcox 
981366c37eSMatthew Wilcox 	assert(item_delete(&tree, 1000000));
991366c37eSMatthew Wilcox 	tree_verify_min_height(&tree, 42);
1001366c37eSMatthew Wilcox 
1011366c37eSMatthew Wilcox 	assert(item_delete(&tree, 42));
1021366c37eSMatthew Wilcox 	tree_verify_min_height(&tree, 0);
1031366c37eSMatthew Wilcox 
1041366c37eSMatthew Wilcox 	for (i = 0; i < 1000; i++) {
1051366c37eSMatthew Wilcox 		item_insert(&tree, i);
1061366c37eSMatthew Wilcox 		tree_verify_min_height(&tree, i);
1071366c37eSMatthew Wilcox 	}
1081366c37eSMatthew Wilcox 
1091366c37eSMatthew Wilcox 	i--;
1101366c37eSMatthew Wilcox 	for (;;) {
1111366c37eSMatthew Wilcox 		assert(item_delete(&tree, i));
1121366c37eSMatthew Wilcox 		if (i == 0) {
1131366c37eSMatthew Wilcox 			tree_verify_min_height(&tree, 0);
1141366c37eSMatthew Wilcox 			break;
1151366c37eSMatthew Wilcox 		}
1161366c37eSMatthew Wilcox 		i--;
1171366c37eSMatthew Wilcox 		tree_verify_min_height(&tree, i);
1181366c37eSMatthew Wilcox 	}
1191366c37eSMatthew Wilcox 
1201366c37eSMatthew Wilcox 	item_kill_tree(&tree);
1211366c37eSMatthew Wilcox }
1221366c37eSMatthew Wilcox 
1231366c37eSMatthew Wilcox void check_copied_tags(struct radix_tree_root *tree, unsigned long start, unsigned long end, unsigned long *idx, int count, int fromtag, int totag)
1241366c37eSMatthew Wilcox {
1251366c37eSMatthew Wilcox 	int i;
1261366c37eSMatthew Wilcox 
1271366c37eSMatthew Wilcox 	for (i = 0; i < count; i++) {
1281366c37eSMatthew Wilcox /*		if (i % 1000 == 0)
1291366c37eSMatthew Wilcox 			putchar('.'); */
1301366c37eSMatthew Wilcox 		if (idx[i] < start || idx[i] > end) {
1311366c37eSMatthew Wilcox 			if (item_tag_get(tree, idx[i], totag)) {
132*73bc029bSRehas Sachdeva 				printv(2, "%lu-%lu: %lu, tags %d-%d\n", start,
133*73bc029bSRehas Sachdeva 				       end, idx[i], item_tag_get(tree, idx[i],
134*73bc029bSRehas Sachdeva 								 fromtag),
135*73bc029bSRehas Sachdeva 				       item_tag_get(tree, idx[i], totag));
1361366c37eSMatthew Wilcox 			}
1371366c37eSMatthew Wilcox 			assert(!item_tag_get(tree, idx[i], totag));
1381366c37eSMatthew Wilcox 			continue;
1391366c37eSMatthew Wilcox 		}
1401366c37eSMatthew Wilcox 		if (item_tag_get(tree, idx[i], fromtag) ^
1411366c37eSMatthew Wilcox 			item_tag_get(tree, idx[i], totag)) {
142*73bc029bSRehas Sachdeva 			printv(2, "%lu-%lu: %lu, tags %d-%d\n", start, end,
143*73bc029bSRehas Sachdeva 			       idx[i], item_tag_get(tree, idx[i], fromtag),
144*73bc029bSRehas Sachdeva 			       item_tag_get(tree, idx[i], totag));
1451366c37eSMatthew Wilcox 		}
1461366c37eSMatthew Wilcox 		assert(!(item_tag_get(tree, idx[i], fromtag) ^
1471366c37eSMatthew Wilcox 			 item_tag_get(tree, idx[i], totag)));
1481366c37eSMatthew Wilcox 	}
1491366c37eSMatthew Wilcox }
1501366c37eSMatthew Wilcox 
1511366c37eSMatthew Wilcox #define ITEMS 50000
1521366c37eSMatthew Wilcox 
1531366c37eSMatthew Wilcox void copy_tag_check(void)
1541366c37eSMatthew Wilcox {
1551366c37eSMatthew Wilcox 	RADIX_TREE(tree, GFP_KERNEL);
1561366c37eSMatthew Wilcox 	unsigned long idx[ITEMS];
1571366c37eSMatthew Wilcox 	unsigned long start, end, count = 0, tagged, cur, tmp;
1581366c37eSMatthew Wilcox 	int i;
1591366c37eSMatthew Wilcox 
1601366c37eSMatthew Wilcox //	printf("generating radix tree indices...\n");
1611366c37eSMatthew Wilcox 	start = rand();
1621366c37eSMatthew Wilcox 	end = rand();
1631366c37eSMatthew Wilcox 	if (start > end && (rand() % 10)) {
1641366c37eSMatthew Wilcox 		cur = start;
1651366c37eSMatthew Wilcox 		start = end;
1661366c37eSMatthew Wilcox 		end = cur;
1671366c37eSMatthew Wilcox 	}
1681366c37eSMatthew Wilcox 	/* Specifically create items around the start and the end of the range
1691366c37eSMatthew Wilcox 	 * with high probability to check for off by one errors */
1701366c37eSMatthew Wilcox 	cur = rand();
1711366c37eSMatthew Wilcox 	if (cur & 1) {
1721366c37eSMatthew Wilcox 		item_insert(&tree, start);
1731366c37eSMatthew Wilcox 		if (cur & 2) {
1741366c37eSMatthew Wilcox 			if (start <= end)
1751366c37eSMatthew Wilcox 				count++;
1761366c37eSMatthew Wilcox 			item_tag_set(&tree, start, 0);
1771366c37eSMatthew Wilcox 		}
1781366c37eSMatthew Wilcox 	}
1791366c37eSMatthew Wilcox 	if (cur & 4) {
1801366c37eSMatthew Wilcox 		item_insert(&tree, start-1);
1811366c37eSMatthew Wilcox 		if (cur & 8)
1821366c37eSMatthew Wilcox 			item_tag_set(&tree, start-1, 0);
1831366c37eSMatthew Wilcox 	}
1841366c37eSMatthew Wilcox 	if (cur & 16) {
1851366c37eSMatthew Wilcox 		item_insert(&tree, end);
1861366c37eSMatthew Wilcox 		if (cur & 32) {
1871366c37eSMatthew Wilcox 			if (start <= end)
1881366c37eSMatthew Wilcox 				count++;
1891366c37eSMatthew Wilcox 			item_tag_set(&tree, end, 0);
1901366c37eSMatthew Wilcox 		}
1911366c37eSMatthew Wilcox 	}
1921366c37eSMatthew Wilcox 	if (cur & 64) {
1931366c37eSMatthew Wilcox 		item_insert(&tree, end+1);
1941366c37eSMatthew Wilcox 		if (cur & 128)
1951366c37eSMatthew Wilcox 			item_tag_set(&tree, end+1, 0);
1961366c37eSMatthew Wilcox 	}
1971366c37eSMatthew Wilcox 
1981366c37eSMatthew Wilcox 	for (i = 0; i < ITEMS; i++) {
1991366c37eSMatthew Wilcox 		do {
2001366c37eSMatthew Wilcox 			idx[i] = rand();
2011366c37eSMatthew Wilcox 		} while (item_lookup(&tree, idx[i]));
2021366c37eSMatthew Wilcox 
2031366c37eSMatthew Wilcox 		item_insert(&tree, idx[i]);
2041366c37eSMatthew Wilcox 		if (rand() & 1) {
2051366c37eSMatthew Wilcox 			item_tag_set(&tree, idx[i], 0);
2061366c37eSMatthew Wilcox 			if (idx[i] >= start && idx[i] <= end)
2071366c37eSMatthew Wilcox 				count++;
2081366c37eSMatthew Wilcox 		}
2091366c37eSMatthew Wilcox /*		if (i % 1000 == 0)
2101366c37eSMatthew Wilcox 			putchar('.'); */
2111366c37eSMatthew Wilcox 	}
2121366c37eSMatthew Wilcox 
2131366c37eSMatthew Wilcox //	printf("\ncopying tags...\n");
214268f42deSMatthew Wilcox 	tagged = tag_tagged_items(&tree, NULL, start, end, ITEMS, 0, 1);
2151366c37eSMatthew Wilcox 
2161366c37eSMatthew Wilcox //	printf("checking copied tags\n");
2171366c37eSMatthew Wilcox 	assert(tagged == count);
2181366c37eSMatthew Wilcox 	check_copied_tags(&tree, start, end, idx, ITEMS, 0, 1);
2191366c37eSMatthew Wilcox 
2201366c37eSMatthew Wilcox 	/* Copy tags in several rounds */
2211366c37eSMatthew Wilcox //	printf("\ncopying tags...\n");
2221366c37eSMatthew Wilcox 	tmp = rand() % (count / 10 + 2);
223268f42deSMatthew Wilcox 	tagged = tag_tagged_items(&tree, NULL, start, end, tmp, 0, 2);
224268f42deSMatthew Wilcox 	assert(tagged == count);
2251366c37eSMatthew Wilcox 
2261366c37eSMatthew Wilcox //	printf("%lu %lu %lu\n", tagged, tmp, count);
2271366c37eSMatthew Wilcox //	printf("checking copied tags\n");
2281366c37eSMatthew Wilcox 	check_copied_tags(&tree, start, end, idx, ITEMS, 0, 2);
2291366c37eSMatthew Wilcox 	verify_tag_consistency(&tree, 0);
2301366c37eSMatthew Wilcox 	verify_tag_consistency(&tree, 1);
2311366c37eSMatthew Wilcox 	verify_tag_consistency(&tree, 2);
2321366c37eSMatthew Wilcox //	printf("\n");
2331366c37eSMatthew Wilcox 	item_kill_tree(&tree);
2341366c37eSMatthew Wilcox }
2351366c37eSMatthew Wilcox 
236eb73f7f3SRoss Zwisler static void __locate_check(struct radix_tree_root *tree, unsigned long index,
2370a2efc6cSMatthew Wilcox 			unsigned order)
238d42cb1a9SMatthew Wilcox {
239d42cb1a9SMatthew Wilcox 	struct item *item;
240d42cb1a9SMatthew Wilcox 	unsigned long index2;
241d42cb1a9SMatthew Wilcox 
2420a2efc6cSMatthew Wilcox 	item_insert_order(tree, index, order);
243d42cb1a9SMatthew Wilcox 	item = item_lookup(tree, index);
244478922e2SMatthew Wilcox 	index2 = find_item(tree, item);
245d42cb1a9SMatthew Wilcox 	if (index != index2) {
246*73bc029bSRehas Sachdeva 		printv(2, "index %ld order %d inserted; found %ld\n",
2470a2efc6cSMatthew Wilcox 			index, order, index2);
248d42cb1a9SMatthew Wilcox 		abort();
249d42cb1a9SMatthew Wilcox 	}
250d42cb1a9SMatthew Wilcox }
251d42cb1a9SMatthew Wilcox 
252eb73f7f3SRoss Zwisler static void __order_0_locate_check(void)
253eb73f7f3SRoss Zwisler {
254eb73f7f3SRoss Zwisler 	RADIX_TREE(tree, GFP_KERNEL);
255eb73f7f3SRoss Zwisler 	int i;
256eb73f7f3SRoss Zwisler 
257eb73f7f3SRoss Zwisler 	for (i = 0; i < 50; i++)
258eb73f7f3SRoss Zwisler 		__locate_check(&tree, rand() % INT_MAX, 0);
259eb73f7f3SRoss Zwisler 
260eb73f7f3SRoss Zwisler 	item_kill_tree(&tree);
261eb73f7f3SRoss Zwisler }
262eb73f7f3SRoss Zwisler 
263d42cb1a9SMatthew Wilcox static void locate_check(void)
264d42cb1a9SMatthew Wilcox {
265d42cb1a9SMatthew Wilcox 	RADIX_TREE(tree, GFP_KERNEL);
2660a2efc6cSMatthew Wilcox 	unsigned order;
267d42cb1a9SMatthew Wilcox 	unsigned long offset, index;
268d42cb1a9SMatthew Wilcox 
269eb73f7f3SRoss Zwisler 	__order_0_locate_check();
270eb73f7f3SRoss Zwisler 
2710a2efc6cSMatthew Wilcox 	for (order = 0; order < 20; order++) {
2720a2efc6cSMatthew Wilcox 		for (offset = 0; offset < (1 << (order + 3));
2730a2efc6cSMatthew Wilcox 		     offset += (1UL << order)) {
2740a2efc6cSMatthew Wilcox 			for (index = 0; index < (1UL << (order + 5));
2750a2efc6cSMatthew Wilcox 			     index += (1UL << order)) {
2760a2efc6cSMatthew Wilcox 				__locate_check(&tree, index + offset, order);
277d42cb1a9SMatthew Wilcox 			}
278478922e2SMatthew Wilcox 			if (find_item(&tree, &tree) != -1)
279d42cb1a9SMatthew Wilcox 				abort();
280d42cb1a9SMatthew Wilcox 
281d42cb1a9SMatthew Wilcox 			item_kill_tree(&tree);
282d42cb1a9SMatthew Wilcox 		}
2830a2efc6cSMatthew Wilcox 	}
284d42cb1a9SMatthew Wilcox 
285478922e2SMatthew Wilcox 	if (find_item(&tree, &tree) != -1)
286d42cb1a9SMatthew Wilcox 		abort();
2870a2efc6cSMatthew Wilcox 	__locate_check(&tree, -1, 0);
288478922e2SMatthew Wilcox 	if (find_item(&tree, &tree) != -1)
289d42cb1a9SMatthew Wilcox 		abort();
290d42cb1a9SMatthew Wilcox 	item_kill_tree(&tree);
291d42cb1a9SMatthew Wilcox }
292d42cb1a9SMatthew Wilcox 
293aa1d62d8SRoss Zwisler static void single_thread_tests(bool long_run)
2941366c37eSMatthew Wilcox {
2951366c37eSMatthew Wilcox 	int i;
2961366c37eSMatthew Wilcox 
297*73bc029bSRehas Sachdeva 	printv(1, "starting single_thread_tests: %d allocated, preempt %d\n",
298847d3576SMatthew Wilcox 		nr_allocated, preempt_count);
2994f3755d1SMatthew Wilcox 	multiorder_checks();
300af1c5ccaSMatthew Wilcox 	rcu_barrier();
301*73bc029bSRehas Sachdeva 	printv(2, "after multiorder_check: %d allocated, preempt %d\n",
302847d3576SMatthew Wilcox 		nr_allocated, preempt_count);
303d42cb1a9SMatthew Wilcox 	locate_check();
304af1c5ccaSMatthew Wilcox 	rcu_barrier();
305*73bc029bSRehas Sachdeva 	printv(2, "after locate_check: %d allocated, preempt %d\n",
306847d3576SMatthew Wilcox 		nr_allocated, preempt_count);
3071366c37eSMatthew Wilcox 	tag_check();
308af1c5ccaSMatthew Wilcox 	rcu_barrier();
309*73bc029bSRehas Sachdeva 	printv(2, "after tag_check: %d allocated, preempt %d\n",
310847d3576SMatthew Wilcox 		nr_allocated, preempt_count);
3111366c37eSMatthew Wilcox 	gang_check();
312af1c5ccaSMatthew Wilcox 	rcu_barrier();
313*73bc029bSRehas Sachdeva 	printv(2, "after gang_check: %d allocated, preempt %d\n",
314847d3576SMatthew Wilcox 		nr_allocated, preempt_count);
3151366c37eSMatthew Wilcox 	add_and_check();
316af1c5ccaSMatthew Wilcox 	rcu_barrier();
317*73bc029bSRehas Sachdeva 	printv(2, "after add_and_check: %d allocated, preempt %d\n",
318847d3576SMatthew Wilcox 		nr_allocated, preempt_count);
3191366c37eSMatthew Wilcox 	dynamic_height_check();
320af1c5ccaSMatthew Wilcox 	rcu_barrier();
321*73bc029bSRehas Sachdeva 	printv(2, "after dynamic_height_check: %d allocated, preempt %d\n",
322847d3576SMatthew Wilcox 		nr_allocated, preempt_count);
3230a835c4fSMatthew Wilcox 	idr_checks();
3240a835c4fSMatthew Wilcox 	ida_checks();
3250a835c4fSMatthew Wilcox 	rcu_barrier();
326*73bc029bSRehas Sachdeva 	printv(2, "after idr_checks: %d allocated, preempt %d\n",
3270a835c4fSMatthew Wilcox 		nr_allocated, preempt_count);
328aa1d62d8SRoss Zwisler 	big_gang_check(long_run);
329af1c5ccaSMatthew Wilcox 	rcu_barrier();
330*73bc029bSRehas Sachdeva 	printv(2, "after big_gang_check: %d allocated, preempt %d\n",
331847d3576SMatthew Wilcox 		nr_allocated, preempt_count);
332aa1d62d8SRoss Zwisler 	for (i = 0; i < (long_run ? 2000 : 3); i++) {
3331366c37eSMatthew Wilcox 		copy_tag_check();
334*73bc029bSRehas Sachdeva 		printv(2, "%d ", i);
3351366c37eSMatthew Wilcox 		fflush(stdout);
3361366c37eSMatthew Wilcox 	}
337af1c5ccaSMatthew Wilcox 	rcu_barrier();
338*73bc029bSRehas Sachdeva 	printv(2, "after copy_tag_check: %d allocated, preempt %d\n",
339847d3576SMatthew Wilcox 		nr_allocated, preempt_count);
3401366c37eSMatthew Wilcox }
3411366c37eSMatthew Wilcox 
342aa1d62d8SRoss Zwisler int main(int argc, char **argv)
3431366c37eSMatthew Wilcox {
344aa1d62d8SRoss Zwisler 	bool long_run = false;
345aa1d62d8SRoss Zwisler 	int opt;
346061ef393SMatthew Wilcox 	unsigned int seed = time(NULL);
347aa1d62d8SRoss Zwisler 
348*73bc029bSRehas Sachdeva 	while ((opt = getopt(argc, argv, "ls:v")) != -1) {
349aa1d62d8SRoss Zwisler 		if (opt == 'l')
350aa1d62d8SRoss Zwisler 			long_run = true;
351061ef393SMatthew Wilcox 		else if (opt == 's')
352061ef393SMatthew Wilcox 			seed = strtoul(optarg, NULL, 0);
353*73bc029bSRehas Sachdeva 		else if (opt == 'v')
354*73bc029bSRehas Sachdeva 			test_verbose++;
355aa1d62d8SRoss Zwisler 	}
356aa1d62d8SRoss Zwisler 
357061ef393SMatthew Wilcox 	printf("random seed %u\n", seed);
358061ef393SMatthew Wilcox 	srand(seed);
359061ef393SMatthew Wilcox 
360*73bc029bSRehas Sachdeva 	printf("running tests\n");
361*73bc029bSRehas Sachdeva 
3621366c37eSMatthew Wilcox 	rcu_register_thread();
3631366c37eSMatthew Wilcox 	radix_tree_init();
3641366c37eSMatthew Wilcox 
3651366c37eSMatthew Wilcox 	regression1_test();
3661366c37eSMatthew Wilcox 	regression2_test();
3672d6f45b8SKonstantin Khlebnikov 	regression3_test();
3683e3cdc68SMatthew Wilcox 	iteration_test(0, 10);
3693e3cdc68SMatthew Wilcox 	iteration_test(7, 20);
370aa1d62d8SRoss Zwisler 	single_thread_tests(long_run);
3711366c37eSMatthew Wilcox 
3726df5ee78SMatthew Wilcox 	/* Free any remaining preallocated nodes */
3736df5ee78SMatthew Wilcox 	radix_tree_cpu_dead(0);
3746df5ee78SMatthew Wilcox 
375cfa40bcfSKonstantin Khlebnikov 	benchmark();
376cfa40bcfSKonstantin Khlebnikov 
377af1c5ccaSMatthew Wilcox 	rcu_barrier();
378*73bc029bSRehas Sachdeva 	printv(2, "after rcu_barrier: %d allocated, preempt %d\n",
379847d3576SMatthew Wilcox 		nr_allocated, preempt_count);
3801366c37eSMatthew Wilcox 	rcu_unregister_thread();
3811366c37eSMatthew Wilcox 
382*73bc029bSRehas Sachdeva 	printf("tests completed\n");
383*73bc029bSRehas Sachdeva 
3841366c37eSMatthew Wilcox 	exit(0);
3851366c37eSMatthew Wilcox }
386