Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 73bc029b authored by Rehas Sachdeva's avatar Rehas Sachdeva Committed by Matthew Wilcox
Browse files

radix tree test suite: Dial down verbosity with -v



Make the output of radix tree test suite less verbose by default and add
-v and -vv command line options for increasing level of verbosity.

Signed-off-by: default avatarRehas Sachdeva <aquannie@gmail.com>
Signed-off-by: default avatarMatthew Wilcox <mawilcox@microsoft.com>
parent 5eeb2d23
Loading
Loading
Loading
Loading
+3 −3
Original line number Diff line number Diff line
@@ -71,7 +71,7 @@ static void benchmark_size(unsigned long size, unsigned long step, int order)
	tagged = benchmark_iter(&tree, true);
	normal = benchmark_iter(&tree, false);

	printf("Size %ld, step %6ld, order %d tagged %10lld ns, normal %10lld ns\n",
	printv(2, "Size %ld, step %6ld, order %d tagged %10lld ns, normal %10lld ns\n",
		size, step, order, tagged, normal);

	item_kill_tree(&tree);
@@ -85,8 +85,8 @@ void benchmark(void)
				128, 256, 512, 12345, 0};
	int c, s;

	printf("starting benchmarks\n");
	printf("RADIX_TREE_MAP_SHIFT = %d\n", RADIX_TREE_MAP_SHIFT);
	printv(1, "starting benchmarks\n");
	printv(1, "RADIX_TREE_MAP_SHIFT = %d\n", RADIX_TREE_MAP_SHIFT);

	for (c = 0; size[c]; c++)
		for (s = 0; step[s]; s++)
