From: Sergey Senozhatsky Date: Mon, 6 Feb 2017 16:42:53 +0000 (+0900) Subject: printk: always use deferred printk when flush printk_safe lines X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=7acac3445acde1c94054cde69ab53503d296c393;p=GitHub%2FLineageOS%2Fandroid_kernel_motorola_exynos9610.git printk: always use deferred printk when flush printk_safe lines 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. Link: http://lkml.kernel.org/r/20170206164253.GA463@tigerII.localdomain Cc: Andrew Morton Cc: Linus Torvalds Cc: Jan Kara Cc: Tejun Heo Cc: Calvin Owens Cc: Ingo Molnar Cc: Peter Zijlstra Cc: Andy Lutomirski Cc: Peter Hurley Cc: linux-kernel@vger.kernel.org Signed-off-by: Sergey Senozhatsky Suggested-by: Petr Mladek Signed-off-by: Petr Mladek Reviewed-by: Steven Rostedt (VMware) --- diff --git a/kernel/printk/printk_safe.c b/kernel/printk/printk_safe.c index efc89a4e9df5..5214d326d3ba 100644 --- a/kernel/printk/printk_safe.c +++ b/kernel/printk/printk_safe.c @@ -110,17 +110,15 @@ again: return add; } -static void printk_safe_flush_line(const char *text, int len) +static inline 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 */