aboutsummaryrefslogtreecommitdiffstats
path: root/kernel
diff options
context:
space:
mode:
authorFeng Tang <feng.tang@intel.com>2019-01-03 18:28:17 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2019-01-04 16:13:47 -0500
commitd999bd9392dea7c1a9ac43b8680b22c4425ae4c7 (patch)
tree55636facade107a4c2205b4c59cf769a1e9ef9bc /kernel
parentd1877155891020cb26ad4fba45bfee52d8da9951 (diff)
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: http://lkml.kernel.org/r/1543398842-19295-2-git-send-email-feng.tang@intel.com Signed-off-by: Feng Tang <feng.tang@intel.com> Reviewed-by: Kees Cook <keescook@chromium.org> Acked-by: Steven Rostedt (VMware) <rostedt@goodmis.org> Cc: Thomas Gleixner <tglx@linutronix.de> Cc: John Stultz <john.stultz@linaro.org> Cc: Ingo Molnar <mingo@kernel.org> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Steven Rostedt <rostedt@goodmis.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'kernel')
-rw-r--r--kernel/panic.c28
1 files changed, 28 insertions, 0 deletions
diff --git a/kernel/panic.c b/kernel/panic.c
index d10c340c43b0..855f66738bc7 100644
--- a/kernel/panic.c
+++ b/kernel/panic.c
@@ -46,6 +46,13 @@ int panic_on_warn __read_mostly;
46int panic_timeout = CONFIG_PANIC_TIMEOUT; 46int panic_timeout = CONFIG_PANIC_TIMEOUT;
47EXPORT_SYMBOL_GPL(panic_timeout); 47EXPORT_SYMBOL_GPL(panic_timeout);
48 48
49#define PANIC_PRINT_TASK_INFO 0x00000001
50#define PANIC_PRINT_MEM_INFO 0x00000002
51#define PANIC_PRINT_TIMER_INFO 0x00000004
52#define PANIC_PRINT_LOCK_INFO 0x00000008
53#define PANIC_PRINT_FTRACE_INFO 0x00000010
54static unsigned long panic_print;
55
49ATOMIC_NOTIFIER_HEAD(panic_notifier_list); 56ATOMIC_NOTIFIER_HEAD(panic_notifier_list);
50 57
51EXPORT_SYMBOL(panic_notifier_list); 58EXPORT_SYMBOL(panic_notifier_list);
@@ -125,6 +132,24 @@ void nmi_panic(struct pt_regs *regs, const char *msg)
125} 132}
126EXPORT_SYMBOL(nmi_panic); 133EXPORT_SYMBOL(nmi_panic);
127 134
135static void panic_print_sys_info(void)
136{
137 if (panic_print & PANIC_PRINT_TASK_INFO)
138 show_state();
139
140 if (panic_print & PANIC_PRINT_MEM_INFO)
141 show_mem(0, NULL);
142
143 if (panic_print & PANIC_PRINT_TIMER_INFO)
144 sysrq_timer_list_show();
145
146 if (panic_print & PANIC_PRINT_LOCK_INFO)
147 debug_show_all_locks();
148
149 if (panic_print & PANIC_PRINT_FTRACE_INFO)
150 ftrace_dump(DUMP_ALL);
151}
152
128/** 153/**
129 * panic - halt the system 154 * panic - halt the system
130 * @fmt: The text string to print 155 * @fmt: The text string to print
@@ -254,6 +279,8 @@ void panic(const char *fmt, ...)
254 debug_locks_off(); 279 debug_locks_off();
255 console_flush_on_panic(); 280 console_flush_on_panic();
256 281
282 panic_print_sys_info();
283
257 if (!panic_blink) 284 if (!panic_blink)
258 panic_blink = no_blink; 285 panic_blink = no_blink;
259 286
@@ -658,6 +685,7 @@ void refcount_error_report(struct pt_regs *regs, const char *err)
658#endif 685#endif
659 686
660core_param(panic, panic_timeout, int, 0644); 687core_param(panic, panic_timeout, int, 0644);
688core_param(panic_print, panic_print, ulong, 0644);
661core_param(pause_on_oops, pause_on_oops, int, 0644); 689core_param(pause_on_oops, pause_on_oops, int, 0644);
662core_param(panic_on_warn, panic_on_warn, int, 0644); 690core_param(panic_on_warn, panic_on_warn, int, 0644);
663core_param(crash_kexec_post_notifiers, crash_kexec_post_notifiers, bool, 0644); 691core_param(crash_kexec_post_notifiers, crash_kexec_post_notifiers, bool, 0644);