radix tree test suite: Dial down verbosity with -v
authorRehas Sachdeva <aquannie@gmail.com>
Wed, 4 Jan 2017 16:55:00 +0000 (11:55 -0500)
committerMatthew Wilcox <mawilcox@microsoft.com>
Tue, 14 Feb 2017 02:44:04 +0000 (21:44 -0500)
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: Rehas Sachdeva <aquannie@gmail.com>
Signed-off-by: Matthew Wilcox <mawilcox@microsoft.com>
tools/testing/radix-tree/benchmark.c
tools/testing/radix-tree/iteration_check.c
tools/testing/radix-tree/linux.c
tools/testing/radix-tree/linux/radix-tree.h
tools/testing/radix-tree/main.c
tools/testing/radix-tree/multiorder.c
tools/testing/radix-tree/regression1.c
tools/testing/radix-tree/regression2.c
tools/testing/radix-tree/regression3.c
tools/testing/radix-tree/tag_check.c

index 215ca86c7605527d59a208cb8b34f686a5ac4ba4..9b09ddfe462fd3b2ea782805560c349e720a4637 100644 (file)
@@ -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++)
index 7572b7ed930ecccbf043b6f9989f64b6cd27d0e7..a92bab51370139f673001cef8bf193463498bd98 100644 (file)
@@ -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;
index 3e4f9f36da2efe29d4cec4f159a47615e33c9f02..94bcdb992bbf68585d6efe0b6ebd8fad99d1fc90 100644 (file)
@@ -14,6 +14,7 @@
 int nr_allocated;
 int preempt_count;
 int kmalloc_verbose;
+int test_verbose;
 
 struct kmem_cache {
        pthread_mutex_t lock;
index f4d8532e1bef8f7a84394ba63f1736b30f980cfe..ddd135fa3af70d66228a05110babbe3c60b4e8be 100644 (file)
@@ -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)
 
index ddd90a11db3f4a548c41a6460c8dce26d45ee4e5..86de448b699e5b73c81b53af0009a2160b5b8fae 100644 (file)
@@ -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);
 }
index e465a3811b970b21c013c12b6bbe58aec7c95bf1..72d80f7059d3155da93b0d81940013c97b50c4a3 100644 (file)
@@ -30,7 +30,7 @@ static void __multiorder_tag_test(int index, int order)
        /* our canonical entry */
        base = index & ~((1 << order) - 1);
 
