Skip to contentSkip to conversation

printk delay for each line break instead of callback

PATCH In review Dave Young 2 participants 3 messages Feb 6, 2010 – Feb 9, 2010

lore
Share & tools
lore

Dave Young

author
#0 lore raw

PATCH 1/2 printk delay for each line break instead of callback

printk delay for every callback does not make sense, change to delay every line

---

 kernel/printk.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/printk.c +1 -1
@@ -678,7 +678,6 @@ asmlinkage int vprintk(const char *fmt, 
 	char *p;
 
 	boot_delay_msec();
-	printk_delay();
 
 	preempt_disable();
 	/* This stops the holder of console_sem just where we want him */
@@ -746,6 +745,7 @@ asmlinkage int vprintk(const char *fmt, 
 	 */
 	for ( ; *p; p++) {
 		if (new_text_line) {
+			printk_delay();
 			/* Always output the token */
 			emit_log_char('<');
 			emit_log_char(current_log_level + '0');
#1 lore raw
Quoted 19 lines · On Sat, 6 Feb 2010 21:34:25 +0800 Dave Young <[email protected]> wrote:

printk delay for every callback does not make sense, change to delay every line

---

 kernel/printk.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/printk.c +0 -1
@@ -678,7 +678,6 @@ asmlinkage int vprintk(const char *fmt, 
 	char *p;
 
 	boot_delay_msec();
-	printk_delay();
 
 	preempt_disable();
 	/* This stops the holder of console_sem just where we want him */

kernel/printk.c asmlinkage int vprintk(const char *fmt, · line 751

Quoted 7 lines
kernel/printk.c +1 -0
@@ -746,6 +745,7 @@ asmlinkage int vprintk(const char *fmt, 
 	 */
 	for ( ; *p; p++) {
 		if (new_text_line) {
+			printk_delay();
 			/* Always output the token */
 			emit_log_char('<');
 			emit_log_char(current_log_level + '0');

This moves the printk_delay() so that it is now inside spin_lock_irqsave(logbuf_lock).

This fixes the race I mentioned in the previous email, but it seems a bad idea. If the delay is long enough, it could even cause other CPUs to get hit by the NMI watchdog when trying to acquire logbuf_lock.

A better approach would be to perform the calculation of "how long must I delay" at this site, but perform the actual delay later, after the raw_local_irq_restore(). This means that if the printk contains "a\nb\nc\n" then we won't delay until the final \n, but that seems a fairly small problem.

author
#2 lore raw
Quoted 37 lines · Andrew Morton
Quoted 19 lines · On Sat, 6 Feb 2010 21:34:25 +0800 Dave Young <[email protected]> wrote:

printk delay for every callback does not make sense, change to delay every line

---

 kernel/printk.c |    2 +-

 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/printk.c 2010-02-02 13:39:19.446657319 +0800 renamed from kernel/printk.c    2010-02-02 13:38:47.646659531 +0800 +0 -1
@@ -678,7 +678,6 @@ asmlinkage int vprintk(const char *fmt,
       char *p;
 
       boot_delay_msec();
-     printk_delay();
 
       preempt_disable();
       /* This stops the holder of console_sem just where we want him */

kernel/printk.c 2010-02-02 13:39:19.446657319 +0800 asmlinkage int vprintk(const char *fmt, · line 751

Quoted 7 lines
kernel/printk.c 2010-02-02 13:39:19.446657319 +0800 renamed from kernel/printk.c    2010-02-02 13:38:47.646659531 +0800 +1 -0
@@ -746,6 +745,7 @@ asmlinkage int vprintk(const char *fmt,
        */
       for ( ; *p; p++) {
               if (new_text_line) {
+                     printk_delay();
                       /* Always output the token */
                       emit_log_char('<');
                       emit_log_char(current_log_level + '0');

This moves the printk_delay() so that it is now inside spin_lock_irqsave(logbuf_lock).

This fixes the race I mentioned in the previous email, but it seems a bad idea.  If the delay is long enough, it could even cause other CPUs to get hit by the NMI watchdog when trying to acquire logbuf_lock.

Quoted 6 lines

A better approach would be to perform the calculation of "how long must I delay" at this site, but perform the actual delay later, after the raw_local_irq_restore().  This means that if the printk contains "a\nb\nc\n" then we won't delay until the final \n, but that seems a fairly small problem.

Ok, agree. But need another variable to track '\n', if there's no line break then
it will not delay at the end of printk.

Signature · 2 lines
Regards
dave