Received: by 2002:ab2:b82:0:b0:1f3:401:3cfb with SMTP id 2csp1074250lqh; Fri, 29 Mar 2024 06:36:56 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXC2HbDHq2xgtYIqFnffIc9xJk3zuv+4vcOhhIotzufz+3ouJQB/etVO5ufNdQeaaC0XrtU/DKaljkRC5Okh6H9Dnffu7DQE7Gsi7fyhQ== X-Google-Smtp-Source: AGHT+IEB+j1hk0G4TZsDoJhUmlkbARs/epOi60Syi8W1ze5ywBT8mgSkLq6ORRqHMvSrbBwygFed X-Received: by 2002:a05:620a:40ce:b0:78a:452e:d602 with SMTP id g14-20020a05620a40ce00b0078a452ed602mr2291105qko.41.1711719416097; Fri, 29 Mar 2024 06:36:56 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1711719416; cv=pass; d=google.com; s=arc-20160816; b=lJTRN4x7Se7pef6p4sdtHnReDA88kBwGZO78ddlmlBun/hBfADqxKii/TyhUFyUchx gCvhJnCEQt4pCccpRGDVc4zl4h4caYzzQ9h9t23g4l4QPJKQ/2mgwXFK2xCl7j/CJRmQ KTFHXcGdQjYz3ybiIwcU1gB+F9o5YRYhyPHvscDLIwEgwi9pNu1CJnL+/pHpP3eF5vdy gqeeYmgZw1oD/wnQb3rF+jq33CGsSJt3i9wttXhHqP9VNdSHJn+bJUiMa7BWwpSolN4Q yPTqw3OAfDgSDoPZt/JO4BHF6J3w5o+dElpXFMomPW/nQY6BxIG+0XW0KuqVgUyck5ta HzWw== ARC-Message-Signature: i=2; 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:from:dkim-signature; bh=lvzWxhysvS3iLlwyRhsKmg/pHwPNkHpDUhvwBE737XA=; fh=PndALSOzQUoe7oLdD73S7mk0LO61VZuAe+c6hZ5u8Sk=; b=qh/wQJbwnj+B1Gy5JNOsJgY7f9LuCw78SnvsDRXjTpSACp++ogZ2ytBlqYZsbwQwzM cM3cVnTAV/w5ucTaM0bOCRf9S3gaoj2MSmKdYtI0RUS7h4bktzUeJnFeSs4vTG3iO5G4 ACpNSV3PYZVqp3VSElHUWZa7ShIuE+sKwBVN7yMZLW8Y4h2jD8Yg+bzgjAL3oUd90HR4 p67hms5WFrYfwLttwV895/YPEpJGcZN0wEbY6Y99NpQr0jkK7XeLJ5VxfPxxr3Yx4gnF Em7htKpgmK+gSD4BbAddEk+HWjrZZKOqbqNDlexOscXWehIWS8iRyXCvO/3mqnLUgcBF fIXg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=AwmLFsjS; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-124731-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-124731-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id d20-20020a05620a167400b00789fdf70813si3560486qko.770.2024.03.29.06.36.55 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 29 Mar 2024 06:36:56 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-124731-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=AwmLFsjS; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-124731-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-124731-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org 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 ny.mirrors.kernel.org (Postfix) with ESMTPS id 52E9E1C21520 for ; Fri, 29 Mar 2024 13:36:53 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 032911788A0; Fri, 29 Mar 2024 12:40:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="AwmLFsjS" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 2B826178890; Fri, 29 Mar 2024 12:40:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711716026; cv=none; b=qjiMNCnmAJSmFzbsG12ar+NfqeLe64xVN4LECk271p65QYdw3W3YgfuQonGv7VoZ6NPV8lcwI2mWzf3bE6pJAcj7XVE2b5Gd2x4RLvgOjWBP0o+30MS7LAts7N0IoFT+kffSA7Lvjl/d9XjAMspSn2p/REDhdB7EhcXJE2cPHNU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711716026; c=relaxed/simple; bh=WBxuzQAL7Uk/oH50pW4tkZDR4/xjBoDCxy6UmwLkmH8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=CAxYIyQ1oEhKeNnG8+vEMrYGwocaoHG8XB7aTEd2K1gn/GoeyvRqfHAzLlr2Q35IplENw1cytl8snbwYy7cqjguwZL5n/4RQbiTgD7QgggOl86exCDztgonU6X1kO8g2ytS2dnCc/qAs5Wq9ijteU24UTevmY9qc0AtAGUI1+SQ= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=AwmLFsjS; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id AA3A7C43390; Fri, 29 Mar 2024 12:40:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1711716026; bh=WBxuzQAL7Uk/oH50pW4tkZDR4/xjBoDCxy6UmwLkmH8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=AwmLFsjSEurH2/xTUh39aRikZ4o/+Xl2mQfTUYFMUNRqd1gPOIovzvSTlzAFJ92Dw SO5KwGos8PmdSwd0bgMXY10NoM+Oh/uAm507aeLBhcUsw9mk4UoNO8yBHHtzWmjS+w u3E46R3vKttIVMCkAHE9We+i5lXFLXXDOuTU7B46efMdWAeOQ7AnzAh/d3+ILIpZT7 JH/UIGa+x5/HTMJpPhWv4rLRzdkQdk287JfbOk6fp7uG02tnWgAgKW5E4O5C96jXIw pSSwufKvLfD6VRTI+JxFU/SKlPmf6bQ3b/Jrvm6LBQ+OULoNwRx2Mrirw5iARCAZ/A gemv8SuiYrV4Q== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: John Ogness , Petr Mladek , Sasha Levin , akpm@linux-foundation.org, peterz@infradead.org, jpoimboe@kernel.org, wangkefeng.wang@huawei.com, ubizjak@gmail.com, feng.tang@intel.com, bhe@redhat.com, arnd@arndb.de Subject: [PATCH AUTOSEL 6.8 22/98] panic: Flush kernel log buffer at the end Date: Fri, 29 Mar 2024 08:36:53 -0400 Message-ID: <20240329123919.3087149-22-sashal@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240329123919.3087149-1-sashal@kernel.org> References: <20240329123919.3087149-1-sashal@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore X-stable-base: Linux 6.8.2 Content-Transfer-Encoding: 8bit From: John Ogness [ Upstream commit d988d9a9b9d180bfd5c1d353b3b176cb90d6861b ] 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 Link: https://lore.kernel.org/r/20240207134103.1357162-14-john.ogness@linutronix.de Signed-off-by: Petr Mladek Signed-off-by: Sasha Levin --- kernel/panic.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/kernel/panic.c b/kernel/panic.c index 2807639aab51d..f22d8f33ea147 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.43.0