[RFC][PATCH v3 2/4] printk: do not console_cont_flush() on every jump to again

From: Sergey Senozhatsky
Date: Sat Jan 23 2016 - 03:18:13 EST


Every jump to `again' label will call console_cont_flush(),
which is not really something big -- it just adds one extra
raw_spin_lock_irqsave/raw_spin_unlock_irqrestore. However, to
keep the previous behaviour we can call console_cont_flush()
only when `retry' is false -- which happens once, all jumps
to `again' label have `retry' set to true.

Signed-off-by: Sergey Senozhatsky <sergey.senozhatsky@xxxxxxxxx>
---
kernel/printk/printk.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/kernel/printk/printk.c b/kernel/printk/printk.c
index c39232a..dc722fc 100644
--- a/kernel/printk/printk.c
+++ b/kernel/printk/printk.c
@@ -2213,7 +2213,7 @@ void console_unlock(void)
static u64 seen_seq;
unsigned long flags;
bool wake_klogd = false;
- bool do_cond_resched, retry;
+ bool do_cond_resched, retry = false;

if (console_suspended) {
up_console_sem();
@@ -2246,7 +2246,8 @@ again:
}

/* flush buffered message fragment immediately to console */
- console_cont_flush(text, sizeof(text));
+ if (!retry)
+ console_cont_flush(text, sizeof(text));

for (;;) {
struct printk_log *msg;
--
2.7.0