linux-doc.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "qiwu.chen" <qiwuchen55@gmail.com>
To: corbet@lwn.net, oleg@redhat.com, mhocko@suse.com,
	jani.nikula@intel.com, akpm@linux-foundation.org,
	brauner@kernel.org, paulmck@kernel.org
Cc: linux-doc@vger.kernel.org, "qiwu.chen" <qiwu.chen@transsion.com>
Subject: [PATCH v3 2/2] exit: dump current pt_regs info on global init exit
Date: Sun, 22 Sep 2024 17:55:04 +0800	[thread overview]
Message-ID: <20240922095504.7182-2-qiwu.chen@transsion.com> (raw)
In-Reply-To: <20240922095504.7182-1-qiwu.chen@transsion.com>

Currently, it's hard to debug panic issues caused by kill init,
since there is no debug info from user mode in current panic msg
such as the user_regs and maps info.

This patch dumps current pt_regs info on global init exit for debugging.

Signed-off-by: qiwu.chen <qiwu.chen@transsion.com>
---
 kernel/exit.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/kernel/exit.c b/kernel/exit.c
index 0d62a53605df..3d5aa88ba517 100644
--- a/kernel/exit.c
+++ b/kernel/exit.c
@@ -11,6 +11,7 @@
 #include <linux/sched/mm.h>
 #include <linux/sched/stat.h>
 #include <linux/sched/task.h>
+#include <linux/sched/debug.h>
 #include <linux/sched/task_stack.h>
 #include <linux/sched/cputime.h>
 #include <linux/interrupt.h>
@@ -847,10 +848,12 @@ void __noreturn do_exit(long code)
 		 * If the last thread of global init has exited, panic
 		 * immediately to get a useable coredump.
 		 */
-		if (unlikely(is_global_init(tsk)))
+		if (unlikely(is_global_init(tsk))) {
+			/* dump the pt_regs of current thread for debugging. */
+			show_regs(task_pt_regs(tsk));
 			panic("Attempted to kill init! exitcode=0x%08x\n",
 				tsk->signal->group_exit_code ?: (int)code);
-
+		}
 #ifdef CONFIG_POSIX_TIMERS
 		hrtimer_cancel(&tsk->signal->real_timer);
 		exit_itimers(tsk);
-- 
2.25.1


  reply	other threads:[~2024-09-22  9:55 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-09-22  9:55 [PATCH v3 1/2] panic: add option to dump task maps info in panic_print qiwu.chen
2024-09-22  9:55 ` qiwu.chen [this message]
2024-09-22 12:54   ` [PATCH v3 2/2] exit: dump current pt_regs info on global init exit Oleg Nesterov
2024-09-23  5:11     ` chenqiwu
2024-09-22 13:12 ` [PATCH v3 1/2] panic: add option to dump task maps info in panic_print Oleg Nesterov
2024-09-23  4:08   ` chenqiwu
2024-09-22 13:13 ` Oleg Nesterov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240922095504.7182-2-qiwu.chen@transsion.com \
    --to=qiwuchen55@gmail.com \
    --cc=akpm@linux-foundation.org \
    --cc=brauner@kernel.org \
    --cc=corbet@lwn.net \
    --cc=jani.nikula@intel.com \
    --cc=linux-doc@vger.kernel.org \
    --cc=mhocko@suse.com \
    --cc=oleg@redhat.com \
    --cc=paulmck@kernel.org \
    --cc=qiwu.chen@transsion.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).