Skip to content

Commit

Permalink
kdb: only use atomic consoles for output mirroring
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
jogness authored and Sebastian Andrzej Siewior committed Sep 13, 2021
1 parent 27293f7 commit 2b7d3a8
Showing 1 changed file with 6 additions and 12 deletions.
18 changes: 6 additions & 12 deletions kernel/debug/kdb/kdb_io.c
Original file line number Diff line number Diff line change
Expand Up @@ -559,23 +559,17 @@ static void kdb_msg_write(const char *msg, int msg_len)
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();
}
}
Expand Down

0 comments on commit 2b7d3a8

Please sign in to comment.