aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDave Young <hidave.darkstar@gmail.com>2009-09-22 19:43:33 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2009-09-23 10:39:28 -0400
commitaf91322ef3f29ae4114e736e2a72e28b4d619cf9 (patch)
treedebba08531c7dd78b90b5d8f2c03f6bf7c9e7877
parent3a3b6ed2235f2f619889dd6096e24b6d93bf3339 (diff)
printk: add printk_delay to make messages readable for some scenarios
When syslog is not possible, at the same time there's no serial/net console available, it will be hard to read the printk messages. For example oops/panic/warning messages in shutdown phase. Add a printk delay feature, we can make each printk message delay some milliseconds. Setting the delay by proc/sysctl interface: /proc/sys/kernel/printk_delay The value range from 0 - 10000, default value is 0 [akpm@linux-foundation.org: fix a few things] Signed-off-by: Dave Young <hidave.darkstar@gmail.com> Acked-by: Ingo Molnar <mingo@elte.hu> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
-rw-r--r--Documentation/sysctl/kernel.txt8
-rw-r--r--include/linux/kernel.h2
-rw-r--r--kernel/printk.c15
-rw-r--r--kernel/sysctl.c14
4 files changed, 39 insertions, 0 deletions
diff --git a/Documentation/sysctl/kernel.txt b/Documentation/sysctl/kernel.txt
index 3e5b63ebb821..b3d8b4922740 100644
--- a/Documentation/sysctl/kernel.txt
+++ b/Documentation/sysctl/kernel.txt
@@ -313,6 +313,14 @@ send before ratelimiting kicks in.
313 313
314============================================================== 314==============================================================
315 315
316printk_delay:
317
318Delay each printk message in printk_delay milliseconds
319
320Value from 0 - 10000 is allowed.
321
322==============================================================
323
316randomize-va-space: 324randomize-va-space:
317 325
318This option can be used to select the type of process address 326This option can be used to select the type of process address
diff --git a/include/linux/kernel.h b/include/linux/kernel.h
index 2b5b1e0899a8..0a2a19087863 100644
--- a/include/linux/kernel.h
+++ b/include/linux/kernel.h
@@ -246,6 +246,8 @@ extern int printk_ratelimit(void);
246extern bool printk_timed_ratelimit(unsigned long *caller_jiffies, 246extern bool printk_timed_ratelimit(unsigned long *caller_jiffies,
247 unsigned int interval_msec); 247 unsigned int interval_msec);
248 248
249extern int printk_delay_msec;
250
249/* 251/*
250 * Print a one-time message (analogous to WARN_ONCE() et al): 252 * Print a one-time message (analogous to WARN_ONCE() et al):
251 */ 253 */
diff --git a/kernel/printk.c b/kernel/printk.c
index 932ea21feb18..f38b07f78a4e 100644
--- a/kernel/printk.c
+++ b/kernel/printk.c
@@ -653,6 +653,20 @@ static int recursion_bug;
653static int new_text_line = 1; 653static int new_text_line = 1;
654static char printk_buf[1024]; 654static char printk_buf[1024];
655 655
656int printk_delay_msec __read_mostly;
657
658static inline void printk_delay(void)
659{
660 if (unlikely(printk_delay_msec)) {
661 int m = printk_delay_msec;
662
663 while (m--) {
664 mdelay(1);
665 touch_nmi_watchdog();
666 }
667 }
668}
669
656asmlinkage int vprintk(const char *fmt, va_list args) 670asmlinkage int vprintk(const char *fmt, va_list args)
657{ 671{
658 int printed_len = 0; 672 int printed_len = 0;
@@ -662,6 +676,7 @@ asmlinkage int vprintk(const char *fmt, va_list args)
662 char *p; 676 char *p;
663 677
664 boot_delay_msec(); 678 boot_delay_msec();
679 printk_delay();
665 680
666 preempt_disable(); 681 preempt_disable();
667 /* This stops the holder of console_sem just where we want him */ 682 /* This stops the holder of console_sem just where we want him */
diff --git a/kernel/sysctl.c b/kernel/sysctl.c
index 6ba49c7cb128..0dfaa47d7cb6 100644
--- a/kernel/sysctl.c
+++ b/kernel/sysctl.c
@@ -106,6 +106,9 @@ static int __maybe_unused one = 1;
106static int __maybe_unused two = 2; 106static int __maybe_unused two = 2;
107static unsigned long one_ul = 1; 107static unsigned long one_ul = 1;
108static int one_hundred = 100; 108static int one_hundred = 100;
109#ifdef CONFIG_PRINTK
110static int ten_thousand = 10000;
111#endif
109 112
110/* this is needed for the proc_doulongvec_minmax of vm_dirty_bytes */ 113/* this is needed for the proc_doulongvec_minmax of vm_dirty_bytes */
111static unsigned long dirty_bytes_min = 2 * PAGE_SIZE; 114static unsigned long dirty_bytes_min = 2 * PAGE_SIZE;
@@ -722,6 +725,17 @@ static struct ctl_table kern_table[] = {
722 .mode = 0644, 725 .mode = 0644,
723 .proc_handler = &proc_dointvec, 726 .proc_handler = &proc_dointvec,
724 }, 727 },
728 {
729 .ctl_name = CTL_UNNUMBERED,
730 .procname = "printk_delay",
731 .data = &printk_delay_msec,
732 .maxlen = sizeof(int),
733 .mode = 0644,
734 .proc_handler = &proc_dointvec_minmax,
735 .strategy = &sysctl_intvec,
736 .extra1 = &zero,
737 .extra2 = &ten_thousand,
738 },
725#endif 739#endif
726 { 740 {
727 .ctl_name = KERN_NGROUPS_MAX, 741 .ctl_name = KERN_NGROUPS_MAX,