From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751984AbcGOQ7p (ORCPT ); Fri, 15 Jul 2016 12:59:45 -0400 Received: from mx2.suse.de ([195.135.220.15]:50028 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751904AbcGOQ7e (ORCPT ); Fri, 15 Jul 2016 12:59:34 -0400 From: Petr Mladek To: Andrew Morton , Sergey Senozhatsky Cc: Jiri Kosina , Jan Kara , Tejun Heo , Tetsuo Handa , Byungchul Park , linux-kernel@vger.kernel.org, Petr Mladek Subject: [PATCH POC 3/4] printk: Flush the cont buffer after the other lines Date: Fri, 15 Jul 2016 18:59:01 +0200 Message-Id: <1468601942-18482-4-git-send-email-pmladek@suse.com> X-Mailer: git-send-email 1.8.5.6 In-Reply-To: <1468601942-18482-1-git-send-email-pmladek@suse.com> References: <1468601942-18482-1-git-send-email-pmladek@suse.com> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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