]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
maple_tree: Add MT_WARN_ON()
authorLiam R. Howlett <Liam.Howlett@oracle.com>
Wed, 31 Aug 2022 19:01:11 +0000 (15:01 -0400)
committerLiam R. Howlett <Liam.Howlett@oracle.com>
Tue, 13 Dec 2022 21:22:33 +0000 (16:22 -0500)
Add a debug macro to dump the tree and warn the user.

Signed-off-by: Liam R. Howlett <Liam.Howlett@oracle.com>
include/linux/maple_tree.h

index 6914fa493710242af6223b6057f08a3045c9a18b..71de6ef474e4c06361babc2a062783c471b8b26d 100644 (file)
@@ -701,8 +701,26 @@ void mt_cache_shrink(void);
                atomic_inc(&maple_tree_tests_passed);                   \
        }                                                               \
 } while (0)
+
+#define MT_WARN_ON(__tree, __x)  ({                                    \
+       int ret = !!(__x);                                              \
+       atomic_inc(&maple_tree_tests_run);                              \
+       if (ret) {                                                      \
+               pr_info("WARN at %s:%d (%u)\n",                         \
+               __func__, __LINE__, __x);                               \
+               mt_dump(__tree, mt_dump_hex);                           \
+               pr_info("Pass: %u Run:%u\n",                            \
+                       atomic_read(&maple_tree_tests_passed),          \
+                       atomic_read(&maple_tree_tests_run));            \
+               dump_stack();                                           \
+       } else {                                                        \
+               atomic_inc(&maple_tree_tests_passed);                   \
+       }                                                               \
+       unlikely(ret);                                                  \
+})
 #else
 #define MT_BUG_ON(__tree, __x) BUG_ON(__x)
+#define MT_WARN_ON(__tree, __x) WARN_ON(__x)
 #endif /* CONFIG_DEBUG_MAPLE_TREE */
 
 #endif /*_LINUX_MAPLE_TREE_H */