Received: by 2002:a05:7412:8d10:b0:f3:1519:9f41 with SMTP id bj16csp6285907rdb; Thu, 14 Dec 2023 13:46:07 -0800 (PST) X-Google-Smtp-Source: AGHT+IGBc+pgOky9Px57cRZUdqDhMUTpq15mblfOA03PNLvyR4f2CV3cMxyGBt16lgVvldE5ieEx X-Received: by 2002:a17:902:728e:b0:1d0:6ffd:836d with SMTP id d14-20020a170902728e00b001d06ffd836dmr4504573pll.120.1702590367648; Thu, 14 Dec 2023 13:46:07 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702590367; cv=none; d=google.com; s=arc-20160816; b=shXBRESpHZfHCjx6E5JuRBHNH/+cvXvRx+/+5qLJ4Y1mxxVuJwE3dQFHoXS8V/ctrU ZyTQIbqPa++jhemDq/SnSIiycJgKDTE0oPLjSxS0lvSHWpZR2UYWZaL49jmYlUlyBbA0 bAKzwtVU5jn8yApsANnq10lk3vYDmFZ6BZAlqZqwsqOncTUPmctuwhER9DDGV0JwSYAR T4kAo5IRJDOHIL+jeCv1K7inSYGy/sTNfUyMscukxd7VTxF4B2W83UWg/BjDvtZwmM4a KcPWQtZFaDW5K2KsY5Vqzs/lAvBgjen7bMlYpZA3PwhDxCS22JWKH5ZInjg0hPINS3Tg WQ5w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:dkim-signature:dkim-signature:from; bh=/oXCn644qxpD8FMpAqd87EWn4tyrdJdGrCu1+KrDVIM=; fh=Gi0dtl/7o9EpcVKFFrvrPRAxiUFnjabrs+V2y8yL/Ok=; b=UIoMaZkA143QJTIKsf8muUls1SUKcuZ7SDCPZZzxyAVZiK4T19lEal8U2g2KIhsLH4 mbOXUKC66sZHIHpIakLCCBhHSDdm0l5TOMog5KOO0fSk9xQba5MH5nCizY9uRX1B89an 4omFqNf1NIyXHcK6/A6POpwrhrnNp/IaE2qbUPIQQyAaOLQv6uC0+bRCgrq7vgjVhDeq Q1VbtYv9hQLQrOA1L1faobDNnmWipqSoFeO7kMWiS6qDYMJFoeUCO7/nyxiOS3VjkiT2 tPBlR2yJT4WaAHX236NGA7/4RDvWcssTHud75DyApHTW1zT0ceKyujUaCOmjAquiT8sX VJiQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=yErQmSVa; dkim=neutral (no key) header.i=@linutronix.de header.b=dDrnk0pC; spf=pass (google.com: domain of linux-kernel+bounces-157-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-157-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id q6-20020a170902bd8600b001d34dd65eeasi3557280pls.528.2023.12.14.13.46.07 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Dec 2023 13:46:07 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-157-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=yErQmSVa; dkim=neutral (no key) header.i=@linutronix.de header.b=dDrnk0pC; spf=pass (google.com: domain of linux-kernel+bounces-157-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-157-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id 115F5B21DA2 for ; Thu, 14 Dec 2023 21:44:30 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id E96BD7948E; Thu, 14 Dec 2023 21:42:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="yErQmSVa"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="dDrnk0pC" X-Original-To: linux-kernel@vger.kernel.org Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) (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 C54866E58B for ; Thu, 14 Dec 2023 21:42:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linutronix.de From: John Ogness DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1702590129; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=/oXCn644qxpD8FMpAqd87EWn4tyrdJdGrCu1+KrDVIM=; b=yErQmSVaMfHU6Ut0SEf2M9UrFhXD9j0kjQV3rjWR+rqsZaRuPnqIGH+/+FYhiB7Htqqb29 yxaTR7aEz/PPEAxvz2mSUJvMHkZGYz8RpgI4rAcnaUowr3ErKV0ABZpqnGVn7dz6R7zShG fqGLTasMEoAFZm7wtYSBs+AFqqs3nSn1KR8FnPxDNIY+vNTVBoMEFc1R5swNBo7n6TrQa1 MV86Wenak/8A6p4+FLFqBC8T3JbzuLCYF1MjRQDb0Z/zk8QBH3vkCOm3Ak7C+Q2M4kK9hj 6AYcNCsjG+jnCZ9RzJBFI5+EhKjf2YMkl3Gdf6N5KBS9d+HS8zrSZZ2FjXk0WA== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1702590129; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=/oXCn644qxpD8FMpAqd87EWn4tyrdJdGrCu1+KrDVIM=; b=dDrnk0pCjG5yxf/tj6SXs8Ji2aYRRfbnhY4f4NyzYMRs3Z1mUilD+Qi2DKWl2C+h99oUHp Y9t649zENTvgbxBQ== To: Petr Mladek Cc: Sergey Senozhatsky , Steven Rostedt , Thomas Gleixner , linux-kernel@vger.kernel.org, Andrew Morton , Peter Zijlstra , Josh Poimboeuf , Ingo Molnar , "Guilherme G. Piccoli" , Kefeng Wang , Kees Cook , Uros Bizjak , Arnd Bergmann Subject: [PATCH printk v3 14/14] panic: Flush kernel log buffer at the end Date: Thu, 14 Dec 2023 22:48:01 +0106 Message-Id: <20231214214201.499426-15-john.ogness@linutronix.de> In-Reply-To: <20231214214201.499426-1-john.ogness@linutronix.de> References: <20231214214201.499426-1-john.ogness@linutronix.de> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit If the kernel crashes in a context where printk() calls always defer printing (such as in NMI or inside a printk_safe section) then the final panic messages will be deferred to irq_work. But if irq_work is not available, the messages will not get printed unless explicitly flushed. The result is that the final "end Kernel panic" banner does not get printed. Add one final flush after the last printk() call to make sure the final panic messages make it out as well. Signed-off-by: John Ogness --- kernel/panic.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/kernel/panic.c b/kernel/panic.c index 2807639aab51..f22d8f33ea14 100644 --- a/kernel/panic.c +++ b/kernel/panic.c @@ -446,6 +446,14 @@ void panic(const char *fmt, ...) /* Do not scroll important messages printed above */ suppress_printk = 1; + + /* + * The final messages may not have been printed if in a context that + * defers printing (such as NMI) and irq_work is not available. + * Explicitly flush the kernel log buffer one last time. + */ + console_flush_on_panic(CONSOLE_FLUSH_PENDING); + local_irq_enable(); for (i = 0; ; i += PANIC_TIMER_STEP) { touch_softlockup_watchdog(); -- 2.39.2