[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CALYGNiPp8546yGcC-TYSVq5X9tnPmrQsDecZxZ2smex9zKB5wg@mail.gmail.com>
Date: Sat, 13 Jul 2019 17:03:14 +0300
From: Konstantin Khlebnikov <koct9i@...il.com>
To: Sergey Senozhatsky <sergey.senozhatsky@...il.com>
Cc: Konstantin Khlebnikov <khlebnikov@...dex-team.ru>,
Petr Mladek <pmladek@...e.com>,
Linux Kernel Mailing List <linux-kernel@...r.kernel.org>,
Steven Rostedt <rostedt@...dmis.org>
Subject: Re: [PATCH] kernel/printk: prevent deadlock at calling kmsg_dump from
NMI context
On Sat, Jul 13, 2019 at 4:20 PM Sergey Senozhatsky
<sergey.senozhatsky@...il.com> wrote:
>
> On (07/13/19 09:46), Konstantin Khlebnikov wrote:
> > > On (07/12/19 17:54), Konstantin Khlebnikov wrote:
> >
> > Yep printk() can deal with NMI, but kmsg_dump() is a different beast.
> > It reads printk buffer and saves content into persistent storage like ACPI ERST.
>
> Ah, sorry! I misread your patch. Yeah, I see what you are doing.
>
> OK. So, I guess that for kmsg_dump(KMSG_DUMP_PANIC) we should be
> fine in general.
>
> We call kmsg_dump(KMSG_DUMP_PANIC) after smp_send_stop() and after
> printk_safe_flush_on_panic(). printk_safe_flush_on_panic() resets
> the state of logbuf_lock, so logbuf_lock, in general case, should
> be unlocked by the time we call kmsg_dump(KMSG_DUMP_PANIC).
> Even for nested contexts.
>
> CPU0
> printk()
> logbuf_lock_irqsave(flags)
> -> NMI
> panic()
> smp_send_stop()
> printk_safe_flush_on_panic()
> raw_spin_lock_init(&logbuf_lock) << reinit >>
> kmsg_dump(KMSG_DUMP_PANIC)
> logbuf_lock_irqsave(flags) << expected to be OK >>
>
> So do we have strong reasons to disable NMI->panic->kmsg_dump(DUMP_PANIC)?
>
> Other kmsg_dump(), maybe, can experience some troubles sometimes,
> need to check that.
Indeed, panic is especially handled and looks fine.
Sanity check in my patch could be relaxed:
if (WARN_ON_ONCE(reason != KMSG_DUMP_PANIC && in_nmi()))
return;
>
> -ss
Powered by blists - more mailing lists