Message ID | 20221107141638.3790965-7-john.ogness@linutronix.de |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp2077905wru; Mon, 7 Nov 2022 06:19:41 -0800 (PST) X-Google-Smtp-Source: AA0mqf5ZXX0VzfZoJtEWvu/X4fbjDdyW4oPekfiETzCChCmXLp4W1pRuOV849+0ttt/LyMJ+RWiQ X-Received: by 2002:a17:907:3f9d:b0:7ae:587e:73aa with SMTP id hr29-20020a1709073f9d00b007ae587e73aamr10313292ejc.289.1667830780880; Mon, 07 Nov 2022 06:19:40 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1667830780; cv=none; d=google.com; s=arc-20160816; b=Jlp4VzuiRZhqrW20gIZjAtIMPdpuxNLToWVuaN4gtz/yeY+Pt9KSbhsFKD9LR3Osgx eyO6MBrRCsmWW2y4dRbsPfKGQ+mqubjhpfBOu6SmQbaKhCqzXZKyaJVkstM818RdOuLf +44g8cjrx+t4Vjg88Y9NZbHmr+NNvnyapiUCMHGgHYaiC8q0bxIQA4nJSo7pXdAyCE3w h/TXTUUUt5rlLWrIZA9jGXrXmP4g+k9biI+mqb/hhpME9En52c6uX7ZJvgV1FuLsHrLS sKSTle5bZEhH/XazZTsZxlU8+wQIxGY80Nbfd5jzg0Z3q0YJsV3KTeMWq6phc9/EFG+8 x9Aw== 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:dkim-signature :dkim-signature:from; bh=6/paKzOHPdL7LtYxjVc5vEnqdv9ZQ5lgTtMtTQHWNnQ=; b=FsUlslfnAttvJwLfU6nzPTLKTV3ildKdE2mn/uA6l3wReN9+mky8KhWegEDkS5iImM jQgnB0qpR6N+PfRqPpbGQwcbm5tUBgdBXBN1iChTjcL5m7c3VHLIfR2rj/OEoTUpnAyg YT9Xyea5ZviHi4+1R9bDGL8lDolz4oDxgftm/B6SQJ+CipzzyUJ06JV2oS2EDRplgJIN CudlCe7MTMN5YBKDDtp5EMGTVCUdPpaxaciKBJGH7Ibu0qxWpGYXJM11ROpkM7vk1rBc rp5bJFufjGE5d7pmzAeRY7lKQ2/z70Az8Snbs4wwAKLyfIYlEBvgSS15E4HnWDwNhd9x o87A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=kgfOV8TY; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=vWS9R1RB; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id w18-20020a50fa92000000b00461d5afea01si8286588edr.165.2022.11.07.06.19.16; Mon, 07 Nov 2022 06:19:40 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=kgfOV8TY; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=vWS9R1RB; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231689AbiKGORK (ORCPT <rfc822;hjfbswb@gmail.com> + 99 others); Mon, 7 Nov 2022 09:17:10 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55670 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232099AbiKGOQq (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Mon, 7 Nov 2022 09:16:46 -0500 Received: from galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0DC151CFF1 for <linux-kernel@vger.kernel.org>; Mon, 7 Nov 2022 06:16:45 -0800 (PST) From: John Ogness <john.ogness@linutronix.de> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1667830603; 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=6/paKzOHPdL7LtYxjVc5vEnqdv9ZQ5lgTtMtTQHWNnQ=; b=kgfOV8TY/LzEY5UzgRdT3BlvUS4J1DgI43rtqiBP9Hat6fe0tbknUSa2d0RAAIOO+gTscI 9gmZ/Oe5VTwP6nr6aI5cirDD8ru3D4TaVVzQzcKFr/nXfUWAbIm76g0tG7oACi1zAypM21 wSACcAaMqT+08PtymJMHqyyKDvN6rE0eGaya9a2kYmWdI+WL8S/v3bS5NYBqugmdS4eUgw 2PBFr7mml7AoQQIqx6L9iXf/WfFvtkQbEyOJtpgmt4m1tvzCh+5Ks6dDOcremWNzfpqzKp 9uTWvROhtIUwlxLIz7tHhRdcrNZtybOB6R8xqouGyYP+HcGLH3dnVTezBOcTHQ== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1667830603; 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=6/paKzOHPdL7LtYxjVc5vEnqdv9ZQ5lgTtMtTQHWNnQ=; b=vWS9R1RBOLVJYj2nIE+UOu47k28bDRXb6conZQphvOjHz1Y9ErtSJTCEnA7Fn3BAEIUYkJ oQTGziecwCDdfmAQ== To: Petr Mladek <pmladek@suse.com> Cc: Sergey Senozhatsky <senozhatsky@chromium.org>, Steven Rostedt <rostedt@goodmis.org>, Thomas Gleixner <tglx@linutronix.de>, linux-kernel@vger.kernel.org, Richard Weinberger <richard@nod.at>, Anton Ivanov <anton.ivanov@cambridgegreys.com>, Johannes Berg <johannes@sipsolutions.net>, linux-um@lists.infradead.org Subject: [PATCH printk v3 06/40] um: kmsg_dump: only dump when no output console available Date: Mon, 7 Nov 2022 15:22:04 +0106 Message-Id: <20221107141638.3790965-7-john.ogness@linutronix.de> In-Reply-To: <20221107141638.3790965-1-john.ogness@linutronix.de> References: <20221107141638.3790965-1-john.ogness@linutronix.de> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-3.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,INVALID_DATE_TZ_ABSURD, RCVD_IN_DNSWL_MED,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1748847328428193040?= X-GMAIL-MSGID: =?utf-8?q?1748847328428193040?= |
Series |
reduce console_lock scope
|
|
Commit Message
John Ogness
Nov. 7, 2022, 2:16 p.m. UTC
The initial intention of the UML kmsg_dumper is to dump the kernel
buffers to stdout if there is no console available to perform the
regular crash output.
However, if ttynull was registered as a console, no crash output was
seen. Commit e23fe90dec28 ("um: kmsg_dumper: always dump when not tty
console") tried to fix this by performing the kmsg_dump unless the
stdio console was behind /dev/console or enabled. But this allowed
kmsg dumping to occur even if other non-stdio consoles will output
the crash output. Also, a console being the driver behind
/dev/console has nothing to do with a crash scenario.
Restore the initial intention by dumping the kernel buffers to stdout
only if a non-ttynull console is registered and enabled. Also add
detailed comments so that it is clear why these rules are applied.
Signed-off-by: John Ogness <john.ogness@linutronix.de>
---
arch/um/kernel/kmsg_dump.c | 15 ++++++++++++---
1 file changed, 12 insertions(+), 3 deletions(-)
Comments
On Mon 2022-11-07 15:22:04, John Ogness wrote: > The initial intention of the UML kmsg_dumper is to dump the kernel > buffers to stdout if there is no console available to perform the > regular crash output. > > However, if ttynull was registered as a console, no crash output was > seen. Commit e23fe90dec28 ("um: kmsg_dumper: always dump when not tty > console") tried to fix this by performing the kmsg_dump unless the > stdio console was behind /dev/console or enabled. But this allowed > kmsg dumping to occur even if other non-stdio consoles will output > the crash output. Also, a console being the driver behind > /dev/console has nothing to do with a crash scenario. > > Restore the initial intention by dumping the kernel buffers to stdout > only if a non-ttynull console is registered and enabled. Also add > detailed comments so that it is clear why these rules are applied. > > Signed-off-by: John Ogness <john.ogness@linutronix.de> The change makes sense to me: Reviewed-by: Petr Mladek <pmladek@suse.com> Best Regards, Petr
diff --git a/arch/um/kernel/kmsg_dump.c b/arch/um/kernel/kmsg_dump.c index 0224fcb36e22..40abf1e9ccb1 100644 --- a/arch/um/kernel/kmsg_dump.c +++ b/arch/um/kernel/kmsg_dump.c @@ -17,13 +17,22 @@ static void kmsg_dumper_stdout(struct kmsg_dumper *dumper, unsigned long flags; size_t len = 0; - /* only dump kmsg when no console is available */ + /* + * If no consoles are available to output crash information, dump + * the kmsg buffer to stdout. + */ + if (!console_trylock()) return; for_each_console(con) { - if(strcmp(con->name, "tty") == 0 && - (con->flags & (CON_ENABLED | CON_CONSDEV)) != 0) { + /* + * The ttynull console and disabled consoles are ignored + * since they cannot output. All other consoles are + * expected to output the crash information. + */ + if (strcmp(con->name, "ttynull") != 0 && + (con->flags & CON_ENABLED)) { break; } }