From: Liam R. Howlett Date: Wed, 31 Aug 2022 19:01:11 +0000 (-0400) Subject: maple_tree: Add MT_WARN_ON() X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=5fc3df059288acc730fd785b72828324ccb16f1b;p=users%2Fjedix%2Flinux-maple.git maple_tree: Add MT_WARN_ON() Add a debug macro to dump the tree and warn the user. Signed-off-by: Liam R. Howlett --- diff --git a/include/linux/maple_tree.h b/include/linux/maple_tree.h index 6914fa493710..71de6ef474e4 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("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 */