Re: [PATCH] printk/nmi: Prevent deadlock when serializing NMI backtraces

From: Petr Mladek
Date: Mon May 28 2018 - 11:56:50 EST


On Wed 2018-05-23 11:01:07, Sergey Senozhatsky wrote:
> On (05/22/18 17:43), Steven Rostedt wrote:
> > > CPU0 CPU1 CPU2
> > >
> > > printk()
> > > vprintk_emit()
> > > spin_lock(&logbuf_lock)
> > >
> > > trigger_all_cpu_backtrace()
> > > raise()
> > >
> > > nmi_enter()
> > > printk_nmi_enter()
> > > if (this_cpu_read(printk_context)
> > > & PRINTK_SAFE_CONTEXT_MASK)
> > > // false
> > > else
> > > // looks safe to use printk_deferred()
> > > this_cpu_or(printk_context,
> > > PRINTK_NMI_DEFERRED_CONTEXT_MASK);
> > >
> > > nmi_cpu_backtrace()
> > > arch_spin_lock(&lock);
> >
> > What branch is this based on, because I can't find the
> > "arch_spin_lock()" you are talking about here.
>
> This arch_spin_lock() is in lib/nmi_backtrace.c
>
> https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/lib/nmi_backtrace.c?h=v4.17-rc6#n94

JFYI, I have pushed the patch into printk.git, for-4.18 branch, see
https://git.kernel.org/pub/scm/linux/kernel/git/pmladek/printk.git/commit/?h=for-4.18&id=42f139d887cbb2c396dd61f4f13d4facfde5739e

Best Regards,
Petr