]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
maple_tree: Clean up debug infrastructure
authorMatthew Wilcox (Oracle) <willy@infradead.org>
Thu, 27 Feb 2020 15:47:07 +0000 (10:47 -0500)
committerLiam R. Howlett <Liam.Howlett@Oracle.com>
Tue, 5 Jan 2021 17:28:24 +0000 (12:28 -0500)
making tests_run & tests_passed static means there's one copy of them in
every file that includes maple_tree.h.  Make them extern, prefix them
with maple_tree_, move them to maple_tree.c and export them so that
test_maple_tree can be built as a module.

Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
include/linux/maple_tree.h
lib/maple_tree.c
lib/test_maple_tree.c

index eb9ede385c02768e160f9cf31e347967eabd972c..a5d75366b24f3e98803df0f61eb6cfbd5df71c1f 100644 (file)
@@ -411,22 +411,22 @@ void *_mt_find(struct maple_tree *mt, unsigned long *index, unsigned long max,
 
 
 #ifdef CONFIG_DEBUG_MAPLE_TREE
-
-static unsigned int tests_run;
-static unsigned int tests_passed;
+extern unsigned int maple_tree_tests_run;
+extern unsigned int maple_tree_tests_passed;
 
 void mt_dump(const struct maple_tree *mt);
-#define MT_BUG_ON(tree, x) do {                                        \
-       tests_run++;                                            \
-       if (x) {                                                \
-               pr_info("BUG at %s:%d (%u)\n",                  \
-               __func__, __LINE__, x);                         \
-               mt_dump(tree);                                  \
-               pr_info("Pass: %u Run:%u\n", tests_passed, tests_run); \
-               dump_stack();                                   \
-       } else {                                                \
-               tests_passed++;                                 \
-       }                                                       \
+#define MT_BUG_ON(tree, x) do {                                                \
+       maple_tree_tests_run++;                                         \
+       if (x) {                                                        \
+               pr_info("BUG at %s:%d (%u)\n",                          \
+               __func__, __LINE__, x);                                 \
+               mt_dump(tree);                                          \
+               pr_info("Pass: %u Run:%u\n", maple_tree_tests_passed,   \
+                       maple_tree_tests_run);                          \
+               dump_stack();                                           \
+       } else {                                                        \
+               maple_tree_tests_passed++;                              \
+       }                                                               \
 } while (0)
 #else
 #define MT_BUG_ON(tree, x) BUG_ON(x)
index 3c68ad94d0acb0e8bcf6d1fa1acddce233eb5db4..3b0e24423810fb0051de41dbf881f765b26092c2 100644 (file)
@@ -15,7 +15,6 @@
 //#include <linux/mm.h> // for task_size
 
 #define CONFIG_DEBUG_MAPLE_TREE
-void mt_dump(const struct maple_tree *mt);
 #define MA_ROOT_PARENT 1
 #define ma_parent_ptr(x) ((struct maple_pnode *)(x))
 #define ma_mnode_ptr(x) ((struct maple_node *)(x))
@@ -4953,6 +4952,11 @@ void mtree_destroy(struct maple_tree *mt)
 EXPORT_SYMBOL(mtree_destroy);
 
 #ifdef CONFIG_DEBUG_MAPLE_TREE
+unsigned int maple_tree_tests_run;
+unsigned int maple_tree_tests_passed;
+EXPORT_SYMBOL_GPL(maple_tree_tests_run);
+EXPORT_SYMBOL_GPL(maple_tree_tests_passed);
+
 #ifndef __KERNEL__
 extern void kmem_cache_set_non_kernel(struct kmem_cache *, unsigned int);
 void mt_set_non_kernel(unsigned int val)
@@ -5004,7 +5008,6 @@ void mt_dump_entry(void *entry, unsigned long min, unsigned long max,
                pr_cont(""MA_PTR"\n", entry);
 }
 
-
 void mt_dump_range64(void *entry, unsigned long min, unsigned long max,
                unsigned int depth)
 {
@@ -5045,6 +5048,7 @@ void mt_dump_range64(void *entry, unsigned long min, unsigned long max,
                first = last + 1;
        }
 }
+
 void mt_dump_arange64(void *entry, unsigned long min, unsigned long max,
                unsigned int depth)
 {
index 7e86303c403f39e3745ab690722aff9dd6b32119..695cd392acbc5baaef59721f76615ebd4a257087 100644 (file)
@@ -11850,8 +11850,9 @@ static int maple_tree_seed(void)
        mtree_destroy(&tree);
        rcu_barrier();
 
-       pr_info("maple_tree: %u of %u tests passed\n", tests_passed, tests_run);
-       return (tests_run == tests_passed) ? 0 : -EINVAL;
+       pr_info("maple_tree: %u of %u tests passed\n", maple_tree_tests_passed,
+               maple_tree_tests_run);
+       return (maple_tree_tests_run == maple_tree_tests_passed) ? 0 : -EINVAL;
 }
 
 static void maple_tree_harvest(void)