From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from confino.investici.org (confino.investici.org [93.190.126.19]) (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 5A5C1369980 for ; Sun, 19 Jul 2026 15:36:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=93.190.126.19 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784475418; cv=none; b=RREqB2aDdJjK+4MK9TdvD5OSQicFEgkc9ns89uJ4clscbusYtdSjNCd3cQDmngJSh30AXvqHo6kD34ceZbPxOYLttJz6pjOyEcss/LcgEZb0yuW4BS3U5slLWp7YyBTy536OmqugS0gKukls7LOiF3WkX9crhVMoGmi451HPNNI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784475418; c=relaxed/simple; bh=FKuakDEl/3a+ZRuwbAUucX7WrdsbGg+O1KxqR7/gpfo=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=ictBdLGiPFF2/NLo7oLAOsml+IXicu6ahwSLSfqTouoKpKAvXNQfbF13PWgrO08JkS+iytU3MYBKHR4orKFOXnYuUhUSAzWtnpmeExoAyt732HIPWjoubkOV8eSArj25SaMDwNGxWeSiODmHvVxqsG1s4rT322me6cHZNDuDj5Q= 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=Gu4B5ury; arc=none smtp.client-ip=93.190.126.19 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="Gu4B5ury" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=grrlz.net; s=stigmate; t=1784474952; bh=/RT0ZgMqMOIkKhMJHRn2kuHuj3VzWukPoP64tmiyVl0=; h=From:To:Cc:Subject:Date:From; b=Gu4B5uryYMDD+xuynz0ExMr89RfbG+j/1FCBPM90l9WybLRd+8WCowobUWIAiJbv/ NBVGtn7gskXu7XXYlX3W50ZucBlOtdoD/4a15knSUfBn9orapK2jste9jMw6yhRvoE eamyCxV74F0FAc/QVMtaGdVunJk4xcYaKYwgh1D0= Received: from mx1.investici.org (unknown [127.0.0.1]) by confino.investici.org (Postfix) with ESMTP id 4h36y025cWz10xx; Sun, 19 Jul 2026 15:29:12 +0000 (UTC) Received: by mx1.investici.org (Postfix) id 4h36xz6ccdz10xW; Sun, 19 Jul 2026 15:29:11 +0000 (UTC) From: Bradley Morgan To: akpm@linux-foundation.org Cc: linux-kernel@vger.kernel.org, Bradley Morgan Subject: [PATCH] reboot: log the task that requested a reboot or shutdown Date: Sun, 19 Jul 2026 15:29:09 +0000 Message-ID: <20260719152909.3133-1-include@grrlz.net> X-Mailer: git-send-email 2.53.0 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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 reconstructing it afterwards from userspace logs is unreliable and more likely than not impossible. "What made this reboot?" is a question every fleet operator has had to answer with guesswork. log the comm and pid of the calling task once at the syscall boundary, before the requested command is carried out, 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 --- kernel/reboot.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/kernel/reboot.c b/kernel/reboot.c index c10ac6a0200d..8ac96c527a4e 100644 --- a/kernel/reboot.c +++ b/kernel/reboot.c @@ -754,6 +754,10 @@ SYSCALL_DEFINE4(reboot, int, magic1, int, magic2, unsigned int, cmd, if (ret) return ret; + if (cmd != LINUX_REBOOT_CMD_CAD_ON && cmd != LINUX_REBOOT_CMD_CAD_OFF) + pr_info("initiated by %s[%d]\n", + current->comm, task_pid_nr(current)); + /* Instead of trying to make the power_off code look like * halt when pm_power_off is not set do it the easy way. */ -- 2.53.0