mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] kernel/reboot: enhance dmesg logging for system restart
@ 2024-06-07 10:59 Faiyaz Mohammed
  2024-06-07 14:05 ` 이동민
  0 siblings, 1 reply; 4+ messages in thread
From: Faiyaz Mohammed @ 2024-06-07 10:59 UTC (permalink / raw)
  To: benjamin.bara, dmitry.osipenko, lee, daniel.lezcano, ldmldm05,
	j.granados, quic_faiyazm, linux-kernel

It is useful to add the PID and Comm information along with command info.

Currently, when system reboot kernel logs don not print PID and Comm:

reboot: Restarting system with command 'reboot,scheduled_reboot'
reboot: Restarting system with command 'RescueParty'
reboot: Restarting system with command 'bootloader'
reboot: Restarting system with command 'recovery'
reboot: Restarting system with command 'userrequested,recovery’

For Example after adding PID and Comm:

reboot: PID: 1 Comm: init Restarting system with command 'shell'
reboot: PID: 1 Comm: init Restarting system with command 'bootloader'

Signed-off-by: Faiyaz Mohammed <quic_faiyazm@quicinc.com>
---
 kernel/reboot.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/kernel/reboot.c b/kernel/reboot.c
index f05dbde2c93f..91a4a1428eb9 100644
--- a/kernel/reboot.c
+++ b/kernel/reboot.c
@@ -274,14 +274,17 @@ static void do_kernel_restart_prepare(void)
  */
 void kernel_restart(char *cmd)
 {
+	char comm[sizeof(current->comm)];
+
+	get_task_comm(comm, current);
 	kernel_restart_prepare(cmd);
 	do_kernel_restart_prepare();
 	migrate_to_reboot_cpu();
 	syscore_shutdown();
 	if (!cmd)
-		pr_emerg("Restarting system\n");
+		pr_emerg("PID: %d Comm: %s Restarting system\n", current->pid, comm);
 	else
-		pr_emerg("Restarting system with command '%s'\n", cmd);
+		pr_emerg("PID: %d Comm: %s Restarting system with command '%s'\n", current->pid, comm, cmd);
 	kmsg_dump(KMSG_DUMP_SHUTDOWN);
 	machine_restart(cmd);
 }
-- 
2.25.1


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2024-06-23  8:38 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-06-07 10:59 [PATCH] kernel/reboot: enhance dmesg logging for system restart Faiyaz Mohammed
2024-06-07 14:05 ` 이동민
2024-06-19 11:09   ` Faiyaz Mohammed
2024-06-23  8:38     ` Dongmin Lee

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®