[PATCH v2 2/3] kexec: log the task that initiated the kexec reboot
From: Bradley Morgan
Date: Tue Jul 21 2026 - 11:15:12 EST
The reboot syscall now logs the initiating task for the restart, halt
and power off commands at the point where they can no longer fail.
The kexec command could not be handled there: kernel_kexec() has
several failure points and returns to a running system when any of
them fires, which would leave a stale "initiated by" line in the log
with no transition behind it.
Call reboot_log_initiator() from kernel_kexec() once the shutdown
of the current kernel is committed, right before the existing
"Starting new kernel" line:
reboot: initiated by kexec[713]
kexec_core: Starting new kernel
The preserve_context path is left alone since it returns to the
running kernel instead of tearing it down.
Signed-off-by: Bradley Morgan <include@xxxxxxxxx>
---
kernel/kexec_core.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/kernel/kexec_core.c b/kernel/kexec_core.c
index dc770b9a6d05..23b7fe36e64e 100644
--- a/kernel/kexec_core.c
+++ b/kernel/kexec_core.c
@@ -1200,6 +1200,7 @@ int kernel_kexec(void)
* CPU hotplug again; so re-enable it here.
*/
cpu_hotplug_enable();
+ reboot_log_initiator();
pr_notice("Starting new kernel\n");
machine_shutdown();
}
--
2.50.1