From 73142b40e76c1e6a1028786336d2b14ac9485576 Mon Sep 17 00:00:00 2001 From: "Liam R. Howlett" Date: Wed, 31 Aug 2022 15:01:11 -0400 Subject: [PATCH] maple_tree: Add MT_WARN_ON() Add a debug macro to dump the tree and warn the user. Signed-off-by: Liam R. Howlett --- include/linux/maple_tree.h | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/include/linux/maple_tree.h b/include/linux/maple_tree.h index 6914fa493710..03e383d5982a 100644 --- a/include/linux/maple_tree.h +++ b/include/linux/maple_tree.h @@ -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("BUG 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) MT_WARN_ON(__x) #endif /* CONFIG_DEBUG_MAPLE_TREE */ #endif /*_LINUX_MAPLE_TREE_H */ -- 2.50.1