aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/printk.h
diff options
context:
space:
mode:
authorJoe Perches <joe@perches.com>2013-10-26 23:41:53 -0400
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2013-10-29 19:50:52 -0400
commit29fc2bc75393864bbc9b90a7a13a0d0e11c6f41e (patch)
treec01b58e6f7bc61d12e1d1d1eeb036da31ea0ab6d /include/linux/printk.h
parent9d3bd7684645834ede59d285af1d70ccabee9bf3 (diff)
printk: pr_debug_ratelimited: check state first to reduce "callbacks suppressed" messages
pr_debug_ratelimited should be coded similarly to dev_dbg_ratelimited to reduce the "callbacks suppressed" messages. Add #include <linux/dynamic_debug.h> to printk.h. Unfortunately, this new #include must be after the prototype/declaration of function printk. It may be better to split out these _ratelimited declarations into a separate file one day. Any use of these pr_<foo>_ratelimited functions must also have another specific #include <ratelimited.h>. Most users have this done indirectly via #include <linux/kernel.h> printk.h may not #include <linux/ratelimit.h> as it causes circular dependencies and compilation failures. Signed-off-by: Joe Perches <joe@perches.com> Tested-by: Krzysztof Mazur <krzysiek@podlesie.net> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'include/linux/printk.h')
-rw-r--r--include/linux/printk.h16
1 files changed, 15 insertions, 1 deletions
diff --git a/include/linux/printk.h b/include/linux/printk.h
index e6131a782481..694925837a16 100644
--- a/include/linux/printk.h
+++ b/include/linux/printk.h
@@ -233,6 +233,8 @@ extern asmlinkage void dump_stack(void) __cold;
233 no_printk(KERN_DEBUG pr_fmt(fmt), ##__VA_ARGS__) 233 no_printk(KERN_DEBUG pr_fmt(fmt), ##__VA_ARGS__)
234#endif 234#endif
235 235
236#include <linux/dynamic_debug.h>
237
236/* If you are writing a driver, please use dev_dbg instead */ 238/* If you are writing a driver, please use dev_dbg instead */
237#if defined(CONFIG_DYNAMIC_DEBUG) 239#if defined(CONFIG_DYNAMIC_DEBUG)
238/* dynamic_pr_debug() uses pr_fmt() internally so we don't need it here */ 240/* dynamic_pr_debug() uses pr_fmt() internally so we don't need it here */
@@ -343,7 +345,19 @@ extern asmlinkage void dump_stack(void) __cold;
343#endif 345#endif
344 346
345/* If you are writing a driver, please use dev_dbg instead */ 347/* If you are writing a driver, please use dev_dbg instead */
346#if defined(DEBUG) 348#if defined(CONFIG_DYNAMIC_DEBUG)
349/* descriptor check is first to prevent flooding with "callbacks suppressed" */
350#define pr_debug_ratelimited(fmt, ...) \
351do { \
352 static DEFINE_RATELIMIT_STATE(_rs, \
353 DEFAULT_RATELIMIT_INTERVAL, \
354 DEFAULT_RATELIMIT_BURST); \
355 DEFINE_DYNAMIC_DEBUG_METADATA(descriptor, fmt); \
356 if (unlikely(descriptor.flags & _DPRINTK_FLAGS_PRINT) && \
357 __ratelimit(&_rs)) \
358 __dynamic_pr_debug(&descriptor, fmt, ##__VA_ARGS__); \
359} while (0)
360#elif defined(DEBUG)
347#define pr_debug_ratelimited(fmt, ...) \ 361#define pr_debug_ratelimited(fmt, ...) \
348 printk_ratelimited(KERN_DEBUG pr_fmt(fmt), ##__VA_ARGS__) 362 printk_ratelimited(KERN_DEBUG pr_fmt(fmt), ##__VA_ARGS__)
349#else 363#else