From nobody Sat Jul 25 00:41:52 2026 Received: from devianza.investici.org (devianza.investici.org [198.167.222.108]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 25FB74D9914; Tue, 21 Jul 2026 15:14:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.167.222.108 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784646854; cv=none; b=VWFdANZv8YAmT4GL9FPsxFRnJRehbymkLI4v6cRuaI6OmzYOh6+XHj0Ck3j2oBwy6xzR5RsN5mPUZ3So06ntP258tSZ314Pt6QKXFcYISjBiFxbR2qiziayF+/zl0oW/ysgYHVihApR9YpdaWQtyfWqy7ACtt1nDABpDTeVRe4c= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784646854; c=relaxed/simple; bh=StdNA1WERZBz3R832dxnd3DmnecPu8RaIVeJcTN9nJM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=D4uYCFbxKSHl7romuzDbngUt4LRf3v6oX1Mk4bhhl9EQnMbTfLWMxdDee52YGiXFE1U8R82pn+Kw76JP8CAYrJf3RA0ho4dxt5nfTcpEBevS+Qvn3XL0BtFIN3OGVLXyIQg0KJlZQpLXF1AHoXO55qz6O8EQlvAeqmVjnejFieY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=grrlz.net; spf=pass smtp.mailfrom=grrlz.net; dkim=pass (1024-bit key) header.d=grrlz.net header.i=@grrlz.net header.b=UFNLM+vu; arc=none smtp.client-ip=198.167.222.108 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=grrlz.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=grrlz.net Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=grrlz.net header.i=@grrlz.net header.b="UFNLM+vu" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=grrlz.net; s=stigmate; t=1784646849; bh=pbKDGyNNyhDV1H5PR4A8c50OlkFbCH78KDfnPB0VA6w=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=UFNLM+vumosCC9EyEK+PQKYA3EUr1upq2TWPePwN5KH/nfU+TDJjZKakbxvqim6Tr ogeSAoqUrtIBnKZCBVDsjE6iOIopbbttQjh89NqivAhDIAMBTS6UAuTYgvL6+vOncf TQZ7MZ6puX+XljlXxojFfCmlbxHpsua38BRpNvwY= Received: from mx2.investici.org (unknown [127.0.0.1]) by devianza.investici.org (Postfix) with ESMTP id 4h4LWj3LXyz6vNZ; Tue, 21 Jul 2026 15:14:09 +0000 (UTC) Received: by mx2.investici.org (Postfix) id 4h4LWh4sK6z4vyJ; Tue, 21 Jul 2026 15:14:08 +0000 (UTC) From: Bradley Morgan To: akpm@linux-foundation.org Cc: baoquan.he@linux.dev, rppt@kernel.org, pasha.tatashin@soleen.com, pratyush@kernel.org, rafael@kernel.org, lenb@kernel.org, pavel@kernel.org, kees@kernel.org, tony.luck@intel.com, gpiccoli@igalia.com, linux-kernel@vger.kernel.org, kexec@lists.infradead.org, linux-pm@vger.kernel.org, Bradley Morgan Subject: [PATCH v2 1/3] reboot: log the task that initiated the reboot Date: Tue, 21 Jul 2026 16:13:56 +0100 Message-ID: <20260721151358.4185467-2-include@grrlz.net> X-Mailer: git-send-email 2.50.1 In-Reply-To: <20260721151358.4185467-1-include@grrlz.net> References: <20260721151358.4185467-1-include@grrlz.net> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" When a machine reboots or powers off, the kernel log records what happened but not who asked for it. The reboot syscall throws the caller identity away, and userspace does not reliably record it either: systemd only journals shutdowns that go through logind, anything calling reboot(2) directly (watchdog daemons, container agents, orchestration tooling) leaves no record at all, and the journal is being torn down while the machine goes away, so even the lines that should be written can be lost. The kernel is the only place that always sees the caller, and a kernel log line survives via pstore or a serial console when userspace logs do not. Log the comm and pid of the calling task in the reboot syscall, once the requested command is committed and can no longer fail, e.g: reboot: initiated by systemd-shutdow[1] reboot: Restarting system The existing "Restarting system", "System halted" and "Power down" lines are left untouched, so anything parsing dmesg today keeps working. The two ctrl alt del toggle commands are excluded so init setting the mode does not add a line to dmesg on every boot. Signed-off-by: Bradley Morgan --- include/linux/reboot.h | 1 + kernel/reboot.c | 16 ++++++++++++++++ 2 files changed, 17 insertions(+) diff --git a/include/linux/reboot.h b/include/linux/reboot.h index aa08c3bbbf59..3fb8d8533563 100644 --- a/include/linux/reboot.h +++ b/include/linux/reboot.h @@ -172,6 +172,7 @@ extern void kernel_restart(char *cmd); extern void kernel_halt(void); extern void kernel_power_off(void); extern bool kernel_can_power_off(void); +void reboot_log_initiator(void); =20 void ctrl_alt_del(void); =20 diff --git a/kernel/reboot.c b/kernel/reboot.c index bed6967bfa96..3f4534cd5b9c 100644 --- a/kernel/reboot.c +++ b/kernel/reboot.c @@ -717,6 +717,18 @@ EXPORT_SYMBOL_GPL(kernel_power_off); =20 DEFINE_MUTEX(system_transition_mutex); =20 +/* + * Log the task that asked for the transition once the requested + * command is committed and can no longer fail, e.g: + * + * reboot: initiated by systemd-shutdow[1] + * reboot: Restarting system + */ +void reboot_log_initiator(void) +{ + pr_info("initiated by %s[%d]\n", current->comm, task_pid_nr(current)); +} + /* * Reboot system call: for obvious reasons only root may call it, * and even root needs to set up some magic numbers in the registers @@ -764,6 +776,7 @@ SYSCALL_DEFINE4(reboot, int, magic1, int, magic2, unsig= ned int, cmd, mutex_lock(&system_transition_mutex); switch (cmd) { case LINUX_REBOOT_CMD_RESTART: + reboot_log_initiator(); kernel_restart(NULL); break; =20 @@ -776,10 +789,12 @@ SYSCALL_DEFINE4(reboot, int, magic1, int, magic2, uns= igned int, cmd, break; =20 case LINUX_REBOOT_CMD_HALT: + reboot_log_initiator(); kernel_halt(); do_exit(0); =20 case LINUX_REBOOT_CMD_POWER_OFF: + reboot_log_initiator(); kernel_power_off(); do_exit(0); break; @@ -792,6 +807,7 @@ SYSCALL_DEFINE4(reboot, int, magic1, int, magic2, unsig= ned int, cmd, } buffer[sizeof(buffer) - 1] =3D '\0'; =20 + reboot_log_initiator(); kernel_restart(buffer); break; =20 --=20 2.50.1 From nobody Sat Jul 25 00:41:52 2026 Received: from devianza.investici.org (devianza.investici.org [198.167.222.108]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 259654D90D8; Tue, 21 Jul 2026 15:14:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.167.222.108 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784646853; cv=none; b=nEErsW0s6DAvLVZxyEAGkZKHjMlOZbFfHSeCwGdq5Y/CWrnoMVYFSGckQ7WK1wkTODt4xmGS/e+dtYtiYMMnQOqAcFuLCRo0RyzcRmt0iAenx4clqJhem3MLmX/YITPS5/X7iaJAUheGAOxAao4IZUxJbsiqDpyDXuuF0JtEAp8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784646853; c=relaxed/simple; bh=pOlYpHB8qYB+i/+0XBWMQ6pRO1+uN4s1NK8suJ7kkfo=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=u+4VNTbPDGnv2TdNIfG0iZbkSkLAsJeOdpEOGR1snHQn/5FKQLIsJ8Pbe3cuGevkxfrhzUcIlv8WQSl4lKYcXC2gC7cPpjqhjQDOdpUcpoBn+6Vt8TOLeVoDDY7fU1ytDPSzfImcOFSfeSlA5XXYzMCBBojDRRTNXQV5QLLYaCQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=grrlz.net; spf=pass smtp.mailfrom=grrlz.net; dkim=pass (1024-bit key) header.d=grrlz.net header.i=@grrlz.net header.b=dAGopWRe; arc=none smtp.client-ip=198.167.222.108 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=grrlz.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=grrlz.net Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=grrlz.net header.i=@grrlz.net header.b="dAGopWRe" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=grrlz.net; s=stigmate; t=1784646850; bh=VNv2SZK5IuT20jKf63eyex2nA1u4B3QwivjV7yjy8NI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=dAGopWReZa5yseDbcQ6xaoOpr2kMsGb0yk+jAEqeqe79kRaCkJTozEWK6tQriLaBd IEwhIS9Cs7cVVlBwlBGqQNQGsFwUzKmroAL54ec19pFxl6GSjXNuBwQDr6sG+LQPzK bBSUmDy8TOq6JDKg7edd5udo2qT7arwnzF26ChVc= Received: from mx2.investici.org (unknown [127.0.0.1]) by devianza.investici.org (Postfix) with ESMTP id 4h4LWk2JWGz6vN3; Tue, 21 Jul 2026 15:14:10 +0000 (UTC) Received: by mx2.investici.org (Postfix) id 4h4LWj3r69z4vyJ; Tue, 21 Jul 2026 15:14:09 +0000 (UTC) From: Bradley Morgan To: akpm@linux-foundation.org Cc: baoquan.he@linux.dev, rppt@kernel.org, pasha.tatashin@soleen.com, pratyush@kernel.org, rafael@kernel.org, lenb@kernel.org, pavel@kernel.org, kees@kernel.org, tony.luck@intel.com, gpiccoli@igalia.com, linux-kernel@vger.kernel.org, kexec@lists.infradead.org, linux-pm@vger.kernel.org, Bradley Morgan Subject: [PATCH v2 2/3] kexec: log the task that initiated the kexec reboot Date: Tue, 21 Jul 2026 16:13:57 +0100 Message-ID: <20260721151358.4185467-3-include@grrlz.net> X-Mailer: git-send-email 2.50.1 In-Reply-To: <20260721151358.4185467-1-include@grrlz.net> References: <20260721151358.4185467-1-include@grrlz.net> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" 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 --- 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(); } --=20 2.50.1 From nobody Sat Jul 25 00:41:52 2026 Received: from devianza.investici.org (devianza.investici.org [198.167.222.108]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A556B3793C3; Tue, 21 Jul 2026 15:14:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.167.222.108 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784646853; cv=none; b=fM9KmFaEHPfykyBmewdYmjBO76g+oRlm0/QIzbniIwgVAJJefEiO40/tk1JUbPygP/AnalM431lYlzy1Uf8fJQRl5O9FWiOmPhm1kRx3icwggMg4Afh2d9PL7MPFSnd3umhsIWtk8VPXHyiQEVPhMEh9HJD4f5q5Ye3x6Ved2Qw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784646853; c=relaxed/simple; bh=1tlW2FzhayOoRkA/k5MGV941viuVyl7EM+PuDyXQKDs=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=VU1mEtSOpVb/yj1NTBf/Eq0kVfYudsOC3Ui+1iOXJl09TNf3/6ep4bRrkFwspV3GPoCXHF4kfVE73I68xsFryeGOUdwZ6a5F2XxqRVHPL0DOJXctMaVQbCr6kFwHuevig/Iac7Om4AX9NUBqpPJsTF1u3wRImJ6RQl5TAIOcn5U= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=grrlz.net; spf=pass smtp.mailfrom=grrlz.net; dkim=pass (1024-bit key) header.d=grrlz.net header.i=@grrlz.net header.b=pwq7Ef46; arc=none smtp.client-ip=198.167.222.108 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=grrlz.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=grrlz.net Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=grrlz.net header.i=@grrlz.net header.b="pwq7Ef46" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=grrlz.net; s=stigmate; t=1784646851; bh=1TnWlVinJDeOhala/vbIeVYCGUm59YDKqzBVCOS9jWE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=pwq7Ef46XWcW85AVc4Id1OZ84DWSL6smZgO4II9+fpMcNuh5e9mfet3Rxc1FYyyo9 nQ5LiP3/dlxpRm8vw7jFcNgO+Hm6PpqRbEg+p5IlSMGdCiSKGrMturwHkp4a/lp2RM 3HYstfKUxL1oomd0i0sVrmXpzBfnGcR5NMsRvMcc= Received: from mx2.investici.org (unknown [127.0.0.1]) by devianza.investici.org (Postfix) with ESMTP id 4h4LWl18Tbz6vP7; Tue, 21 Jul 2026 15:14:11 +0000 (UTC) Received: by mx2.investici.org (Postfix) id 4h4LWk2rKwz4vyJ; Tue, 21 Jul 2026 15:14:10 +0000 (UTC) From: Bradley Morgan To: akpm@linux-foundation.org Cc: baoquan.he@linux.dev, rppt@kernel.org, pasha.tatashin@soleen.com, pratyush@kernel.org, rafael@kernel.org, lenb@kernel.org, pavel@kernel.org, kees@kernel.org, tony.luck@intel.com, gpiccoli@igalia.com, linux-kernel@vger.kernel.org, kexec@lists.infradead.org, linux-pm@vger.kernel.org, Bradley Morgan Subject: [PATCH v2 3/3] PM: hibernate: log the task that initiated the power down Date: Tue, 21 Jul 2026 16:13:58 +0100 Message-ID: <20260721151358.4185467-4-include@grrlz.net> X-Mailer: git-send-email 2.50.1 In-Reply-To: <20260721151358.4185467-1-include@grrlz.net> References: <20260721151358.4185467-1-include@grrlz.net> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Give the hibernation power down the same treatment as the reboot syscall commands. hibernate() runs in the context of the task that asked for it, whether through the reboot syscall or a write to /sys/power/disk, so when power_down() runs current is still the initiating task. Log it once the image has been written and the machine is committed to going down: reboot: initiated by systemd-sleep[812] reboot: Power down The line comes from kernel/reboot.c so it keeps the "reboot:" prefix and sits right next to the final "Restarting system", "Power down" or "System halted" line, same as a plain reboot. The one exception is platform mode rolling back on a pending wakeup event after the line has been printed. The existing "Wakeup event detected during hibernation, rolling back." line follows immediately in that case, so the log stays real about what happened. Signed-off-by: Bradley Morgan --- kernel/power/hibernate.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/kernel/power/hibernate.c b/kernel/power/hibernate.c index d2479c69d71a..bec91bf6a63c 100644 --- a/kernel/power/hibernate.c +++ b/kernel/power/hibernate.c @@ -687,6 +687,8 @@ static void power_down(void) } #endif =20 + reboot_log_initiator(); + switch (hibernation_mode) { case HIBERNATION_REBOOT: kernel_restart(NULL); --=20 2.50.1