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

From: Sergey Senozhatsky
Date: Tue May 22 2018 - 21:07:28 EST


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

-ss