+1 −1
Original line number Diff line number Diff line
@@ -177,7 +177,7 @@ void iteration_test(unsigned order, unsigned test_duration)
{
	int i;

	printf("Running %siteration tests for %d seconds\n",
	printv(1, "Running %siteration tests for %d seconds\n",
			order > 0 ? "multiorder " : "", test_duration);

	max_order = order;
+1 −0
Original line number Diff line number Diff line
@@ -14,6 +14,7 @@
int nr_allocated;
int preempt_count;
int kmalloc_verbose;
int test_verbose;

struct kmem_cache {
	pthread_mutex_t lock;
+6 −0
Original line number Diff line number Diff line
@@ -3,6 +3,7 @@
#include "../../../../include/linux/radix-tree.h"

extern int kmalloc_verbose;
extern int test_verbose;

static inline void trace_call_rcu(struct rcu_head *head,
		void (*func)(struct rcu_head *head))
@@ -12,6 +13,11 @@ static inline void trace_call_rcu(struct rcu_head *head,
				offsetof(struct radix_tree_node, rcu_head));
	call_rcu(head, func);
}

#define printv(verbosity_level, fmt, ...) \
	if(test_verbose >= verbosity_level) \
		printf(fmt, ##__VA_ARGS__)

#undef call_rcu
#define call_rcu(x, y) trace_call_rcu(x, y)

+28 −17
Original line number Diff line number Diff line
@@ -68,7 +68,7 @@ void big_gang_check(bool long_run)

	for (i = 0; i < (long_run ? 1000 : 3); i++) {
		__big_gang_check();
		printf("%d ", i);
		printv(2, "%d ", i);
		fflush(stdout);
	}
}
@@ -129,14 +129,19 @@ void check_copied_tags(struct radix_tree_root *tree, unsigned long start, unsign
			putchar('.'); */
		if (idx[i] < start || idx[i] > end) {
			if (item_tag_get(tree, idx[i], totag)) {
				printf("%lu-%lu: %lu, tags %d-%d\n", start, end, idx[i], item_tag_get(tree, idx[i], fromtag), item_tag_get(tree, idx[i], totag));
				printv(2, "%lu-%lu: %lu, tags %d-%d\n", start,
				       end, idx[i], item_tag_get(tree, idx[i],
								 fromtag),
				       item_tag_get(tree, idx[i], totag));
			}
			assert(!item_tag_get(tree, idx[i], totag));
			continue;
		}
		if (item_tag_get(tree, idx[i], fromtag) ^
			item_tag_get(tree, idx[i], totag)) {
			printf("%lu-%lu: %lu, tags %d-%d\n", start, end, idx[i], item_tag_get(tree, idx[i], fromtag), item_tag_get(tree, idx[i], totag));
			printv(2, "%lu-%lu: %lu, tags %d-%d\n", start, end,
			       idx[i], item_tag_get(tree, idx[i], fromtag),
			       item_tag_get(tree, idx[i], totag));
		}
		assert(!(item_tag_get(tree, idx[i], fromtag) ^
			 item_tag_get(tree, idx[i], totag)));
@@ -238,7 +243,7 @@ static void __locate_check(struct radix_tree_root *tree, unsigned long index,
	item = item_lookup(tree, index);
	index2 = find_item(tree, item);
	if (index != index2) {
		printf("index %ld order %d inserted; found %ld\n",
		printv(2, "index %ld order %d inserted; found %ld\n",
			index, order, index2);
		abort();
	}
@@ -289,48 +294,48 @@ static void single_thread_tests(bool long_run)
{
	int i;

	printf("starting single_thread_tests: %d allocated, preempt %d\n",
	printv(1, "starting single_thread_tests: %d allocated, preempt %d\n",
		nr_allocated, preempt_count);
	multiorder_checks();
	rcu_barrier();
	printf("after multiorder_check: %d allocated, preempt %d\n",
	printv(2, "after multiorder_check: %d allocated, preempt %d\n",
		nr_allocated, preempt_count);
	locate_check();
	rcu_barrier();
	printf("after locate_check: %d allocated, preempt %d\n",
	printv(2, "after locate_check: %d allocated, preempt %d\n",
		nr_allocated, preempt_count);
	tag_check();
	rcu_barrier();
	printf("after tag_check: %d allocated, preempt %d\n",
	printv(2, "after tag_check: %d allocated, preempt %d\n",
		nr_allocated, preempt_count);
	gang_check();
	rcu_barrier();
	printf("after gang_check: %d allocated, preempt %d\n",
	printv(2, "after gang_check: %d allocated, preempt %d\n",
		nr_allocated, preempt_count);
	add_and_check();
	rcu_barrier();
	printf("after add_and_check: %d allocated, preempt %d\n",
	printv(2, "after add_and_check: %d allocated, preempt %d\n",
		nr_allocated, preempt_count);
	dynamic_height_check();
	rcu_barrier();
	printf("after dynamic_height_check: %d allocated, preempt %d\n",
	printv(2, "after dynamic_height_check: %d allocated, preempt %d\n",
		nr_allocated, preempt_count);
	idr_checks();
	ida_checks();
	rcu_barrier();
	printf("after idr_checks: %d allocated, preempt %d\n",
	printv(2, "after idr_checks: %d allocated, preempt %d\n",
		nr_allocated, preempt_count);
	big_gang_check(long_run);
	rcu_barrier();
	printf("after big_gang_check: %d allocated, preempt %d\n",
	printv(2, "after big_gang_check: %d allocated, preempt %d\n",
		nr_allocated, preempt_count);
	for (i = 0; i < (long_run ? 2000 : 3); i++) {
		copy_tag_check();
		printf("%d ", i);
		printv(2, "%d ", i);
		fflush(stdout);
	}
	rcu_barrier();
	printf("after copy_tag_check: %d allocated, preempt %d\n",
	printv(2, "after copy_tag_check: %d allocated, preempt %d\n",
		nr_allocated, preempt_count);
}

@@ -340,16 +345,20 @@ int main(int argc, char **argv)
	int opt;
	unsigned int seed = time(NULL);

	while ((opt = getopt(argc, argv, "ls:")) != -1) {
	while ((opt = getopt(argc, argv, "ls:v")) != -1) {
		if (opt == 'l')
			long_run = true;
		else if (opt == 's')
			seed = strtoul(optarg, NULL, 0);
		else if (opt == 'v')
			test_verbose++;
	}

	printf("random seed %u\n", seed);
	srand(seed);

	printf("running tests\n");

	rcu_register_thread();
	radix_tree_init();

@@ -366,9 +375,11 @@ int main(int argc, char **argv)
	benchmark();

	rcu_barrier();
	printf("after rcu_barrier: %d allocated, preempt %d\n",
	printv(2, "after rcu_barrier: %d allocated, preempt %d\n",
		nr_allocated, preempt_count);
	rcu_unregister_thread();

	printf("tests completed\n");

	exit(0);
}
Loading