lkml.org 
[lkml]   [2021]   [Aug]   [3]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH printk v1 09/10] kdb: if available, only use atomic consoles for output mirroring
Date
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 interface is available for consoles,
use only that interface to mirror kdb output if such a console is
available.

Signed-off-by: John Ogness <john.ogness@linutronix.de>
---
kernel/debug/kdb/kdb_io.c | 16 ++++++++++++++++
1 file changed, 16 insertions(+)

diff --git a/kernel/debug/kdb/kdb_io.c b/kernel/debug/kdb/kdb_io.c
index 6735ac36b718..871b89d6294b 100644
--- a/kernel/debug/kdb/kdb_io.c
+++ b/kernel/debug/kdb/kdb_io.c
@@ -544,6 +544,7 @@ static int kdb_search_string(char *searched, char *searchfor)

static void kdb_msg_write(const char *msg, int msg_len)
{
+ bool atomic_console_available;
struct console *c;
const char *cp;
int len;
@@ -559,11 +560,26 @@ static void kdb_msg_write(const char *msg, int msg_len)
cp++;
}

+ atomic_console_available = have_atomic_console();
+
for_each_console(c) {
if (!(c->flags & CON_ENABLED))
continue;
if (c == dbg_io_ops->cons)
continue;
+
+ /*
+ * If any atomic consoles are available, only atomic
+ * consoles are used.
+ */
+ if (atomic_console_available) {
+ if (c->write_atomic) {
+ c->write_atomic(c, msg, msg_len);
+ touch_nmi_watchdog();
+ }
+ continue;
+ }
+
/*
* Set oops_in_progress to encourage the console drivers to
* disregard their internal spin locks: in the current calling
--
2.20.1
\
 
 \ /
  Last update: 2021-08-03 15:13    [W:0.274 / U:0.884 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site