diff options
author | Joe Perches <joe@perches.com> | 2009-12-14 21:00:25 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2009-12-15 11:53:26 -0500 |
commit | 8a64f336bc1d4aa203b138d29d5a9c414a9fbb47 (patch) | |
tree | 2614009dbe403eff3a35729e4b725469454faf06 /include/linux/kernel.h | |
parent | 2643434c1ad400dc417865ac37610e8d3c7c1783 (diff) |
kernel.h: add printk_ratelimited and pr_<level>_rl
Add a printk_ratelimited statement expression macro that uses a per-call
ratelimit_state so that multiple subsystems output messages are not
suppressed by a global __ratelimit state.
[akpm@linux-foundation.org: coding-style fixes]
[akpm@linux-foundation.org: s/_rl/_ratelimited/g]
Signed-off-by: Joe Perches <joe@perches.com>
Cc: Naohiro Ooiwa <nooiwa@miraclelinux.com>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Hiroshi Shimamoto <h-shimamoto@ct.jp.nec.com>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'include/linux/kernel.h')
-rw-r--r-- | include/linux/kernel.h | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/include/linux/kernel.h b/include/linux/kernel.h index 910db75b1a72..4d9c916d06d9 100644 --- a/include/linux/kernel.h +++ b/include/linux/kernel.h | |||
@@ -405,6 +405,50 @@ static inline char *pack_hex_byte(char *buf, u8 byte) | |||
405 | #endif | 405 | #endif |
406 | 406 | ||
407 | /* | 407 | /* |
408 | * ratelimited messages with local ratelimit_state, | ||
409 | * no local ratelimit_state used in the !PRINTK case | ||
410 | */ | ||
411 | #ifdef CONFIG_PRINTK | ||
412 | #define printk_ratelimited(fmt, ...) ({ \ | ||
413 | static struct ratelimit_state _rs = { \ | ||
414 | .interval = DEFAULT_RATELIMIT_INTERVAL, \ | ||
415 | .burst = DEFAULT_RATELIMIT_BURST, \ | ||
416 | }; \ | ||
417 | \ | ||
418 | if (!__ratelimit(&_rs)) \ | ||
419 | printk(fmt, ##__VA_ARGS__); \ | ||
420 | }) | ||
421 | #else | ||
422 | /* No effect, but we still get type checking even in the !PRINTK case: */ | ||
423 | #define printk_ratelimited printk | ||
424 | #endif | ||
425 | |||
426 | #define pr_emerg_ratelimited(fmt, ...) \ | ||
427 | printk_ratelimited(KERN_EMERG pr_fmt(fmt), ##__VA_ARGS__) | ||
428 | #define pr_alert_ratelimited(fmt, ...) \ | ||
429 | printk_ratelimited(KERN_ALERT pr_fmt(fmt), ##__VA_ARGS__) | ||
430 | #define pr_crit_ratelimited(fmt, ...) \ | ||
431 | printk_ratelimited(KERN_CRIT pr_fmt(fmt), ##__VA_ARGS__) | ||
432 | #define pr_err_ratelimited(fmt, ...) \ | ||
433 | printk_ratelimited(KERN_ERR pr_fmt(fmt), ##__VA_ARGS__) | ||
434 | #define pr_warning_ratelimited(fmt, ...) \ | ||
435 | printk_ratelimited(KERN_WARNING pr_fmt(fmt), ##__VA_ARGS__) | ||
436 | #define pr_notice_ratelimited(fmt, ...) \ | ||
437 | printk_ratelimited(KERN_NOTICE pr_fmt(fmt), ##__VA_ARGS__) | ||
438 | #define pr_info_ratelimited(fmt, ...) \ | ||
439 | printk_ratelimited(KERN_INFO pr_fmt(fmt), ##__VA_ARGS__) | ||
440 | /* no pr_cont_ratelimited, don't do that... */ | ||
441 | /* If you are writing a driver, please use dev_dbg instead */ | ||
442 | #if defined(DEBUG) | ||
443 | #define pr_debug_ratelimited(fmt, ...) \ | ||
444 | printk_ratelimited(KERN_DEBUG pr_fmt(fmt), ##__VA_ARGS__) | ||
445 | #else | ||
446 | #define pr_debug_ratelimited(fmt, ...) \ | ||
447 | ({ if (0) printk_ratelimited(KERN_DEBUG pr_fmt(fmt), \ | ||
448 | ##__VA_ARGS__); 0; }) | ||
449 | #endif | ||
450 | |||
451 | /* | ||
408 | * General tracing related utility functions - trace_printk(), | 452 | * General tracing related utility functions - trace_printk(), |
409 | * tracing_on/tracing_off and tracing_start()/tracing_stop | 453 | * tracing_on/tracing_off and tracing_start()/tracing_stop |
410 | * | 454 | * |