Always print panic message on current console
PATCH 1/1 Always print panic message on current console
The kernel offers with TIOCL_GETKMSGREDIRECT ioctl() the possibility to redirect the kernel messages to a specific console.
However, since it's not possible to switch to the kernel message console after a panic(), it would be nice if the kernel would print the panic message on the current console.
--- kernel/panic.c | 4 ++++ 1 files changed, 4 insertions(+), 0 deletions(-)
kernel/panic.c +4 -0
@@ -22,6 +22,7 @@#include <linux/init.h> #include <linux/nmi.h> #include <linux/dmi.h> +#include <linux/tty.h> int panic_on_oops;static unsigned long tainted_mask;
@@ -65,6 +66,9 @@ NORET_TYPE void panic(const char * fmt, ...)*/ preempt_disable (); +/* don't redirect the panic message to some hidden console */ + kmsg_redirect =0 ; +bust_spinlocks (1 );va_start (args, fmt);vsnprintf (buf,sizeof (buf), fmt, args);
Signature · 1 line
1.6.0.4
Quoted 18 lines · On Sun, 27 Sep 2009 14:36:54 +0200 Bernhard Walle <[email protected]> wrote:
The kernel offers with
TIOCL_GETKMSGREDIRECTioctl()the possibility to redirect the kernel messages to a specific console.However, since it's not possible to switch to the kernel message console after a
panic(), it would be nice if the kernel would print the panic message on the current console.Signed-off-by Bernhard Walle <[email protected]>--- kernel/panic.c | 4 ++++ 1 files changed, 4 insertions(+), 0 deletions(-)kernel/panic.c +0
-0
kernel/panic.c line 25
Quoted 4 lines
kernel/panic.c +1
-0@@ -22,6 +22,7 @@#include <linux/init.h> #include <linux/nmi.h> #include <linux/dmi.h> +#include <linux/tty.h>
It's odd that kmsg_redirect is declared in tty.h when it's purely a vt.c thing. Why not vt.h?
kernel/panic.c NORET_TYPE void panic(const char * fmt, ...) · line 74
Quoted 12 lines
kernel/panic.c +3
-0int panic_on_oops;static unsigned long tainted_mask;@@ -65,6 +66,9 @@ NORET_TYPE void panic(const char * fmt, ...)*/ preempt_disable (); +/* don't redirect the panic message to some hidden console */ + kmsg_redirect =0 ; +bust_spinlocks (1 );va_start (args, fmt);vsnprintf (buf,sizeof (buf), fmt, args);
Methinks CONFIG_HW_CONSOLE=n kernels won't link after making this change.
I'd suggest something like
#ifdef CONFIG_HW_CONSOLE
extern void vt_set_kmsg_redirect(int vt);
#else
static inline void vt_set_kmsg_redirect(int vt)
{
}
#endif
Another possible way of doing this would be for vt.c to hook itself into panic_notifier_list. That's nice and clean from a separation-of-subsystems POV but isn't really conceptually correct - it assumes that other entries on panic_notifier_list don't print messages to the console.