From patchwork Mon Oct 30 09:24:31 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Martin_Hundeb=C3=B8ll?= X-Patchwork-Id: 159573 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:d641:0:b0:403:3b70:6f57 with SMTP id cy1csp2079533vqb; Mon, 30 Oct 2023 02:25:07 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGwm1Jl6hHcvRVIaeIQMNFfJXbwnyxQZUxuwtnw/RfugRBfRKnCdxelCsLEKYZcMvOfHxu4 X-Received: by 2002:a05:6358:e4a0:b0:169:6251:c4a5 with SMTP id by32-20020a056358e4a000b001696251c4a5mr1925752rwb.8.1698657907444; Mon, 30 Oct 2023 02:25:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698657907; cv=none; d=google.com; s=arc-20160816; b=hwSyAIBcNq0fCmZmnMwA15MIyRJrXA/TZbIOrjYGp5FIMsReu4PKkKtCxFBoVCayV0 R7vvRrbjW9AgTt1RTolNEW8S0WdVwCul4lznXazMiLJrSwjTmUMKd6a6gfXve1tHz0kW YovcBP6RTZdZgLzXqS25Spk0YgksKEYXru3CZZILR7Oz7oiFxuwpU4ZQVMkiQj6bru4b xkULwNiNIf3FO85iWHvA9jHyzJmk2EkeKQyvZp6oTErkwG7DNZIPlQ/iLTgDjf/rQdtL 7mYDfcxqf87faWdINUiNZ714D7S2zM5OTqAx+FvjGVcZbYQ4ULrjYPut/iSSA2BLdV0q mHuw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=f71kb40JMN6BLPnCWSZ1cPNxqIlMRwG76WxcbNmWQb8=; fh=pJ55Qn24a9TBXwrzJhASvnC3f7aDNo8UQ2xl10y/bWo=; b=G74HUr06O2zjVDdAc8HYiBYIvS0Lgj2UzwnI7e8cbuZ0IyBzXWBrT8+OL4+JtaYA48 P2AH7vSjBPei6hVKmcyc3mLk0a58D29ydF/XsGMcqq+PhLQUBpLB56xKP4j893l4yzWF q0AJs2ukPjjUORC9Bpot1gn1OVdT+HZh+UPCR0ug3i2KyQK3pCSqIFAIJfBoJ6oVPQ8K smLjfj0kzvOFknl1iivyHXhCOSZWwD6m3nlU9gGCQ+5fdwuCPqmu/8yYAmvjrfHDWxXy awqlz79fDbPbgrTFZ7CY64iwRSHbuOnCNOkqJpBwYrogcIFMfoFNZeHh2rHRVqAd/F6R UAIw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@geanix.com header.s=default2211 header.b=ZDWVUwZp; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=geanix.com Received: from groat.vger.email (groat.vger.email. [23.128.96.35]) by mx.google.com with ESMTPS id x14-20020a63170e000000b005b74de09ee0si4571773pgl.108.2023.10.30.02.25.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 30 Oct 2023 02:25:07 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) client-ip=23.128.96.35; Authentication-Results: mx.google.com; dkim=pass header.i=@geanix.com header.s=default2211 header.b=ZDWVUwZp; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=geanix.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by groat.vger.email (Postfix) with ESMTP id 36CB5806036B; Mon, 30 Oct 2023 02:25:05 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232344AbjJ3JYv (ORCPT + 31 others); Mon, 30 Oct 2023 05:24:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40710 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230477AbjJ3JYs (ORCPT ); Mon, 30 Oct 2023 05:24:48 -0400 Received: from www530.your-server.de (www530.your-server.de [188.40.30.78]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 385E7C2 for ; Mon, 30 Oct 2023 02:24:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=geanix.com; s=default2211; h=Content-Transfer-Encoding:Content-Type:MIME-Version: Message-ID:Date:Subject:Cc:To:From:Sender:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:In-Reply-To:References; bh=f71kb40JMN6BLPnCWSZ1cPNxqIlMRwG76WxcbNmWQb8=; b=ZDWVUwZpgNaxZALcQS9fYTrhhn ZIGKXEgQeG0VehZP4nhtqTCz8NBOOWMF70lRJwpiFdqcICzQ1Dr/WyJh4ZI9zJ7b/CCCQSvZS8+Cj a7qmGCVnz0WRe8kRs5gbcyz80XffaOBuWhqTt/ZDkroAvbZkWqkn/VqTXwGkofgaiXWlmKgv3Qtu2 iRldNdZ/wsJoMQLnjtymwXjiwjsih9Zvf2OHn1Kp5CTjhaEy4SgxjiHdBLiK+vbq6Uf12o+atxOcM KMNqFA2VQP20kDHxxSZ0RgU+i5i6vjNYYBvZdWZbmkp0vp5fnG6KS1lFTBk0wE/QsGuSGD7NWk5L7 fPxkC4Sw==; Received: from sslproxy01.your-server.de ([78.46.139.224]) by www530.your-server.de with esmtpsa (TLS1.3) tls TLS_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1qxOVn-000GoV-GG; Mon, 30 Oct 2023 10:24:43 +0100 Received: from [185.17.218.86] (helo=rap..) by sslproxy01.your-server.de with esmtpsa (TLSv1.3:TLS_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1qxOVn-000DPP-4A; Mon, 30 Oct 2023 10:24:43 +0100 From: =?utf-8?q?Martin_Hundeb=C3=B8ll?= To: Petr Mladek Cc: Steven Rostedt , John Ogness , Sergey Senozhatsky , linux-kernel@vger.kernel.org, =?utf-8?q?Martin_Hundeb=C3=B8ll?= Subject: [PATCH 1/2] printk: export pr_flush() Date: Mon, 30 Oct 2023 10:24:31 +0100 Message-ID: <20231030092432.3434623-1-martin@geanix.com> X-Mailer: git-send-email 2.42.0 MIME-Version: 1.0 X-Authenticated-Sender: martin@geanix.com X-Virus-Scanned: Clear (ClamAV 0.103.10/27077/Mon Oct 30 08:39:55 2023) X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on groat.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (groat.vger.email [0.0.0.0]); Mon, 30 Oct 2023 02:25:05 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1781171914185807070 X-GMAIL-MSGID: 1781171914185807070 Printk users might want to assure whatever printed has reached its destination before continuing. E.g. during the shutdown-procedure, where printk-buffers aren't necessarily emptied before the system goes down. Signed-off-by: Martin Hundebøll --- include/linux/printk.h | 5 +++++ kernel/printk/printk.c | 4 +--- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/include/linux/printk.h b/include/linux/printk.h index 8ef499ab3c1e..a2a33494c222 100644 --- a/include/linux/printk.h +++ b/include/linux/printk.h @@ -192,6 +192,7 @@ void show_regs_print_info(const char *log_lvl); extern asmlinkage void dump_stack_lvl(const char *log_lvl) __cold; extern asmlinkage void dump_stack(void) __cold; void printk_trigger_flush(void); +bool pr_flush(int timeout_ms, bool reset_on_progress); #else static inline __printf(1, 0) int vprintk(const char *s, va_list args) @@ -271,6 +272,10 @@ static inline void dump_stack(void) static inline void printk_trigger_flush(void) { } +static inline bool pr_flush(int timeout_ms, bool reset_on_progress) +{ + return true; +} #endif #ifdef CONFIG_SMP diff --git a/kernel/printk/printk.c b/kernel/printk/printk.c index 0b3af1529778..dc1d2c880eb0 100644 --- a/kernel/printk/printk.c +++ b/kernel/printk/printk.c @@ -2336,7 +2336,6 @@ asmlinkage __visible int _printk(const char *fmt, ...) } EXPORT_SYMBOL(_printk); -static bool pr_flush(int timeout_ms, bool reset_on_progress); static bool __pr_flush(struct console *con, int timeout_ms, bool reset_on_progress); #else /* CONFIG_PRINTK */ @@ -2365,7 +2364,6 @@ static ssize_t msg_print_ext_body(char *buf, size_t size, static void console_lock_spinning_enable(void) { } static int console_lock_spinning_disable_and_check(int cookie) { return 0; } static bool suppress_message_printing(int level) { return false; } -static bool pr_flush(int timeout_ms, bool reset_on_progress) { return true; } static bool __pr_flush(struct console *con, int timeout_ms, bool reset_on_progress) { return true; } #endif /* CONFIG_PRINTK */ @@ -3813,7 +3811,7 @@ static bool __pr_flush(struct console *con, int timeout_ms, bool reset_on_progre * Context: Process context. May sleep while acquiring console lock. * Return: true if all usable printers are caught up. */ -static bool pr_flush(int timeout_ms, bool reset_on_progress) +bool pr_flush(int timeout_ms, bool reset_on_progress) { return __pr_flush(NULL, timeout_ms, reset_on_progress); } From patchwork Mon Oct 30 09:24:32 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Martin_Hundeb=C3=B8ll?= X-Patchwork-Id: 159572 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:d641:0:b0:403:3b70:6f57 with SMTP id cy1csp2079520vqb; Mon, 30 Oct 2023 02:25:05 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFC/tawiCkHdY6LkZH2UA+fLqT3nJAxTfjTWXPJDElCcGdynhfAuR79YRMCGfTNQrwMTRoa X-Received: by 2002:a05:6358:528b:b0:168:d282:90e with SMTP id g11-20020a056358528b00b00168d282090emr12283675rwa.5.1698657904944; Mon, 30 Oct 2023 02:25:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698657904; cv=none; d=google.com; s=arc-20160816; b=v3MMGa3CjBtTaLGfY+ECovdApRGRxooJWDd0amv39wihOc+ow0+qL9YDf6PqR5zGPc 2oQa8IZ7lw4cy2icAjHGT0rPWtI5BhqHW+LhSYFlXFqvLfq39kaz7nkyNF0DNNjkbauE qFKURft9LtHD/wKlSO2+F/e5bp2JnNzwjDAnVa4jtBOCAdLk5Wz3TPt9koInlvaZNx4Y dT1fPd/tU2dR59tMVHQyBN7b6OjeTZpsuC7C5rWVptf29mbSqwULQykcQB1qUBgxxAlk eizsl9wA+WTA+sk919bDJdOP86a6t/0Rv+IdeAtd8ncCfAjq9TTADcB2Hv4EAymI5Dyf o7JQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=bBSFA3O82q5iuXanYrFgC4j6cxLDU7YW1ZtrgC7Y3fQ=; fh=pJ55Qn24a9TBXwrzJhASvnC3f7aDNo8UQ2xl10y/bWo=; b=PFDEUpONhYN97hPzjFg2bdPnGl7GHbktJeotf+vDhdpHh7aggdRvrNefy67h4m4133 2CKk65AUL7aobytbcN4ANVuDH++FYF4F/MNySAd2U67xo58W6J4VI3wWmdpu/ewrsGWX Qs9ZNJkahjF0vePUPeMsIwe6tNIVq7PCaeY56M+qfzFEl/J1v40XKrkrxkTslRgCix3t Nub8ko2iDCzd6PWiWNcLKPBKd/IHZ/w+uEKX4sQOP3G2WEaqD1qj+SMarF85iOVlX3tE 1dtPTYnQklcn4JEYHAHlMKc8BAsz1EU2tUDpharQ3tjVkMc0tKI8l0aF6Y6uiXStzFMO MEuA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@geanix.com header.s=default2211 header.b=0i9XiiD3; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=geanix.com Received: from howler.vger.email (howler.vger.email. [2620:137:e000::3:4]) by mx.google.com with ESMTPS id a19-20020a656413000000b005b7d939c3d9si4772629pgv.651.2023.10.30.02.25.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 30 Oct 2023 02:25:04 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) client-ip=2620:137:e000::3:4; Authentication-Results: mx.google.com; dkim=pass header.i=@geanix.com header.s=default2211 header.b=0i9XiiD3; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=geanix.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by howler.vger.email (Postfix) with ESMTP id 49F0D80A7700; Mon, 30 Oct 2023 02:25:02 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at howler.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232342AbjJ3JYu (ORCPT + 31 others); Mon, 30 Oct 2023 05:24:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40712 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232241AbjJ3JYs (ORCPT ); Mon, 30 Oct 2023 05:24:48 -0400 Received: from www530.your-server.de (www530.your-server.de [188.40.30.78]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 38650C4 for ; Mon, 30 Oct 2023 02:24:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=geanix.com; s=default2211; h=Content-Transfer-Encoding:Content-Type:MIME-Version: References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From:Sender:Reply-To: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID; bh=bBSFA3O82q5iuXanYrFgC4j6cxLDU7YW1ZtrgC7Y3fQ=; b=0i9XiiD3icqdfgdsbZu5BLEMid cS9woy/3gvS6RBrn2M1x3OKOVc1X12GA2/EEI/3QQXBiB8ybG/8Xf87UFw03IVGBKe2rhjtrZ+095 nndV9Et1lyJ0ySN8GDxTBxzW6imjnbuof6yN4PmToK9XjWNj+uxKYfqPGNoSQmOnmuH/vk28dUQcQ Jb2i4xvph1eIRRmlQyd29PPhd66f74FbsfG0gpAtTpnz1hZ4bsMUhjiHnEw2gIrBNeDDTkqalHBlv miwJfLr48KA1ursYK9m8Tu5k49MCFFCZehhbDTm3Lr53g+qp6Nk9GKvvdVw2zYPqWrnTeVRbY3uBd ZJXnFkAg==; Received: from sslproxy01.your-server.de ([78.46.139.224]) by www530.your-server.de with esmtpsa (TLS1.3) tls TLS_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1qxOVn-000GoW-KS; Mon, 30 Oct 2023 10:24:43 +0100 Received: from [185.17.218.86] (helo=rap..) by sslproxy01.your-server.de with esmtpsa (TLSv1.3:TLS_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1qxOVn-000DPP-9i; Mon, 30 Oct 2023 10:24:43 +0100 From: =?utf-8?q?Martin_Hundeb=C3=B8ll?= To: Petr Mladek Cc: Steven Rostedt , John Ogness , Sergey Senozhatsky , linux-kernel@vger.kernel.org, =?utf-8?q?Martin_Hundeb=C3=B8ll?= Subject: [PATCH 2/2] reboot: flush printk buffers before final shutdown Date: Mon, 30 Oct 2023 10:24:32 +0100 Message-ID: <20231030092432.3434623-2-martin@geanix.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20231030092432.3434623-1-martin@geanix.com> References: <20231030092432.3434623-1-martin@geanix.com> MIME-Version: 1.0 X-Authenticated-Sender: martin@geanix.com X-Virus-Scanned: Clear (ClamAV 0.103.10/27077/Mon Oct 30 08:39:55 2023) X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on howler.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (howler.vger.email [0.0.0.0]); Mon, 30 Oct 2023 02:25:02 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1781171911287418289 X-GMAIL-MSGID: 1781171911287418289 Make sure printed messages are in fact printed before putting the system down. Signed-off-by: Martin Hundebøll --- kernel/reboot.c | 1 + 1 file changed, 1 insertion(+) diff --git a/kernel/reboot.c b/kernel/reboot.c index 3bba88c7ffc6..bab8350d5dae 100644 --- a/kernel/reboot.c +++ b/kernel/reboot.c @@ -273,6 +273,7 @@ void kernel_restart(char *cmd) else pr_emerg("Restarting system with command '%s'\n", cmd); kmsg_dump(KMSG_DUMP_SHUTDOWN); + pr_flush(1000, false); machine_restart(cmd); } EXPORT_SYMBOL_GPL(kernel_restart);