[PATCH POC 3/4] printk: Flush the cont buffer after the other lines

From: Petr Mladek
Date: Fri Jul 15 2016 - 12:59:47 EST


The cont buffer is not longer blocked until the rest of
the line is stored. Instead, the remaining part of the line
is printed from the ring buffer in the normal cycle.

Therefore console_cont_flush() always prints only
the very last line and it makes sense to call it
after the main cycle.

Note that it is safe to modify exclusive_console
and console_locked variables without the logbuf_lock.
They both are primary synchronized by the console_sem.
---
kernel/printk/printk.c | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/kernel/printk/printk.c b/kernel/printk/printk.c
index 7d93ac263006..a920cc36c24e 100644
--- a/kernel/printk/printk.c
+++ b/kernel/printk/printk.c
@@ -2258,9 +2258,6 @@ again:
return;
}

- /* flush buffered message fragment immediately to console */
- console_cont_flush(text, sizeof(text));
-
for (;;) {
struct printk_log *msg;
size_t ext_len = 0;
@@ -2334,14 +2331,17 @@ again:
if (do_cond_resched)
cond_resched();
}
- console_locked = 0;
+
+ raw_spin_unlock(&logbuf_lock);
+
+ /* flush buffered message fragment immediately to console */
+ console_cont_flush(text, sizeof(text));

/* Release the exclusive_console once it is used */
if (unlikely(exclusive_console))
exclusive_console = NULL;

- raw_spin_unlock(&logbuf_lock);
-
+ console_locked = 0;
up_console_sem();

/*
--
1.8.5.6