diff options
Diffstat (limited to 'kernel/printk.c')
-rw-r--r-- | kernel/printk.c | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/kernel/printk.c b/kernel/printk.c index f7d427ef5038..66426552fbfe 100644 --- a/kernel/printk.c +++ b/kernel/printk.c | |||
@@ -31,6 +31,7 @@ | |||
31 | #include <linux/security.h> | 31 | #include <linux/security.h> |
32 | #include <linux/bootmem.h> | 32 | #include <linux/bootmem.h> |
33 | #include <linux/syscalls.h> | 33 | #include <linux/syscalls.h> |
34 | #include <linux/jiffies.h> | ||
34 | 35 | ||
35 | #include <asm/uaccess.h> | 36 | #include <asm/uaccess.h> |
36 | 37 | ||
@@ -1101,3 +1102,23 @@ int printk_ratelimit(void) | |||
1101 | printk_ratelimit_burst); | 1102 | printk_ratelimit_burst); |
1102 | } | 1103 | } |
1103 | EXPORT_SYMBOL(printk_ratelimit); | 1104 | EXPORT_SYMBOL(printk_ratelimit); |
1105 | |||
1106 | /** | ||
1107 | * printk_timed_ratelimit - caller-controlled printk ratelimiting | ||
1108 | * @caller_jiffies: pointer to caller's state | ||
1109 | * @interval_msecs: minimum interval between prints | ||
1110 | * | ||
1111 | * printk_timed_ratelimit() returns true if more than @interval_msecs | ||
1112 | * milliseconds have elapsed since the last time printk_timed_ratelimit() | ||
1113 | * returned true. | ||
1114 | */ | ||
1115 | bool printk_timed_ratelimit(unsigned long *caller_jiffies, | ||
1116 | unsigned int interval_msecs) | ||
1117 | { | ||
1118 | if (*caller_jiffies == 0 || time_after(jiffies, *caller_jiffies)) { | ||
1119 | *caller_jiffies = jiffies + msecs_to_jiffies(interval_msecs); | ||
1120 | return true; | ||
1121 | } | ||
1122 | return false; | ||
1123 | } | ||
1124 | EXPORT_SYMBOL(printk_timed_ratelimit); | ||