diff mbox series

kernel/panic: Show the stacktrace after additional notifier messages

Message ID 20180903131745.30593-1-chris@chris-wilson.co.uk (mailing list archive)
State New, archived
Headers show
Series kernel/panic: Show the stacktrace after additional notifier messages | expand

Commit Message

Chris Wilson Sept. 3, 2018, 1:17 p.m. UTC
Most systems keep the last messages from the panic, and we value the
stacktrace most, so dump it last in order to preserve it for
post-mortems.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
---
 kernel/panic.c | 15 ++++++++-------
 1 file changed, 8 insertions(+), 7 deletions(-)

Comments

Martin Peres Sept. 4, 2018, 8:55 a.m. UTC | #1
On 03/09/2018 16:17, Chris Wilson wrote:
> Most systems keep the last messages from the panic, and we value the
> stacktrace most, so dump it last in order to preserve it for
> post-mortems.

Thanks a lot for doing this Chris! I am hopping we'll get a lot of
usable traces out of that!

Acked-by: Martin Peres <martin.peres@linux.intel.com>
> 
> Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
> ---
>  kernel/panic.c | 15 ++++++++-------
>  1 file changed, 8 insertions(+), 7 deletions(-)
> 
> diff --git a/kernel/panic.c b/kernel/panic.c
> index 8b2e002d52eb..c0334516cb15 100644
> --- a/kernel/panic.c
> +++ b/kernel/panic.c
> @@ -176,13 +176,6 @@ void panic(const char *fmt, ...)
>  	vsnprintf(buf, sizeof(buf), fmt, args);
>  	va_end(args);
>  	pr_emerg("Kernel panic - not syncing: %s\n", buf);
> -#ifdef CONFIG_DEBUG_BUGVERBOSE
> -	/*
> -	 * Avoid nested stack-dumping if a panic occurs during oops processing
> -	 */
> -	if (!test_taint(TAINT_DIE) && oops_in_progress <= 1)
> -		dump_stack();
> -#endif
>  
>  	/*
>  	 * If we have crashed and we have a crash kernel loaded let it handle
> @@ -217,6 +210,14 @@ void panic(const char *fmt, ...)
>  	 */
>  	atomic_notifier_call_chain(&panic_notifier_list, 0, buf);
>  
> +#ifdef CONFIG_DEBUG_BUGVERBOSE
> +	/*
> +	 * Avoid nested stack-dumping if a panic occurs during oops processing
> +	 */
> +	if (!test_taint(TAINT_DIE) && oops_in_progress <= 1)
> +		dump_stack();
> +#endif
> +
>  	/* Call flush even twice. It tries harder with a single online CPU */
>  	printk_safe_flush_on_panic();
>  	kmsg_dump(KMSG_DUMP_PANIC);
>
Chris Wilson Sept. 4, 2018, 8:58 a.m. UTC | #2
Quoting Martin Peres (2018-09-04 09:55:38)
> On 03/09/2018 16:17, Chris Wilson wrote:
> > Most systems keep the last messages from the panic, and we value the
> > stacktrace most, so dump it last in order to preserve it for
> > post-mortems.
> 
> Thanks a lot for doing this Chris! I am hopping we'll get a lot of
> usable traces out of that!
> 
> Acked-by: Martin Peres <martin.peres@linux.intel.com>

Let's see if it does the trick, and when Martin spots it in core-for-CI
next year, he can poke someone (hopefully someone else) to send it
upstream ;)
-Chris
diff mbox series

Patch

diff --git a/kernel/panic.c b/kernel/panic.c
index 8b2e002d52eb..c0334516cb15 100644
--- a/kernel/panic.c
+++ b/kernel/panic.c
@@ -176,13 +176,6 @@  void panic(const char *fmt, ...)
 	vsnprintf(buf, sizeof(buf), fmt, args);
 	va_end(args);
 	pr_emerg("Kernel panic - not syncing: %s\n", buf);
-#ifdef CONFIG_DEBUG_BUGVERBOSE
-	/*
-	 * Avoid nested stack-dumping if a panic occurs during oops processing
-	 */
-	if (!test_taint(TAINT_DIE) && oops_in_progress <= 1)
-		dump_stack();
-#endif
 
 	/*
 	 * If we have crashed and we have a crash kernel loaded let it handle
@@ -217,6 +210,14 @@  void panic(const char *fmt, ...)
 	 */
 	atomic_notifier_call_chain(&panic_notifier_list, 0, buf);
 
+#ifdef CONFIG_DEBUG_BUGVERBOSE
+	/*
+	 * Avoid nested stack-dumping if a panic occurs during oops processing
+	 */
+	if (!test_taint(TAINT_DIE) && oops_in_progress <= 1)
+		dump_stack();
+#endif
+
 	/* Call flush even twice. It tries harder with a single online CPU */
 	printk_safe_flush_on_panic();
 	kmsg_dump(KMSG_DUMP_PANIC);