From patchwork Wed Feb 7 13:41:02 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Ogness X-Patchwork-Id: 197948 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:168b:b0:106:860b:bbdd with SMTP id ma11csp2251489dyb; Wed, 7 Feb 2024 06:07:44 -0800 (PST) X-Google-Smtp-Source: AGHT+IGza08SnFprHOumFIF6AEG5KCNitMrDnOzwHiJQJyA2EQI0FlKm7G1k+sb1ryfNBUbFgW00 X-Received: by 2002:a17:903:2b0e:b0:1d8:ef8d:a7ec with SMTP id mc14-20020a1709032b0e00b001d8ef8da7ecmr6849673plb.2.1707314864481; Wed, 07 Feb 2024 06:07:44 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707314864; cv=pass; d=google.com; s=arc-20160816; b=sH0CKa8rrTb+EbprhSiBlK7oIPEIacto5MMTSRSu6Z/9tGG2Qco8CbxrS9No6Q6jwu mTVYy035CGMOuNwWB5/+AL8ZKiDF8FhjmhbinRMUSkVH8PQx1UKAreQuYHMz9NEZjnF+ 7w/IGilWDoW5SDcgSqTtavQC/K2WvP+3wtEqXzYGC0PGJ9sT9k/DsLqeWpMu5lsUPWR/ T0LLeKaocEAHf2tTvfNM1HAFs76wqfFVGaTJtiOLTn6uwynhPXNJw/lMin98grrCHo9H ZiBUdWnXQpEGIltinkQCH0FfWFMWnFd3DWVhM0jjs79Rbqi+/T5CYOQc2CIagBn4vFOy hM7Q== 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:dkim-signature:dkim-signature:from; bh=dglETRzgeJkpvG6OhED1NA4N4r3adrKLfLIWNwh3o/w=; fh=i4zs0yMXR6aCSvn7piRXDARPWTlefnWxznzau8aqmmk=; b=pz53dW3/5Sn2gzwK8OpqmHrNj2D/6LIonsdHDK2IZteuL22DRmwm74CRkK2OBFHDZX EtOqqDpnTD25FQ2cz+DElDmlTpJM/+Zb7cqj6YEsumHcU3hVkTRjEjrdvpFfdq74ibFH qZPLfHtGpl1Q6yVdeXtWzdQ9FTcYPDBwEklSZjxCNBjzL2hQ3v7TwCtRWBq81IvAOtRu RKLlPVudsidPNYJdjH/nL3jh1WD6u9ndKSrYeNQ7Psgh1jYC0NvM+ziXIkbNyRQoJ/LE d7/Kr62od8t8Xjzn6Eb2/YhW6SSrO4tp8pKNDIn8cRdFfO5ANSuy4KhBWK7dFqs19ULo QWlg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=cKTByp08; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e; arc=pass (i=1 spf=pass spfdomain=linutronix.de dkim=pass dkdomain=linutronix.de dmarc=pass fromdomain=linutronix.de); spf=pass (google.com: domain of linux-kernel+bounces-56574-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-56574-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de X-Forwarded-Encrypted: i=2; AJvYcCVfzWd2RH+P/zrzgUuiplpIPhLIqidm+pv2FmhYzwYaFE/YhHpPklex2m4+rSdYTZJ2kMAiSvVLvKL4Pu9VNr65jpuBRQ== Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id y12-20020a170902ed4c00b001d8fc816118si1666860plb.189.2024.02.07.06.07.44 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 07 Feb 2024 06:07:44 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-56574-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=cKTByp08; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e; arc=pass (i=1 spf=pass spfdomain=linutronix.de dkim=pass dkdomain=linutronix.de dmarc=pass fromdomain=linutronix.de); spf=pass (google.com: domain of linux-kernel+bounces-56574-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-56574-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 sv.mirrors.kernel.org (Postfix) with ESMTPS id 6A87428E57E for ; Wed, 7 Feb 2024 13:44:27 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 1D492811F1; Wed, 7 Feb 2024 13:41:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="cKTByp08"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="dZo+Xyev" 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 95B107CF14 for ; Wed, 7 Feb 2024 13:41:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=193.142.43.55 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707313284; cv=none; b=tJ4oMBD+nS2CnYIOEgFJLflhGDOSTK/3KUjCFRxbV3K0pUO+v8ni5F/kAZ75bq363AbTFYhETNNA5l+PVtSmqFDoxB5EYVHV4d5mdmsCWAf1yJqvAz0/QXtY73RLYQrqaDaCaoVtlsDYLQcnBpWVjGbeVoO0s14rmeYQd0UT/Kk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707313284; c=relaxed/simple; bh=CEW+1jm4Jjbzfoy5qe5W0Jz6zUqG9fMl4RYmnU5hdu0=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=ET86fwTN5phYFMr8g1mgJhlj4378Debrnrz3MkK/XmU9j5rqgQDxdqB8lS32sou9ReYRZ6naUXCgxPK6b3uJiMNCMUoYAWFx1P6qd3FGlA6J4EC/7iQ4z8YULJB0TnuK8PgNw4jzul91qPDhOQSEg0eyKKaOz9wtoXAcTfM/GQs= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de; spf=pass smtp.mailfrom=linutronix.de; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=cKTByp08; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=dZo+Xyev; arc=none smtp.client-ip=193.142.43.55 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=1707313278; 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=dglETRzgeJkpvG6OhED1NA4N4r3adrKLfLIWNwh3o/w=; b=cKTByp08JTA4mBNGvjF+r3B+h3oDP2A/bF0kIDK3Of7rFF9xt19VJNvJ0cjRPTf4coBWLt xhneAgT1tON2UttA0t02eGIP02a8XH73ZdtOx454Km/3hruinbPpjpev802RB0kGNMsUgt spWQbaUob+Q81Ih2+sfFcDyzZ37e2xcY+FyUUT22Pwc7w51ZlTXoedt7bc/pRF3y3O2Hu/ 123aPrBb/FvH89xuwHWR/soP9zpojd7iaE+VQI1vPEFJc4Vzty3J7009D1pVc4avWYiYQs xTPqfwc38+1XZtET4wKjpxiD2Ohk+29ALcehkBstaM3XiGrX8FQRR/HuKP1Myw== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1707313278; 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=dglETRzgeJkpvG6OhED1NA4N4r3adrKLfLIWNwh3o/w=; b=dZo+XyevsHtdYpqiRG8A+vejgzxI/quf3igei9fqL+qYK7ZnuJx9XroTnlhM7muuJQPKqJ o3H+KoZfFQN8xNBA== To: Petr Mladek Cc: Sergey Senozhatsky , Steven Rostedt , Thomas Gleixner , linux-kernel@vger.kernel.org, Andrew Morton , Josh Poimboeuf , "Peter Zijlstra (Intel)" , "Guilherme G. Piccoli" , Kefeng Wang , Uros Bizjak , Arnd Bergmann Subject: [PATCH printk v4 13/14] panic: Flush kernel log buffer at the end Date: Wed, 7 Feb 2024 14:47:02 +0106 Message-Id: <20240207134103.1357162-14-john.ogness@linutronix.de> In-Reply-To: <20240207134103.1357162-1-john.ogness@linutronix.de> References: <20240207134103.1357162-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: 1790249391324474300 X-GMAIL-MSGID: 1790249391324474300 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();