Commit d999bd93 authored by Feng Tang's avatar Feng Tang Committed by Linus Torvalds

panic: add options to print system info when panic happens

Kernel panic issues are always painful to debug, partially because it's
not easy to get enough information of the context when panic happens.

And we have ramoops and kdump for that, while this commit tries to
provide a easier way to show the system info by adding a cmdline
parameter, referring some idea from sysrq handler.

Link: default avatarFeng Tang <>
Reviewed-by: default avatarKees Cook <>
Acked-by: default avatarSteven Rostedt (VMware) <>
Cc: Thomas Gleixner <>
Cc: John Stultz <>
Cc: Ingo Molnar <>
Cc: Peter Zijlstra <>
Cc: Steven Rostedt <>
Signed-off-by: default avatarAndrew Morton <>
Signed-off-by: default avatarLinus Torvalds <>
parent d1877155
......@@ -3092,6 +3092,14 @@
timeout < 0: reboot immediately
Format: <timeout>
panic_print= Bitmask for printing system info when panic happens.
User can chose combination of the following bits:
bit 0: print all tasks info
bit 1: print system memory info
bit 2: print timer info
bit 3: print locks info if CONFIG_LOCKDEP is on
bit 4: print ftrace buffer
panic_on_warn panic() instead of WARN(). Useful to cause kdump
on a WARN().
......@@ -46,6 +46,13 @@ int panic_on_warn __read_mostly;
int panic_timeout = CONFIG_PANIC_TIMEOUT;
#define PANIC_PRINT_TASK_INFO 0x00000001
#define PANIC_PRINT_MEM_INFO 0x00000002
#define PANIC_PRINT_TIMER_INFO 0x00000004
#define PANIC_PRINT_LOCK_INFO 0x00000008
#define PANIC_PRINT_FTRACE_INFO 0x00000010
static unsigned long panic_print;
......@@ -125,6 +132,24 @@ void nmi_panic(struct pt_regs *regs, const char *msg)
static void panic_print_sys_info(void)
if (panic_print & PANIC_PRINT_TASK_INFO)
if (panic_print & PANIC_PRINT_MEM_INFO)
show_mem(0, NULL);
if (panic_print & PANIC_PRINT_TIMER_INFO)
if (panic_print & PANIC_PRINT_LOCK_INFO)
if (panic_print & PANIC_PRINT_FTRACE_INFO)
* panic - halt the system
* @fmt: The text string to print
......@@ -254,6 +279,8 @@ void panic(const char *fmt, ...)
if (!panic_blink)
panic_blink = no_blink;
......@@ -658,6 +685,7 @@ void refcount_error_report(struct pt_regs *regs, const char *err)
core_param(panic, panic_timeout, int, 0644);
core_param(panic_print, panic_print, ulong, 0644);
core_param(pause_on_oops, pause_on_oops, int, 0644);
core_param(panic_on_warn, panic_on_warn, int, 0644);
core_param(crash_kexec_post_notifiers, crash_kexec_post_notifiers, bool, 0644);
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment