From patchwork Thu Dec 14 21:42:01 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Ogness X-Patchwork-Id: 178927 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:3b04:b0:fb:cd0c:d3e with SMTP id c4csp8872805dys; Thu, 14 Dec 2023 13:48:20 -0800 (PST) X-Google-Smtp-Source: AGHT+IE419asuCziA3BTUtBFX9mrSlTRpB3f7cxv0lBaBlwVM1aDMAtVcMZsA/aD2W/E9zZNeMJp X-Received: by 2002:a05:6e02:320f:b0:35f:847c:1e4c with SMTP id cd15-20020a056e02320f00b0035f847c1e4cmr1370319ilb.89.1702590500311; Thu, 14 Dec 2023 13:48:20 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702590500; cv=none; d=google.com; s=arc-20160816; b=SbCD29dBrZ4l++x2gkVr24GluMaKshdRJPSdyolZLQPBpVcioNfR9ug/96nhUtfYSA tgGJM1iFlRSd3Rq+/9GCI6isfFw3UZerDcAseSKl5SEgEFact7JLm7jhEtVbtR23auMV /GO+9pinKrH9PfJYwhpbKl7AfclSjyXSOH1GZ58+pIhEjlV7w0tH7ID4hpfDjotDHA/F 74H9HuhDUCjrzhzXmPQ5XLTC2JLwwO+ZEGWLNxftSTwSGcoxV7MDXAW9XTmQQymF/+c9 seYvmCkqbJXfpur+V1lxNJRQS8WV0r4RmQO7HpgO6KaFyyFjvSql2bs8g0BZChVNagXA AzfA== 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.s=2020e; spf=pass (google.com: domain of linux-kernel+bounces-157-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-157-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id h18-20020a63e152000000b005bdbd683601si11885089pgk.57.2023.12.14.13.48.19 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Dec 2023 13:48:20 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-157-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; 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.s=2020e; spf=pass (google.com: domain of linux-kernel+bounces-157-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-157-ouuuleilei=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 B65A2B22657 for ; Thu, 14 Dec 2023 21:46:01 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id C0B7D2C6B6; Thu, 14 Dec 2023 21:42:21 +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 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1785295536121093932 X-GMAIL-MSGID: 1785295536121093932 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 Reviewed-by: Petr Mladek --- 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();