All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 00/10] printk: Avoid deadlock in NMI + vprintk_emit() cleanup
@ 2015-05-25 12:46 Petr Mladek
  2015-05-25 12:46 ` [PATCH 01/10] printk: Avoid deadlock in NMI context Petr Mladek
                   ` (10 more replies)
  0 siblings, 11 replies; 25+ messages in thread
From: Petr Mladek @ 2015-05-25 12:46 UTC (permalink / raw)
  To: Andrew Morton
  Cc: Frederic Weisbecker, Steven Rostedt, Dave Anderson,
	Paul E. McKenney, Kay Sievers, Jiri Kosina, Michal Hocko,
	Jan Kara, linux-kernel, Wang Long, peifeiyue, dzickus,
	morgan.wang, sasha.levin, Petr Mladek

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


^ permalink raw reply	[flat|nested] 25+ messages in thread

end of thread, other threads:[~2015-06-02  9:53 UTC | newest]

Thread overview: 25+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-05-25 12:46 [PATCH 00/10] printk: Avoid deadlock in NMI + vprintk_emit() cleanup Petr Mladek
2015-05-25 12:46 ` [PATCH 01/10] printk: Avoid deadlock in NMI context Petr Mladek
2015-05-27 23:13   ` Andrew Morton
2015-05-28 12:00     ` Petr Mladek
2015-05-25 12:46 ` [PATCH 02/10] printk: Try harder to get logbuf_lock on NMI Petr Mladek
2015-05-27 23:14   ` Andrew Morton
2015-05-28  7:54     ` Jiri Kosina
2015-05-28 13:50     ` Petr Mladek
2015-05-28 20:09       ` Andrew Morton
2015-05-29 10:56         ` Petr Mladek
2015-05-29 20:46           ` Andrew Morton
2015-05-25 12:46 ` [PATCH 03/10] printk: Move the deferred printk stuff Petr Mladek
2015-05-25 12:46 ` [PATCH 04/10] printk: Merge and flush NMI buffer predictably via IRQ work Petr Mladek
2015-05-27 23:14   ` Andrew Morton
2015-05-28 13:12     ` Petr Mladek
2015-05-25 12:46 ` [PATCH 05/10] printk: Try hard to print Oops message in NMI context Petr Mladek
2015-05-25 12:46 ` [PATCH 06/10] printk: Split delayed printing of warnings from vprintk_emit() Petr Mladek
2015-05-25 12:46 ` [PATCH 07/10] printk: Split text formatting and analyze " Petr Mladek
2015-05-25 12:46 ` [PATCH 08/10] printk: Detect scheduler messages in vprintk_format_and_analyze() Petr Mladek
2015-05-25 12:46 ` [PATCH 09/10] printk: Split text storing logic from vprintk_emit() Petr Mladek
2015-05-25 12:46 ` [PATCH 10/10] printk: Split console call " Petr Mladek
2015-05-29 20:50 ` [PATCH 00/10] printk: Avoid deadlock in NMI + vprintk_emit() cleanup Andrew Morton
2015-06-01 13:06   ` Jan Kara
2015-06-02  9:46     ` long.wanglong
2015-06-02  9:52       ` Jiri Kosina

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.