linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Muchun Song <songmuchun@bytedance.com>
To: Sergey Senozhatsky <sergey.senozhatsky@gmail.com>
Cc: Petr Mladek <pmladek@suse.com>,
	Steven Rostedt <rostedt@goodmis.org>,
	john.ogness@linutronix.de,
	Andrew Morton <akpm@linux-foundation.org>,
	LKML <linux-kernel@vger.kernel.org>
Subject: Re: [External] Re: [PATCH v2] printk: fix deadlock when kernel panic
Date: Mon, 8 Feb 2021 23:40:07 +0800	[thread overview]
Message-ID: <CAMZfGtX-bHXoF_4rU+WzDNp+LmZj3CHWmurEvjCZBCyM2uiDMw@mail.gmail.com> (raw)
In-Reply-To: <YCE4tIrz/u/RkDc/@jagdpanzerIV.localdomain>

On Mon, Feb 8, 2021 at 9:12 PM Sergey Senozhatsky
<sergey.senozhatsky@gmail.com> wrote:
>
> On (21/02/08 16:49), Muchun Song wrote:
> > On Mon, Feb 8, 2021 at 2:38 PM Sergey Senozhatsky
> > <sergey.senozhatsky@gmail.com> wrote:
> > >
> > > On (21/02/06 13:41), Muchun Song wrote:
> > > > We found a deadlock bug on our server when the kernel panic. It can be
> > > > described in the following diagram.
> > > >
> > > > CPU0:                                         CPU1:
> > > > panic                                         rcu_dump_cpu_stacks
> > > >   kdump_nmi_shootdown_cpus                      nmi_trigger_cpumask_backtrace
> > > >     register_nmi_handler(crash_nmi_callback)      printk_safe_flush
> > > >                                                     __printk_safe_flush
> > > >                                                       raw_spin_lock_irqsave(&read_lock)
> > > >     // send NMI to other processors
> > > >     apic_send_IPI_allbutself(NMI_VECTOR)
> > > >                                                         // NMI interrupt, dead loop
> > > >                                                         crash_nmi_callback
> > >
> > > At what point does this decrement num_online_cpus()? Any chance that
> > > panic CPU can apic_send_IPI_allbutself() and printk_safe_flush_on_panic()
> > > before num_online_cpus() becomes 1?
> >
> > I took a closer look at the code. IIUC, It seems that there is no point
> > which decreases num_online_cpus.
>
> So then this never re-inits the safe_read_lock?

Right. If we encounter this case, we do not flush printk
buffer. So, it seems my previous patch is the right fix.
Right?

https://lore.kernel.org/patchwork/patch/1373563/

>
>                if (num_online_cpus() > 1)
>                        return;
>
>                debug_locks_off();
>                raw_spin_lock_init(&safe_read_lock);
>
>         -ss

  reply	other threads:[~2021-02-08 18:13 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-02-06  5:41 [PATCH v2] printk: fix deadlock when kernel panic Muchun Song
2021-02-08  6:38 ` Sergey Senozhatsky
2021-02-08  8:49   ` [External] " Muchun Song
2021-02-08 13:12     ` Sergey Senozhatsky
2021-02-08 15:40       ` Muchun Song [this message]
2021-02-09  8:39         ` Petr Mladek
2021-02-10  2:25           ` Sergey Senozhatsky
2021-02-09  9:19 ` Petr Mladek
2021-02-09 12:20   ` [External] " Muchun Song
2021-02-10  2:16   ` Sergey Senozhatsky

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAMZfGtX-bHXoF_4rU+WzDNp+LmZj3CHWmurEvjCZBCyM2uiDMw@mail.gmail.com \
    --to=songmuchun@bytedance.com \
    --cc=akpm@linux-foundation.org \
    --cc=john.ogness@linutronix.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=pmladek@suse.com \
    --cc=rostedt@goodmis.org \
    --cc=sergey.senozhatsky@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).