diff options
Diffstat (limited to 'kernel/printk.c')
| -rw-r--r-- | kernel/printk.c | 32 |
1 files changed, 23 insertions, 9 deletions
diff --git a/kernel/printk.c b/kernel/printk.c index 771f5e861bcd..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 | ||
| @@ -820,15 +821,8 @@ void release_console_sem(void) | |||
| 820 | console_locked = 0; | 821 | console_locked = 0; |
| 821 | up(&console_sem); | 822 | up(&console_sem); |
| 822 | spin_unlock_irqrestore(&logbuf_lock, flags); | 823 | spin_unlock_irqrestore(&logbuf_lock, flags); |
| 823 | if (wake_klogd && !oops_in_progress && waitqueue_active(&log_wait)) { | 824 | if (wake_klogd && !oops_in_progress && waitqueue_active(&log_wait)) |
| 824 | /* | 825 | wake_up_interruptible(&log_wait); |
| 825 | * If we printk from within the lock dependency code, | ||
| 826 | * from within the scheduler code, then do not lock | ||
| 827 | * up due to self-recursion: | ||
| 828 | */ | ||
| 829 | if (!lockdep_internal()) | ||
| 830 | wake_up_interruptible(&log_wait); | ||
| 831 | } | ||
| 832 | } | 826 | } |
| 833 | EXPORT_SYMBOL(release_console_sem); | 827 | EXPORT_SYMBOL(release_console_sem); |
| 834 | 828 | ||
| @@ -1108,3 +1102,23 @@ int printk_ratelimit(void) | |||
| 1108 | printk_ratelimit_burst); | 1102 | printk_ratelimit_burst); |
| 1109 | } | 1103 | } |
| 1110 | 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); | ||
