From 44e088a6bdf4823a625e17e107dfbf56a29d2e7b Mon Sep 17 00:00:00 2001 From: John Ogness <john.ogness@linutronix.de> Date: Fri, 19 Mar 2021 14:57:31 +0100 Subject: [PATCH 006/158] kdb: only use atomic consoles for output mirroring Currently kdb uses the @oops_in_progress hack to mirror kdb output to all active consoles from NMI context. Ignoring locks is unsafe. Now that an NMI-safe atomic interfaces is available for consoles, use that interface to mirror kdb output. Signed-off-by: John Ogness <john.ogness@linutronix.de> Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de> Signed-off-by: Thomas Gleixner <tglx@linutronix.de> --- kernel/debug/kdb/kdb_io.c | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) Index: linux-5.15.19-rt29/kernel/debug/kdb/kdb_io.c =================================================================== @ linux-5.15.19-rt29/kernel/debug/kdb/kdb_io.c:562 @ static void kdb_msg_write(const char *ms cp++; } + /* mirror output on atomic consoles */ for_each_console(c) { if (!(c->flags & CON_ENABLED)) continue; if (c == dbg_io_ops->cons) continue; - /* - * Set oops_in_progress to encourage the console drivers to - * disregard their internal spin locks: in the current calling - * context the risk of deadlock is a bigger problem than risks - * due to re-entering the console driver. We operate directly on - * oops_in_progress rather than using bust_spinlocks() because - * the calls bust_spinlocks() makes on exit are not appropriate - * for this calling context. - */ - ++oops_in_progress; - c->write(c, msg, msg_len); - --oops_in_progress; + + if (!c->write_atomic) + continue; + c->write_atomic(c, msg, msg_len); + touch_nmi_watchdog(); } }