Linux kernel -stable discussions
 help / color / mirror / Atom feed
From: Sergey Senozhatsky <sergey.senozhatsky.work@gmail.com>
To: Petr Mladek <pmladek@suse.com>
Cc: Sergey Senozhatsky <sergey.senozhatsky@gmail.com>,
	Steven Rostedt <rostedt@goodmis.org>,
	Peter Zijlstra <peterz@infradead.org>,
	Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>,
	Sergey Senozhatsky <sergey.senozhatsky.work@gmail.com>,
	linux-kernel@vger.kernel.org, "4 . 13+" <stable@vger.kernel.org>
Subject: Re: [PATCH] printk/nmi: Prevent deadlock when serializing NMI backtraces
Date: Thu, 7 Jun 2018 14:40:13 +0900	[thread overview]
Message-ID: <20180607054013.GB10406@jagdpanzerIV> (raw)
In-Reply-To: <20180606111557.xzs6l3lkvg7lq3ts@pathway.suse.cz>

On (06/06/18 13:15), Petr Mladek wrote:
> On Wed 2018-06-06 14:10:29, Sergey Senozhatsky wrote:
> > On (06/05/18 14:47), Petr Mladek wrote:
> > [..]
> > > Grr, the ABBA deadlock is still there. NMIs are not sent to the other
> > > CPUs atomically. Even if we detect that logbuf_lock is available
> > > in printk_nmi_enter() on some CPUs, it might still get locked on
> > > another CPU before the other CPU gets NMI.
> > 
> > Can we do something about "B"? :) I mean - any chance we can rework
> > locking in nmi_cpu_backtrace()?
> 
> I can't think of any possibility at the moment. Well, it does not mean
> that it does not exist.
> 
> The irony is that we need the extra lock in nmi_cpu_backtrace() only
> because we try to store the messages into the common log buffer.
> If we always use the per-CPU buffers in NMI then the lock would
> not cause any problems but it also won't be necessary.

Yep. I think we can come up with something. It seems that the only
problem is that we want in this particular case to avoid printk_nmi()->logbuf
and instead we want to enforce per-CPU printk_nmi buffers. Then we can
drop nmi_cpu_backtrace() spinlock, because the messages will be
serialized by printk_safe flush spin_lock. That doesn't sound like an
impossible thing to do. What am I missing?

Could you please check my follow up email?

> > >   => I suggest to revert the commit 719f6a7040f1bdaf96fcc70
> > >      "printk: Use the main logbuf in NMI when logbuf_lock is available"
> > >      for-4.18 and stable until we get a better solution.
> > 
> > Just random thoughts.
> > 
> > May be we need to revert it, but let's not "panic". I think [but don't
> > insist on it] that the patch in question is *probably* "good enough". It
> > addresses a bug report after all.
> 
> It was a problem reported by me. I found it when testing other changes.
> The patch improved the situation definitely. The question is if it is
> enough in practice.

Oh, certainly. But I was talking about 719f6a7040f1bdaf96fcc70. We
introduced that change in response to a bug report from Steven. He would
not be able to debug his kernel otherwise, because per-CPU printk_nmi was
too limited in size.
So on one hand we have the problem that you reported, which you found
while you were hammering/testing NMI printk-s [a valid report on its
own]; on the other hand we have the problem that Steven reported, which
he triggered while he was debugging the kernel. It might be the case that
Steven's problem is more likely to happen in real world. So that's why I
proposed to keep 719f6a7040f1bda for the time being [until we come up with
another fix]. I may be wrong.

	-ss

      reply	other threads:[~2018-06-07  5:40 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-05-17 14:39 [PATCH] printk/nmi: Prevent deadlock when serializing NMI backtraces Petr Mladek
2018-05-18  2:07 ` Sergey Senozhatsky
2018-05-18  6:38   ` Sergey Senozhatsky
2018-05-18  8:10     ` Petr Mladek
2018-05-22 21:43 ` Steven Rostedt
2018-05-23  2:01   ` Sergey Senozhatsky
2018-05-28 12:27     ` Petr Mladek
2018-06-05 12:47 ` Petr Mladek
2018-06-06  5:10   ` Sergey Senozhatsky
2018-06-06 10:33     ` Sergey Senozhatsky
2018-06-08 10:48       ` Petr Mladek
2018-06-18  6:37         ` Sergey Senozhatsky
2018-06-18  9:39           ` Petr Mladek
2018-06-18 10:07             ` Sergey Senozhatsky
2018-06-19  7:52               ` Petr Mladek
2018-06-19  8:27                 ` Sergey Senozhatsky
2018-06-19 13:23                   ` Steven Rostedt
2018-06-20  1:58                     ` Sergey Senozhatsky
2018-06-20  2:32                       ` Steven Rostedt
2018-06-20  4:17                         ` Sergey Senozhatsky
2018-06-06 11:15     ` Petr Mladek
2018-06-07  5:40       ` Sergey Senozhatsky [this message]

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=20180607054013.GB10406@jagdpanzerIV \
    --to=sergey.senozhatsky.work@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=penguin-kernel@I-love.SAKURA.ne.jp \
    --cc=peterz@infradead.org \
    --cc=pmladek@suse.com \
    --cc=rostedt@goodmis.org \
    --cc=sergey.senozhatsky@gmail.com \
    --cc=stable@vger.kernel.org \
    /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