Message ID | 20221019145600.1282823-10-john.ogness@linutronix.de |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp377871wrs; Wed, 19 Oct 2022 08:08:01 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5K9FZSkIQqjWJVAbHW4oGsVCahu93Cd3ZNvCN8rPDa+GXOa9doBl5c2c2PDBoBqMugjrBb X-Received: by 2002:a17:906:ef8c:b0:78d:96b9:a0ad with SMTP id ze12-20020a170906ef8c00b0078d96b9a0admr7282737ejb.529.1666192081747; Wed, 19 Oct 2022 08:08:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666192081; cv=none; d=google.com; s=arc-20160816; b=j4Wiu2iWX01Xyzppw+HGiYcgPCiKkfvqTcwTa/gaGiHCQBSDXh4Aj4iA+oP3YwK5ux BK53iZK5xf8klGNJ+OyAeqwiVgiHa5BvCbpRuXNBBeL5Uth+rVJZpb9FzQfKc3SxKIWC f4MGPXb5XfXiQcrpFRRSVocU0KzdobIbK6gl0sJS8YT7HBmeatPURHkTgfBYvmHoTRAb Vp1TjgHlaUtAtNwav67uPPQXMobwZTSNACRWeh8MaFFxlhIbRH044xAYmHKn3ZG7y42L DFMubHkpLNM3RauEP1Za9z51exy7gKk2RO0kQLAJ+LPsWOCltZYrRpl1yP1sTiFTtRuf GovQ== 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=6uEJOM0caPrcvNJcHiErtW6cO4rX4lvkgAL5ZPoAngE=; b=ZvwCpncD8XzBcL9H4b1h7ZEl//Cg5TuvHjEkIfVfM1RC9NYHYN1clqYg3T8G4wco+2 uDmc/HW0yN0tsNqZuzZcTCFfXcSqPCd8bpkqgjbP/K3mfbzcfNIygUEm3rrYVCUH4+Cu GCiCwAVgiDpggqcdW/0kdmZbg4P/jXQLP2CdFKzyFtyFr3Cn4x3OT0S34RQ9ZGmFGL5M fEwJDz/dar0yXoiXr/HRNdtXJmHLxzrAarf1HG1y0THB8PmT/rfWpK2/pVMQWIdlQcBD gl6H5rU1ZuiDXVIU0mfWZaiHzNTQGniSfBCQgBK7+RANSx4Y9SxvV/7Ionk2EqeeAu7S q/pg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=CapeSp4l; dkim=neutral (no key) header.i=@linutronix.de; 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 gs19-20020a1709072d1300b00783d5a93880si14237860ejc.503.2022.10.19.08.07.27; Wed, 19 Oct 2022 08:08:01 -0700 (PDT) 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=CapeSp4l; dkim=neutral (no key) header.i=@linutronix.de; 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 S231566AbiJSPEl (ORCPT <rfc822;samuel.l.nystrom@gmail.com> + 99 others); Wed, 19 Oct 2022 11:04:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60680 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232013AbiJSPEA (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Wed, 19 Oct 2022 11:04:00 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3A1AF189C3E; Wed, 19 Oct 2022 07:58:32 -0700 (PDT) From: John Ogness <john.ogness@linutronix.de> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1666191366; 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=6uEJOM0caPrcvNJcHiErtW6cO4rX4lvkgAL5ZPoAngE=; b=CapeSp4lIuUCMT3A2F+Nh1MiAgJLkP2QvT6kPUMQDmJJFQsukbmY9zgoaeE4Mq6UuBqXXb FrZc++ZOPgsuLs9l7PcPyG4j8PgQByAcFR2QTb5ZOiIdmXyyFYqlRtydfmDmoK5yA3OP78 U0XmnXaelSW/V/NwDwJUqlWqX2IcrI2b9QoB5wTOni/8eC59uwoJspmELM/0AK/+2z5J0G bd1oHF0zuZVLDhAFAcJJT5y3CPqV4fXZIaKcBDHjVUzgpVkWqsTRUcD5J9GUYo05fhBIDg fYj1DxyE3Wu0F0Ede8aUNYGFTPayP73PEUKd+FQ5qnHfrV5Nu/mSQTYm2wS3RQ== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1666191366; 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=6uEJOM0caPrcvNJcHiErtW6cO4rX4lvkgAL5ZPoAngE=; b=ZQecdyT7PQky3Pel/Hzc+4qBo3aS7NXlfHW9v7oMg/iE63aGG0BcneUC9VkDNd/cxE1gob fBX8kx6iiefyiNCg== 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, "David S. Miller" <davem@davemloft.net>, Eric Dumazet <edumazet@google.com>, Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>, netdev@vger.kernel.org Subject: [PATCH printk v2 09/38] netconsole: use console_is_enabled() Date: Wed, 19 Oct 2022 17:01:31 +0206 Message-Id: <20221019145600.1282823-10-john.ogness@linutronix.de> In-Reply-To: <20221019145600.1282823-1-john.ogness@linutronix.de> References: <20221019145600.1282823-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?1747129028390875320?= X-GMAIL-MSGID: =?utf-8?q?1747129028390875320?= |
Series |
reduce console_lock scope
|
|
Commit Message
John Ogness
Oct. 19, 2022, 2:55 p.m. UTC
Replace (console->flags & CON_ENABLED) usage with console_is_enabled().
Signed-off-by: John Ogness <john.ogness@linutronix.de>
---
drivers/net/netconsole.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
Comments
On Wed 2022-10-19 17:01:31, John Ogness wrote: > Replace (console->flags & CON_ENABLED) usage with console_is_enabled(). > > Signed-off-by: John Ogness <john.ogness@linutronix.de> The change is straightforward: Reviewed-by: Petr Mladek <pmladek@suse.com> The comment below is just a lamentation about the netconsole code. > --- > drivers/net/netconsole.c | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) > > diff --git a/drivers/net/netconsole.c b/drivers/net/netconsole.c > index bdff9ac5056d..073e59a06f21 100644 > --- a/drivers/net/netconsole.c > +++ b/drivers/net/netconsole.c > @@ -332,7 +332,7 @@ static ssize_t enabled_store(struct config_item *item, > } > > if (enabled) { /* true */ > - if (nt->extended && !(netconsole_ext.flags & CON_ENABLED)) { > + if (nt->extended && !console_is_enabled(&netconsole_ext)) { > netconsole_ext.flags |= CON_ENABLED; > register_console(&netconsole_ext); > } > @@ -915,7 +915,7 @@ static int __init init_netconsole(void) > if (err) > goto undonotifier; > > - if (netconsole_ext.flags & CON_ENABLED) > + if (console_is_enabled(&netconsole_ext)) > register_console(&netconsole_ext); > register_console(&netconsole); > pr_info("network logging started\n"); Just for record: This looks like a (mis)use of CON_ENABLED flag. It took me some time to understand why pre-enabled consoles are handled special way in register_console(). I partly documented it in try_enable_preferred_console(): /* * Some consoles, such as pstore and netconsole, can be enabled even * without matching. Accept the pre-enabled consoles only when match() * and setup() had a chance to be called. */ if (console_is_enabled(newcon) && (c->user_specified == user_specified)) return 0; In my bottom driver, I have a patch cleaning this. It is part of a bigger clean up that is not ready for upstream :-/ Best Regards, Petr
On 2022-10-21, Petr Mladek <pmladek@suse.com> wrote: >> diff --git a/drivers/net/netconsole.c b/drivers/net/netconsole.c >> index bdff9ac5056d..073e59a06f21 100644 >> --- a/drivers/net/netconsole.c >> +++ b/drivers/net/netconsole.c >> @@ -332,7 +332,7 @@ static ssize_t enabled_store(struct config_item *item, >> } >> >> if (enabled) { /* true */ >> - if (nt->extended && !(netconsole_ext.flags & CON_ENABLED)) { >> + if (nt->extended && !console_is_enabled(&netconsole_ext)) { >> netconsole_ext.flags |= CON_ENABLED; >> register_console(&netconsole_ext); >> } >> @@ -915,7 +915,7 @@ static int __init init_netconsole(void) >> if (err) >> goto undonotifier; >> >> - if (netconsole_ext.flags & CON_ENABLED) >> + if (console_is_enabled(&netconsole_ext)) >> register_console(&netconsole_ext); >> register_console(&netconsole); >> pr_info("network logging started\n"); > > This looks like a (mis)use of CON_ENABLED flag. Yes. When @netconsole_ext is registered, CON_ENABLED is always set. So it should be set in the static initialization. The first hunk should be using the new console_is_registered(). The second hunk should be using a local @extended bool variable. Also, in cleanup_netconsole() it should check if the console is registered: if (console_is_registered(&netconsole_ext)) unregister_console(&netconsole_ext); I will make all of these changes for v3. Then there will be no checking/setting of CON_ENABLED in the driver. John Ogness
diff --git a/drivers/net/netconsole.c b/drivers/net/netconsole.c index bdff9ac5056d..073e59a06f21 100644 --- a/drivers/net/netconsole.c +++ b/drivers/net/netconsole.c @@ -332,7 +332,7 @@ static ssize_t enabled_store(struct config_item *item, } if (enabled) { /* true */ - if (nt->extended && !(netconsole_ext.flags & CON_ENABLED)) { + if (nt->extended && !console_is_enabled(&netconsole_ext)) { netconsole_ext.flags |= CON_ENABLED; register_console(&netconsole_ext); } @@ -915,7 +915,7 @@ static int __init init_netconsole(void) if (err) goto undonotifier; - if (netconsole_ext.flags & CON_ENABLED) + if (console_is_enabled(&netconsole_ext)) register_console(&netconsole_ext); register_console(&netconsole); pr_info("network logging started\n");