Re: [PATCH] kernel/printk: prevent deadlock at calling kmsg_dump from NMI context
From: Sergey Senozhatsky
Date: Sat Jul 13 2019 - 02:09:55 EST
On (07/12/19 17:54), Konstantin Khlebnikov wrote:
> Function kmsg_dump could be invoked from NMI context intentionally or
> accidentally because it is called at various oops/panic paths.
> Kernel message dumpers are not ready to work in NMI context right now.
> They could deadlock on lockbuf_lock or break internal structures.
Hmm.
printk()-s from NMI go through per-CPU printk_safe/nmi - a bunch of
lockless buffers which is supposed to deal with printk() deadlocks,
including NMI printk()-s.
include/linux/hardirq.h
#define nmi_enter()
...
printk_nmi_enter();
...
#define nmi_exit()
...
printk_nmi_exit();
...
So we are not really supposed to deadlock.
-ss