-       printf("Multiorder tag test with index %d, canonical entry %d\n",
+       printv(2, "Multiorder tag test with index %d, canonical entry %d\n",
                        index, base);
 
        err = item_insert_order(&tree, index, order);
@@ -150,7 +150,7 @@ static void multiorder_check(unsigned long index, int order)
        struct item *item2 = item_create(min, order);
        RADIX_TREE(tree, GFP_KERNEL);
 
-       printf("Multiorder index %ld, order %d\n", index, order);
+       printv(2, "Multiorder index %ld, order %d\n", index, order);
 
        assert(item_insert_order(&tree, index, order) == 0);
 
@@ -188,7 +188,7 @@ static void multiorder_shrink(unsigned long index, int order)
        RADIX_TREE(tree, GFP_KERNEL);
        struct radix_tree_node *node;
 
-       printf("Multiorder shrink index %ld, order %d\n", index, order);
+       printv(2, "Multiorder shrink index %ld, order %d\n", index, order);
 
        assert(item_insert_order(&tree, 0, order) == 0);
 
@@ -209,7 +209,8 @@ static void multiorder_shrink(unsigned long index, int order)
                item_check_absent(&tree, i);
 
        if (!item_delete(&tree, 0)) {
-               printf("failed to delete index %ld (order %d)\n", index, order);                abort();
+               printv(2, "failed to delete index %ld (order %d)\n", index, order);
+               abort();
        }
 
        for (i = 0; i < 2*max; i++)
@@ -234,7 +235,7 @@ void multiorder_iteration(void)
        void **slot;
        int i, j, err;
 
-       printf("Multiorder iteration test\n");
+       printv(1, "Multiorder iteration test\n");
 
 #define NUM_ENTRIES 11
        int index[NUM_ENTRIES] = {0, 2, 4, 8, 16, 32, 34, 36, 64, 72, 128};
@@ -275,7 +276,7 @@ void multiorder_tagged_iteration(void)
        void **slot;
        int i, j;
 
-       printf("Multiorder tagged iteration test\n");
+       printv(1, "Multiorder tagged iteration test\n");
 
 #define MT_NUM_ENTRIES 9
        int index[MT_NUM_ENTRIES] = {0, 2, 4, 16, 32, 40, 64, 72, 128};
@@ -453,7 +454,7 @@ static void check_mem(unsigned old_order, unsigned new_order, unsigned alloc)
 {
        struct radix_tree_preload *rtp = &radix_tree_preloads;
        if (rtp->nr != 0)
-               printf("split(%u %u) remaining %u\n", old_order, new_order,
+               printv(2, "split(%u %u) remaining %u\n", old_order, new_order,
                                                        rtp->nr);
        /*
         * Can't check for equality here as some nodes may have been
@@ -461,7 +462,7 @@ static void check_mem(unsigned old_order, unsigned new_order, unsigned alloc)
         * nodes allocated since they should have all been preloaded.
         */
        if (nr_allocated > alloc)
-               printf("split(%u %u) allocated %u %u\n", old_order, new_order,
+               printv(2, "split(%u %u) allocated %u %u\n", old_order, new_order,
                                                        alloc, nr_allocated);
 }
 
index 0d6813a61b37f904b436e74448c910a350c10bb3..bf97742fc18c1cc62e923acc448a5db64b5578fb 100644 (file)
@@ -193,7 +193,7 @@ void regression1_test(void)
        long arg;
 
        /* Regression #1 */
-       printf("running regression test 1, should finish in under a minute\n");
+       printv(1, "running regression test 1, should finish in under a minute\n");
        nr_threads = 2;
        pthread_barrier_init(&worker_barrier, NULL, nr_threads);
 
@@ -216,5 +216,5 @@ void regression1_test(void)
 
        free(threads);
 
-       printf("regression test 1, done\n");
+       printv(1, "regression test 1, done\n");
 }
index a41325d7a170eff26cca5f789f718492209eb1d5..a24d1beec7c80c6d96ba8224cf3dad9c062e9d2d 100644 (file)
@@ -80,7 +80,7 @@ void regression2_test(void)
        unsigned long int start, end;
        struct page *pages[1];
 
-       printf("running regression test 2 (should take milliseconds)\n");
+       printv(1, "running regression test 2 (should take milliseconds)\n");
        /* 0. */
        for (i = 0; i <= max_slots - 1; i++) {
                p = page_alloc();
@@ -116,5 +116,5 @@ void regression2_test(void)
        /* We remove all the remained nodes */
        radix_tree_delete(&mt_tree, max_slots);
 
-       printf("regression test 2, done\n");
+       printv(1, "regression test 2, done\n");
 }
index b594841fae8594c52a530b39cca7c2bdc772fb20..670c3d2ae7b189f9405d1ac536013a32ba9db188 100644 (file)
@@ -34,21 +34,21 @@ void regression3_test(void)
        void **slot;
        bool first;
 
-       printf("running regression test 3 (should take milliseconds)\n");
+       printv(1, "running regression test 3 (should take milliseconds)\n");
 
        radix_tree_insert(&root, 0, ptr0);
        radix_tree_tag_set(&root, 0, 0);
 
        first = true;
        radix_tree_for_each_tagged(slot, &root, &iter, 0, 0) {
-               printf("tagged %ld %p\n", iter.index, *slot);
+               printv(2, "tagged %ld %p\n", iter.index, *slot);
                if (first) {
                        radix_tree_insert(&root, 1, ptr);
                        radix_tree_tag_set(&root, 1, 0);
                        first = false;
                }
                if (radix_tree_deref_retry(*slot)) {
-                       printf("retry at %ld\n", iter.index);
+                       printv(2, "retry at %ld\n", iter.index);
                        slot = radix_tree_iter_retry(&iter);
                        continue;
                }
@@ -57,13 +57,13 @@ void regression3_test(void)
 
        first = true;
        radix_tree_for_each_slot(slot, &root, &iter, 0) {
-               printf("slot %ld %p\n", iter.index, *slot);
+               printv(2, "slot %ld %p\n", iter.index, *slot);
                if (first) {
                        radix_tree_insert(&root, 1, ptr);
                        first = false;
                }
                if (radix_tree_deref_retry(*slot)) {
-                       printk("retry at %ld\n", iter.index);
+                       printv(2, "retry at %ld\n", iter.index);
                        slot = radix_tree_iter_retry(&iter);
                        continue;
                }
@@ -72,30 +72,30 @@ void regression3_test(void)
 
        first = true;
        radix_tree_for_each_contig(slot, &root, &iter, 0) {
-               printk("contig %ld %p\n", iter.index, *slot);
+               printv(2, "contig %ld %p\n", iter.index, *slot);
                if (first) {
                        radix_tree_insert(&root, 1, ptr);
                        first = false;
                }
                if (radix_tree_deref_retry(*slot)) {
-                       printk("retry at %ld\n", iter.index);
+                       printv(2, "retry at %ld\n", iter.index);
                        slot = radix_tree_iter_retry(&iter);
                        continue;
                }
        }
 
        radix_tree_for_each_slot(slot, &root, &iter, 0) {
-               printf("slot %ld %p\n", iter.index, *slot);
+               printv(2, "slot %ld %p\n", iter.index, *slot);
                if (!iter.index) {
-                       printf("next at %ld\n", iter.index);
+                       printv(2, "next at %ld\n", iter.index);
                        slot = radix_tree_iter_resume(slot, &iter);
                }
        }
 
        radix_tree_for_each_contig(slot, &root, &iter, 0) {
-               printf("contig %ld %p\n", iter.index, *slot);
+               printv(2, "contig %ld %p\n", iter.index, *slot);
                if (!iter.index) {
-                       printf("next at %ld\n", iter.index);
+                       printv(2, "next at %ld\n", iter.index);
                        slot = radix_tree_iter_resume(slot, &iter);
                }
        }
@@ -103,9 +103,9 @@ void regression3_test(void)
        radix_tree_tag_set(&root, 0, 0);
        radix_tree_tag_set(&root, 1, 0);
        radix_tree_for_each_tagged(slot, &root, &iter, 0, 0) {
-               printf("tagged %ld %p\n", iter.index, *slot);
+               printv(2, "tagged %ld %p\n", iter.index, *slot);
                if (!iter.index) {
-                       printf("next at %ld\n", iter.index);
+                       printv(2, "next at %ld\n", iter.index);
                        slot = radix_tree_iter_resume(slot, &iter);
                }
        }
@@ -113,5 +113,5 @@ void regression3_test(void)
        radix_tree_delete(&root, 0);
        radix_tree_delete(&root, 1);
 
-       printf("regression test 3 passed\n");
+       printv(1, "regression test 3 passed\n");
 }
index fd98c132207aa353f4acce5413b4bf7c23c1cfda..d4ff009892456a3b588df788488027da45209ecf 100644 (file)
@@ -49,10 +49,10 @@ void simple_checks(void)
        }
        verify_tag_consistency(&tree, 0);
        verify_tag_consistency(&tree, 1);
-       printf("before item_kill_tree: %d allocated\n", nr_allocated);
+       printv(2, "before item_kill_tree: %d allocated\n", nr_allocated);
        item_kill_tree(&tree);
        rcu_barrier();
-       printf("after item_kill_tree: %d allocated\n", nr_allocated);
+       printv(2, "after item_kill_tree: %d allocated\n", nr_allocated);
 }
 
 /*
@@ -257,7 +257,7 @@ static void do_thrash(struct radix_tree_root *tree, char *thrash_state, int tag)
 
                gang_check(tree, thrash_state, tag);
 
-               printf("%d(%d) %d(%d) %d(%d) %d(%d) / "
+               printv(2, "%d(%d) %d(%d) %d(%d) %d(%d) / "
                                "%d(%d) present, %d(%d) tagged\n",
                        insert_chunk, nr_inserted,
                        delete_chunk, nr_deleted,
@@ -296,13 +296,13 @@ static void __leak_check(void)
 {
        RADIX_TREE(tree, GFP_KERNEL);
 
-       printf("%d: nr_allocated=%d\n", __LINE__, nr_allocated);
+       printv(2, "%d: nr_allocated=%d\n", __LINE__, nr_allocated);
        item_insert(&tree, 1000000);
-       printf("%d: nr_allocated=%d\n", __LINE__, nr_allocated);
+       printv(2, "%d: nr_allocated=%d\n", __LINE__, nr_allocated);
        item_delete(&tree, 1000000);
-       printf("%d: nr_allocated=%d\n", __LINE__, nr_allocated);
+       printv(2, "%d: nr_allocated=%d\n", __LINE__, nr_allocated);
        item_kill_tree(&tree);
-       printf("%d: nr_allocated=%d\n", __LINE__, nr_allocated);
+       printv(2, "%d: nr_allocated=%d\n", __LINE__, nr_allocated);
 }
 
 static void single_check(void)
@@ -336,15 +336,15 @@ void tag_check(void)
        extend_checks();
        contract_checks();
        rcu_barrier();
-       printf("after extend_checks: %d allocated\n", nr_allocated);
+       printv(2, "after extend_checks: %d allocated\n", nr_allocated);
        __leak_check();
        leak_check();
        rcu_barrier();
-       printf("after leak_check: %d allocated\n", nr_allocated);
+       printv(2, "after leak_check: %d allocated\n", nr_allocated);
        simple_checks();
        rcu_barrier();
-       printf("after simple_checks: %d allocated\n", nr_allocated);
+       printv(2, "after simple_checks: %d allocated\n", nr_allocated);
        thrash_tags();
        rcu_barrier();
-       printf("after thrash_tags: %d allocated\n", nr_allocated);
+       printv(2, "after thrash_tags: %d allocated\n", nr_allocated);
 }