Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1545809

[PATCHv6 4/7] printk: always use deferred printk when flush printk_safe lines

From Sergey Senozhatsky <sergey.senozhatsky@gmail.com>
Newsgroups linux.kernel
Subject [PATCHv6 4/7] printk: always use deferred printk when flush printk_safe lines
Date 2016-12-21 15:50 +0100
Message-ID <sQQno-4FS-11@gated-at.bofh.it> (permalink)
References <sQQdH-4Cy-3@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


Always use printk_deferred() in printk_safe_flush_line().
Flushing can be done from NMI or printk_safe contexts (when
we are in panic), so we can't call console drivers, yet still
want to store the messages in the logbuf buffer. Therefore we
use a deferred printk version.

Signed-off-by: Sergey Senozhatsky <sergey.senozhatsky@gmail.com>
Suggested-by: Petr Mladek <pmladek@suse.com>
Reviewed-by: Petr Mladek <pmladek@suse.com>
---
 kernel/printk/printk_safe.c | 12 +++++-------
 1 file changed, 5 insertions(+), 7 deletions(-)

diff --git a/kernel/printk/printk_safe.c b/kernel/printk/printk_safe.c
index a041927a127b..9e8ef6a2070c 100644
--- a/kernel/printk/printk_safe.c
+++ b/kernel/printk/printk_safe.c
@@ -113,14 +113,12 @@ static int printk_safe_log_store(struct printk_safe_seq_buf *s,
 static void printk_safe_flush_line(const char *text, int len)
 {
 	/*
-	 * The buffers are flushed in NMI only on panic.  The messages must
-	 * go only into the ring buffer at this stage.  Consoles will get
-	 * explicitly called later when a crashdump is not generated.
+	 * Avoid any console drivers calls from here, because we may be
+	 * in NMI or printk_safe context (when in panic). The messages
+	 * must go only into the ring buffer at this stage.  Consoles will
+	 * get explicitly called later when a crashdump is not generated.
 	 */
-	if (in_nmi())
-		printk_deferred("%.*s", len, text);
-	else
-		printk("%.*s", len, text);
+	printk_deferred("%.*s", len, text);
 }
 
 /* printk part of the temporary buffer line by line */
-- 
2.11.0

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCHv6 0/7] printk: use printk_safe to handle printk() recursive calls Sergey Senozhatsky <sergey.senozhatsky@gmail.com> - 2016-12-21 15:40 +0100
  [PATCHv6 6/7] printk: use printk_safe buffers in printk Sergey Senozhatsky <sergey.senozhatsky@gmail.com> - 2016-12-21 15:40 +0100
    Re: [PATCHv6 6/7] printk: use printk_safe buffers in printk Sergey Senozhatsky <sergey.senozhatsky.work@gmail.com> - 2016-12-22 06:40 +0100
      Re: [PATCHv6 6/7] printk: use printk_safe buffers in printk Petr Mladek <pmladek@suse.com> - 2016-12-22 18:20 +0100
        Re: [PATCHv6 6/7] printk: use printk_safe buffers in printk Sergey Senozhatsky <sergey.senozhatsky.work@gmail.com> - 2016-12-23 02:50 +0100
          Re: [PATCHv6 6/7] printk: use printk_safe buffers in printk Petr Mladek <pmladek@suse.com> - 2016-12-23 11:00 +0100
  [PATCHv6 7/7] printk: remove zap_locks() function Sergey Senozhatsky <sergey.senozhatsky@gmail.com> - 2016-12-21 15:40 +0100
  [PATCHv6 2/7] printk: rename nmi.c and exported api Sergey Senozhatsky <sergey.senozhatsky@gmail.com> - 2016-12-21 15:40 +0100
    Re: [PATCHv6 2/7] printk: rename nmi.c and exported api Linus Torvalds <torvalds@linux-foundation.org> - 2016-12-21 20:50 +0100
      Re: [PATCHv6 2/7] printk: rename nmi.c and exported api Sergey Senozhatsky <sergey.senozhatsky.work@gmail.com> - 2016-12-22 02:20 +0100
  [PATCHv6 1/7] printk: use vprintk_func in vprintk() Sergey Senozhatsky <sergey.senozhatsky@gmail.com> - 2016-12-21 15:40 +0100
  [PATCHv6 4/7] printk: always use deferred printk when flush printk_safe lines Sergey Senozhatsky <sergey.senozhatsky@gmail.com> - 2016-12-21 15:50 +0100
  [PATCHv6 3/7] printk: introduce per-cpu safe_print seq buffer Sergey Senozhatsky <sergey.senozhatsky@gmail.com> - 2016-12-21 15:50 +0100
    Re: [PATCHv6 3/7] printk: introduce per-cpu safe_print seq buffer Sergey Senozhatsky <sergey.senozhatsky.work@gmail.com> - 2016-12-22 02:20 +0100
      Re: [PATCHv6 3/7] printk: introduce per-cpu safe_print seq buffer Petr Mladek <pmladek@suse.com> - 2016-12-22 17:40 +0100

csiph-web