aboutsummaryrefslogtreecommitdiffstats
path: root/kernel/printk
diff options
context:
space:
mode:
authorManinder Singh <maninder1.s@samsung.com>2018-06-01 04:56:42 -0400
committerPetr Mladek <pmladek@suse.com>2018-06-27 10:14:28 -0400
commit375899cddcbb26881b03cb3fbdcfd600e4e67f4a (patch)
treeb70cc79ff4ae2c25bc1e1fec4c09f967133e26ee /kernel/printk
parentce041c43f22298485122bab15c14d062383fbc67 (diff)
printk: make sure to print log on console.
This patch make sure printing of log on console if loglevel at time of storing log is less than current console loglevel. @why In SMP printk can work asynchronously, logs can be missed on console because it checks current log level at time of console_unlock, not at time of storing logs. func() { .... .... console_verbose(); // user wants to have all the logs on console. pr_alert(); dump_backtrace(); //prints with default loglevel. ... console_silent(); // stop all logs from printing on console. } Now if console_lock was owned by another process, the messages might be handled after the consoles were silenced. Reused flag LOG_NOCONS as its usage is gone long back by the commit 5c2992ee7fd8a29d0412 ("printk: remove console flushing special cases for partial buffered lines"). Note that there are still some corner cases where this patch is not enough. For example, when the messages are flushed later from printk_safe buffers or when there are races between console_verbose() and console_silent() callers. Link: http://lkml.kernel.org/r/20180601090029epcas5p3cc93d4bfbebb3199f0a2684058da7e26~z-a_jkmrI2993329933epcas5p3q@epcas5p3.samsung.com Cc: linux-kernel@vger.kernel.org Cc: a.sahrawat@samsung.com Cc: pankaj.m@samsung.com Cc: v.narang@samsung.com Cc: <maninder1.s@samsung.com> Signed-off-by: Vaneet Narang <v.narang@samsung.com> Signed-off-by: Maninder Singh <maninder1.s@samsung.com> Reviewed-by: Sergey Senozhatsky <sergey.senozhatsky@gmail.com> Signed-off-by: Petr Mladek <pmladek@suse.com>
Diffstat (limited to 'kernel/printk')
-rw-r--r--kernel/printk/printk.c12
1 files changed, 7 insertions, 5 deletions
diff --git a/kernel/printk/printk.c b/kernel/printk/printk.c
index 247808333ba4..3999c295d6f7 100644
--- a/kernel/printk/printk.c
+++ b/kernel/printk/printk.c
@@ -349,7 +349,7 @@ static int console_msg_format = MSG_FORMAT_DEFAULT;
349 */ 349 */
350 350
351enum log_flags { 351enum log_flags {
352 LOG_NOCONS = 1, /* already flushed, do not print to console */ 352 LOG_NOCONS = 1, /* suppress print, do not print to console */
353 LOG_NEWLINE = 2, /* text ended with a newline */ 353 LOG_NEWLINE = 2, /* text ended with a newline */
354 LOG_PREFIX = 4, /* text started with a prefix */ 354 LOG_PREFIX = 4, /* text started with a prefix */
355 LOG_CONT = 8, /* text is a fragment of a continuation line */ 355 LOG_CONT = 8, /* text is a fragment of a continuation line */
@@ -1886,6 +1886,9 @@ asmlinkage int vprintk_emit(int facility, int level,
1886 if (dict) 1886 if (dict)
1887 lflags |= LOG_PREFIX|LOG_NEWLINE; 1887 lflags |= LOG_PREFIX|LOG_NEWLINE;
1888 1888
1889 if (suppress_message_printing(level))
1890 lflags |= LOG_NOCONS;
1891
1889 printed_len = log_output(facility, level, lflags, dict, dictlen, text, text_len); 1892 printed_len = log_output(facility, level, lflags, dict, dictlen, text, text_len);
1890 1893
1891 logbuf_unlock_irqrestore(flags); 1894 logbuf_unlock_irqrestore(flags);
@@ -2349,11 +2352,10 @@ skip:
2349 break; 2352 break;
2350 2353
2351 msg = log_from_idx(console_idx); 2354 msg = log_from_idx(console_idx);
2352 if (suppress_message_printing(msg->level)) { 2355 if (msg->flags & LOG_NOCONS) {
2353 /* 2356 /*
2354 * Skip record we have buffered and already printed 2357 * Skip record if !ignore_loglevel, and
2355 * directly to the console when we received it, and 2358 * record has level above the console loglevel.
2356 * record that has level above the console loglevel.
2357 */ 2359 */
2358 console_idx = log_next(console_idx); 2360 console_idx = log_next(console_idx);
2359 console_seq++; 2361 console_seq++;