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


Groups > linux.kernel > #1345632

Re: [PATCH] printk/nmi: restore printk_func in nmi_panic

From Petr Mladek <pmladek@suse.com>
Newsgroups linux.kernel
Subject Re: [PATCH] printk/nmi: restore printk_func in nmi_panic
Date 2016-02-29 11:40 +0100
Message-ID <r7tp9-1NN-29@gated-at.bofh.it> (permalink)
References <r6hq2-5F3-11@gated-at.bofh.it> <r6s25-4LU-9@gated-at.bofh.it> <r6CNP-4m4-1@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


On Sat 2016-02-27 11:19:44, Sergey Senozhatsky wrote:
> Hello Petr,
> 
> On (02/26/16 15:57), Petr Mladek wrote:
> > On Fri 2016-02-26 12:37:20, Sergey Senozhatsky wrote:
> > > When watchdog detects a hardlockup and calls nmi_panic() `printk_func'
> > > must be restored via printk_nmi_exit() call, so panic() will be able
> > > to flush nmi buf and show backtrace and panic message. We also better
> > > explicitly ask nmi to printk_nmi_flush() in console_flush_on_panic(),
> > > because it may be too late to rely on irq work.
> > > 
> > > Signed-off-by: Sergey Senozhatsky <sergey.senozhatsky@gmail.com>
> > > ---
> > >  include/linux/kernel.h | 6 ++++--
> > >  kernel/printk/printk.c | 1 +
> > >  2 files changed, 5 insertions(+), 2 deletions(-)
> > > 
> > > diff --git a/include/linux/kernel.h b/include/linux/kernel.h
> > > index f4fa2b2..3ee33d5 100644
> > > --- a/include/linux/kernel.h
> > > +++ b/include/linux/kernel.h
> > > @@ -469,10 +469,12 @@ do {									\
> > >  	cpu = raw_smp_processor_id();					\
> > >  	old_cpu = atomic_cmpxchg(&panic_cpu, PANIC_CPU_INVALID, cpu);	\
> > >  									\
> > > -	if (old_cpu == PANIC_CPU_INVALID)				\
> > > +	if (old_cpu == PANIC_CPU_INVALID) {				\
> > > +		printk_nmi_exit();					\
> > 
> > This might end up in a deadlock that printk_nmi() wanted to avoid.
> 
> aha, I see.
> 
> > I think about a compromise. We should try to get the messages
> > out only when kdump is not enabled.
> 
> can we zap_locks() if we are on nmi_panic()->panic()->console_flush_on_panic() path?

That is the problem. zap_locks() is not a solution.

First, it handles only lockbuf_lock and console_sem. There are other
locks used by particular consoles that might cause a deadlock.

Second, re-initializing locks is dangerous of its own. If they are
released by some other CPU that is still running, you might end up
in a deadlock because of a double release. In fact, I think that it
actually increases the risk. If there are more than 2 CPUs than
it is more likely that a printk is running on another CPU than
on the current one.


Peter Zijlstra had an idea of using early console in this case.
I am not sure but I guess that it does not have any internal locks.
But there is still the other problem with the double release.

I am afraid that the only solution is to make it configurable.
Some people might want to risk the deadlock and try to see the messages
on console. Others might rather want to get the crashdump for sure
with the cost that they will need to extract the NMI messages
from the per-CPU buffers.


Best Regards,
Petr

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


Thread

[PATCH] printk/nmi: restore printk_func in nmi_panic Sergey Senozhatsky <sergey.senozhatsky.work@gmail.com> - 2016-02-26 04:40 +0100
  Re: [PATCH] printk/nmi: restore printk_func in nmi_panic Petr Mladek <pmladek@suse.com> - 2016-02-26 16:00 +0100
    Re: [PATCH] printk/nmi: restore printk_func in nmi_panic Sergey Senozhatsky <sergey.senozhatsky@gmail.com> - 2016-02-27 03:30 +0100
      Re: [PATCH] printk/nmi: restore printk_func in nmi_panic Sergey Senozhatsky <sergey.senozhatsky@gmail.com> - 2016-02-27 04:20 +0100
        Re: [PATCH] printk/nmi: restore printk_func in nmi_panic Sergey Senozhatsky <sergey.senozhatsky@gmail.com> - 2016-02-27 04:40 +0100
          Re: [PATCH] printk/nmi: restore printk_func in nmi_panic Sergey Senozhatsky <sergey.senozhatsky@gmail.com> - 2016-02-28 05:00 +0100
      Re: [PATCH] printk/nmi: restore printk_func in nmi_panic Petr Mladek <pmladek@suse.com> - 2016-02-29 11:40 +0100
        Re: [PATCH] printk/nmi: restore printk_func in nmi_panic Sergey Senozhatsky <sergey.senozhatsky.work@gmail.com> - 2016-02-29 12:20 +0100
          Re: [PATCH] printk/nmi: restore printk_func in nmi_panic Sergey Senozhatsky <sergey.senozhatsky@gmail.com> - 2016-03-01 10:30 +0100
            Re: [PATCH] printk/nmi: restore printk_func in nmi_panic Petr Mladek <pmladek@suse.com> - 2016-03-01 12:10 +0100
              Re: [PATCH] printk/nmi: restore printk_func in nmi_panic Sergey Senozhatsky <sergey.senozhatsky@gmail.com> - 2016-03-01 14:20 +0100

csiph-web