Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 176339
b: refs/heads/master
c: 8a64f33
h: refs/heads/master
i:
  176337: 3f8f0d4
  176335: fbf8e63
v: v3
  • Loading branch information
Joe Perches authored and Linus Torvalds committed Dec 15, 2009
1 parent 5287317 commit 2602045
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 1 deletion.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 2643434c1ad400dc417865ac37610e8d3c7c1783
refs/heads/master: 8a64f336bc1d4aa203b138d29d5a9c414a9fbb47
44 changes: 44 additions & 0 deletions trunk/include/linux/kernel.h
Original file line number Diff line number Diff line change
Expand Up @@ -404,6 +404,50 @@ static inline char *pack_hex_byte(char *buf, u8 byte)
({ if (0) printk(KERN_DEBUG pr_fmt(fmt), ##__VA_ARGS__); 0; })
#endif

/*
* ratelimited messages with local ratelimit_state,
* no local ratelimit_state used in the !PRINTK case
*/
#ifdef CONFIG_PRINTK
#define printk_ratelimited(fmt, ...) ({ \
static struct ratelimit_state _rs = { \
.interval = DEFAULT_RATELIMIT_INTERVAL, \
.burst = DEFAULT_RATELIMIT_BURST, \
}; \
\
if (!__ratelimit(&_rs)) \
printk(fmt, ##__VA_ARGS__); \
})
#else
/* No effect, but we still get type checking even in the !PRINTK case: */
#define printk_ratelimited printk
#endif

#define pr_emerg_ratelimited(fmt, ...) \
printk_ratelimited(KERN_EMERG pr_fmt(fmt), ##__VA_ARGS__)
#define pr_alert_ratelimited(fmt, ...) \
printk_ratelimited(KERN_ALERT pr_fmt(fmt), ##__VA_ARGS__)
#define pr_crit_ratelimited(fmt, ...) \
printk_ratelimited(KERN_CRIT pr_fmt(fmt), ##__VA_ARGS__)
#define pr_err_ratelimited(fmt, ...) \
printk_ratelimited(KERN_ERR pr_fmt(fmt), ##__VA_ARGS__)
#define pr_warning_ratelimited(fmt, ...) \
printk_ratelimited(KERN_WARNING pr_fmt(fmt), ##__VA_ARGS__)
#define pr_notice_ratelimited(fmt, ...) \
printk_ratelimited(KERN_NOTICE pr_fmt(fmt), ##__VA_ARGS__)
#define pr_info_ratelimited(fmt, ...) \
printk_ratelimited(KERN_INFO pr_fmt(fmt), ##__VA_ARGS__)
/* no pr_cont_ratelimited, don't do that... */
/* If you are writing a driver, please use dev_dbg instead */
#if defined(DEBUG)
#define pr_debug_ratelimited(fmt, ...) \
printk_ratelimited(KERN_DEBUG pr_fmt(fmt), ##__VA_ARGS__)
#else
#define pr_debug_ratelimited(fmt, ...) \
({ if (0) printk_ratelimited(KERN_DEBUG pr_fmt(fmt), \
##__VA_ARGS__); 0; })
#endif

/*
* General tracing related utility functions - trace_printk(),
* tracing_on/tracing_off and tracing_start()/tracing_stop
Expand Down

0 comments on commit 2602045

Please sign in to comment.