lkml.org 
[lkml]   [2015]   [May]   [25]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
Subject[PATCH 00/10] printk: Avoid deadlock in NMI + vprintk_emit() cleanup
Date
The main source of deadlocks caused by printk() in NMI context has been
solved by the commit a9edc88093287 ("x86/nmi: Perform a safe NMI stack
trace on all CPUs").

But there are still few warnings printed in the NMI code that could
case a deadlock. For example, see the freeze discussed at
https://lkml.org/lkml/2015/5/20/481

The warnings are not easy to avoid. We could not postpone them easily.
We could not allocate buffers in NMI context. Therefore we would need
some lockless mechanism to share a buffer between NMI and normal context.
But this would make printk() code much more complicated and it is not
worth it. There has already been an attempt to do so and it has been
rejected, see https://lkml.org/lkml/2014/6/10/388


This patch set provides much easier solution. It prevents from
the deadlock on logbuf_lock by using trylock rather than spin_lock.
If the lock can not be taken, the message is ignored and some
warning is printed later on.

1st patch adds the simple solution.

2nd, 4th, 5th patches makes the solution a bit more robust.

3rd patch just shuffle some code to make 4th patch trivial.

6th..10th patches split the spaghetti vprintk_emit() into more
pieces. They basically just shuffle the code to make it
better readable.


The patch have been tested against Linus' tree but it can be applied
also against linux-next.

Petr Mladek (10):
printk: Avoid deadlock in NMI context
printk: Try harder to get logbuf_lock on NMI
printk: Move the deferred printk stuff
printk: Merge and flush NMI buffer predictably via IRQ work
printk: Try hard to print Oops message in NMI context
printk: Split delayed printing of warnings from vprintk_emit()
printk: Split text formatting and analyze from vprintk_emit()
printk: Detect scheduler messages in vprintk_format_and_analyze()
printk: Split text storing logic from vprintk_emit()
printk: Split console call from vprintk_emit()

kernel/printk/printk.c | 378 +++++++++++++++++++++++++++++++++++--------------
1 file changed, 269 insertions(+), 109 deletions(-)

--
1.8.5.6



\
 
 \ /
  Last update: 2015-05-25 15:01    [W:0.149 / U:2.156 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site