* [RFC PATCH] panic: Add options to dump system info when panic happens
@ 2018-11-22 7:10 Feng Tang
2018-11-26 23:24 ` Andrew Morton
0 siblings, 1 reply; 3+ messages in thread
From: Feng Tang @ 2018-11-22 7:10 UTC (permalink / raw)
To: Andrew Morton, linux-kernel
Cc: Kees Cook, Feng Tang, Thomas Gleixner, John Stultz, Ingo Molnar,
Peter Zijlstra
Kernel panic issues are always painful to debug, partially
because of 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 a easier way to show the system info by adding a
cmdline parameter, referring some idea from sysrq handler.
Signed-off-by: Feng Tang <feng.tang@intel.com>
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>
---
This patch is frequently used by us when debugging panic and system
stability bugs, and does help much. And the options could be expanded
more to cover other info like the ftrace, signal etc.
Documentation/admin-guide/kernel-parameters.txt | 7 +++++++
kernel/panic.c | 26 +++++++++++++++++++++++++
2 files changed, 33 insertions(+)
diff --git a/Documentation/admin-guide/kernel-parameters.txt b/Documentation/admin-guide/kernel-parameters.txt
index 81d1d5a..8d349a8 100644
--- a/Documentation/admin-guide/kernel-parameters.txt
+++ b/Documentation/admin-guide/kernel-parameters.txt
@@ -3081,6 +3081,13 @@
timeout < 0: reboot immediately
Format: <timeout>
+ panic_dump= Bitmask for dumping system info when panic happens.
+ User can chose combination of the following bits:
+ bit 0: dump all tasks info
+ bit 1: dump system memory info
+ bit 2: dump timer info
+ bit 3: dump locks info if CONFIG_LOCKDEP is on
+
panic_on_warn panic() instead of WARN(). Useful to cause kdump
on a WARN().
diff --git a/kernel/panic.c b/kernel/panic.c
index f6d549a..8320d04 100644
--- a/kernel/panic.c
+++ b/kernel/panic.c
@@ -45,6 +45,12 @@ int panic_on_warn __read_mostly;
int panic_timeout = CONFIG_PANIC_TIMEOUT;
EXPORT_SYMBOL_GPL(panic_timeout);
+#define PANIC_DUMP_TASK_INFO 0x00000001
+#define PANIC_DUMP_MEM_INFO 0x00000002
+#define PANIC_DUMP_TIMER_INFO 0x00000004
+#define PANIC_DUMP_LOCK_INFO 0x00000008
+static unsigned long panic_dump;
+
ATOMIC_NOTIFIER_HEAD(panic_notifier_list);
EXPORT_SYMBOL(panic_notifier_list);
@@ -124,6 +130,23 @@ void nmi_panic(struct pt_regs *regs, const char *msg)
}
EXPORT_SYMBOL(nmi_panic);
+static void panic_dump_sys_info(void)
+{
+ if (panic_dump & PANIC_DUMP_TASK_INFO)
+ show_state();
+
+ if (panic_dump & PANIC_DUMP_MEM_INFO)
+ show_mem(0, NULL);
+
+ if (panic_dump & PANIC_DUMP_TIMER_INFO)
+ sysrq_timer_list_show();
+
+#ifdef COFNIG_LOCKDEP
+ if (panic_dump & PANIC_DUMP_LOCK_INFO)
+ debug_show_all_locks();
+#endif
+}
+
/**
* panic - halt the system
* @fmt: The text string to print
@@ -250,6 +273,8 @@ void panic(const char *fmt, ...)
debug_locks_off();
console_flush_on_panic();
+ panic_dump_sys_info();
+
if (!panic_blink)
panic_blink = no_blink;
@@ -654,6 +679,7 @@ void refcount_error_report(struct pt_regs *regs, const char *err)
#endif
core_param(panic, panic_timeout, int, 0644);
+core_param(panic_dump, panic_dump, 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);
--
2.7.4
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [RFC PATCH] panic: Add options to dump system info when panic happens
2018-11-22 7:10 [RFC PATCH] panic: Add options to dump system info when panic happens Feng Tang
@ 2018-11-26 23:24 ` Andrew Morton
2018-11-27 2:16 ` Feng Tang
0 siblings, 1 reply; 3+ messages in thread
From: Andrew Morton @ 2018-11-26 23:24 UTC (permalink / raw)
To: Feng Tang
Cc: linux-kernel, Kees Cook, Thomas Gleixner, John Stultz,
Ingo Molnar, Peter Zijlstra
On Thu, 22 Nov 2018 15:10:31 +0800 Feng Tang <feng.tang@intel.com> wrote:
> Kernel panic issues are always painful to debug, partially
> because of 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 a easier way to show the system info by adding a
> cmdline parameter, referring some idea from sysrq handler.
>
This seems sensible to me.
> This patch is frequently used by us when debugging panic and system
> stability bugs, and does help much. And the options could be expanded
> more to cover other info like the ftrace, signal etc.
And that info is valuable.
> --- a/Documentation/admin-guide/kernel-parameters.txt
> +++ b/Documentation/admin-guide/kernel-parameters.txt
> @@ -3081,6 +3081,13 @@
> timeout < 0: reboot immediately
> Format: <timeout>
>
> + panic_dump= Bitmask for dumping system info when panic happens.
> + User can chose combination of the following bits:
> + bit 0: dump all tasks info
> + bit 1: dump system memory info
> + bit 2: dump timer info
> + bit 3: dump locks info if CONFIG_LOCKDEP is on
> +
Using "dump" makes this feature sounds a bit like kdump, which is also
used in this code context.
I think I'd prefer that we use "print" - that's a more accurate
description and avoids such confusion. So s/dump/print/ and
s/DUMP/PRINT/ throughout the changelog and patch?
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [RFC PATCH] panic: Add options to dump system info when panic happens
2018-11-26 23:24 ` Andrew Morton
@ 2018-11-27 2:16 ` Feng Tang
0 siblings, 0 replies; 3+ messages in thread
From: Feng Tang @ 2018-11-27 2:16 UTC (permalink / raw)
To: Andrew Morton
Cc: linux-kernel, Kees Cook, Thomas Gleixner, John Stultz,
Ingo Molnar, Peter Zijlstra, feng.tang
Hi Andrew,
Thanks for the review.
On Mon, Nov 26, 2018 at 03:24:57PM -0800, Andrew Morton wrote:
> On Thu, 22 Nov 2018 15:10:31 +0800 Feng Tang <feng.tang@intel.com> wrote:
>
> > Kernel panic issues are always painful to debug, partially
> > because of 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 a easier way to show the system info by adding a
> > cmdline parameter, referring some idea from sysrq handler.
> >
>
> This seems sensible to me.
>
> > This patch is frequently used by us when debugging panic and system
> > stability bugs, and does help much. And the options could be expanded
> > more to cover other info like the ftrace, signal etc.
>
> And that info is valuable.
Will add these info in v2.
>
> > --- a/Documentation/admin-guide/kernel-parameters.txt
> > +++ b/Documentation/admin-guide/kernel-parameters.txt
> > @@ -3081,6 +3081,13 @@
> > timeout < 0: reboot immediately
> > Format: <timeout>
> >
> > + panic_dump= Bitmask for dumping system info when panic happens.
> > + User can chose combination of the following bits:
> > + bit 0: dump all tasks info
> > + bit 1: dump system memory info
> > + bit 2: dump timer info
> > + bit 3: dump locks info if CONFIG_LOCKDEP is on
> > +
>
> Using "dump" makes this feature sounds a bit like kdump, which is also
> used in this code context.
>
> I think I'd prefer that we use "print" - that's a more accurate
> description and avoids such confusion. So s/dump/print/ and
> s/DUMP/PRINT/ throughout the changelog and patch?
Thanks for the suggestion, will change it in v2.
- Feng
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2018-11-27 2:08 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-11-22 7:10 [RFC PATCH] panic: Add options to dump system info when panic happens Feng Tang
2018-11-26 23:24 ` Andrew Morton
2018-11-27 2:16 ` Feng Tang
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®