Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 40659
b: refs/heads/master
c: f46c483
h: refs/heads/master
i:
  40657: 36d4c98
  40655: 4e09a1c
v: v3
  • Loading branch information
Andrew Morton authored and Linus Torvalds committed Nov 3, 2006
1 parent db4528e commit 168ff46
Show file tree
Hide file tree
Showing 3 changed files with 24 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: 7f6b8876c7e66b0d15af134e2a5b87e55514eb6d
refs/heads/master: f46c483357c2d87606bbefb511321e3efd4baae0
2 changes: 2 additions & 0 deletions trunk/include/linux/kernel.h
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,8 @@ __attribute_const__ roundup_pow_of_two(unsigned long x)

extern int printk_ratelimit(void);
extern int __printk_ratelimit(int ratelimit_jiffies, int ratelimit_burst);
extern bool printk_timed_ratelimit(unsigned long *caller_jiffies,
unsigned int interval_msec);

static inline void console_silent(void)
{
Expand Down
21 changes: 21 additions & 0 deletions trunk/kernel/printk.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
#include <linux/security.h>
#include <linux/bootmem.h>
#include <linux/syscalls.h>
#include <linux/jiffies.h>

#include <asm/uaccess.h>

Expand Down Expand Up @@ -1101,3 +1102,23 @@ int printk_ratelimit(void)
printk_ratelimit_burst);
}
EXPORT_SYMBOL(printk_ratelimit);

/**
* printk_timed_ratelimit - caller-controlled printk ratelimiting
* @caller_jiffies: pointer to caller's state
* @interval_msecs: minimum interval between prints
*
* printk_timed_ratelimit() returns true if more than @interval_msecs
* milliseconds have elapsed since the last time printk_timed_ratelimit()
* returned true.
*/
bool printk_timed_ratelimit(unsigned long *caller_jiffies,
unsigned int interval_msecs)
{
if (*caller_jiffies == 0 || time_after(jiffies, *caller_jiffies)) {
*caller_jiffies = jiffies + msecs_to_jiffies(interval_msecs);
return true;
}
return false;
}
EXPORT_SYMBOL(printk_timed_ratelimit);

0 comments on commit 168ff46

Please sign in to comment.