Received: by 2002:a05:6358:1087:b0:cb:c9d3:cd90 with SMTP id j7csp848114rwi; Thu, 20 Oct 2022 06:04:07 -0700 (PDT) X-Google-Smtp-Source: AMsMyM51ykBGrv0h4EO+DaW9kElLNgLt78a3uLS7pOK1GZEw3qbHOiIwnkmb7coLqriMsDRqUXMx X-Received: by 2002:a17:907:2cf5:b0:78d:5d7a:9cde with SMTP id hz21-20020a1709072cf500b0078d5d7a9cdemr11164175ejc.17.1666271041303; Thu, 20 Oct 2022 06:04:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666271041; cv=none; d=google.com; s=arc-20160816; b=mMXCyRPId07iOvmYzMIe6kd84aYOVe3YKEhgLirAs+5W88+QqdR3T07k1RswPqz5mu biJbiKmmlz8/qMDPniPtpZJzGz3Er1+ibr11l5bNAsmAQ6erRgQB0celj1NaHWvJKLfd nZEGbScwGylPpYOEh+a2uYeL0af0rb/42tTu0ADlTfbJw85/hFbYLCimtrZ8QizbUswC ob4wDXSIJr/1NBMBXJZxUW6tOc9vDqUh6YYJUNbu99aiaDIUfxlNco4s6xgaPPY1kFhU LfqbSROJP/BPg78uSoqCBNGJqdFpHkhIHHLkTantYx+HA6zpYFGS7Aj0H2C0JfIWnNHh 8/+w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=o4ei7yu6QWFyLMaeYgPNpdUb6xNNxRYG7Pz1Chl8oOg=; b=s9RJ/Yh0RrMeyrswixyjSAiACneDYJ9OfFan08a/F2pzalx9tnFnL9BpUXPTtoFlRu TM2eXc1jmuDdomiZxYnoOKEH3vjhbBdNWAR+RqmqPNVtzYs1wVnxAzw9flhq/U3FZLi3 GQJ1awjUlePH7DYvAX3U9JOCaFNb/VKacE1dv8fly2xmkLACMhfKAQi1asJV06MDQAYR m2YpNASI9VA0hyWeHnr5zNdH/HU8XUt2z03ubSTVADaoY4tah+81RnEOH15aoa/OuCUN GbmZuVPnA/KHY5k06ahlAV5v6reLDYc8mLTWa6WynYlkn7fs/7NugSFwUgsZbUvKG5w5 RVlQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.com header.s=susede1 header.b=TCTHPh2E; 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=QUARANTINE sp=QUARANTINE dis=NONE) header.from=suse.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id dt19-20020a170907729300b007804b5a2c48si17587476ejc.521.2022.10.20.06.03.26; Thu, 20 Oct 2022 06:04: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=@suse.com header.s=susede1 header.b=TCTHPh2E; 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=QUARANTINE sp=QUARANTINE dis=NONE) header.from=suse.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230139AbiJTMgk (ORCPT + 99 others); Thu, 20 Oct 2022 08:36:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55250 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230151AbiJTMgg (ORCPT ); Thu, 20 Oct 2022 08:36:36 -0400 Received: from smtp-out1.suse.de (smtp-out1.suse.de [IPv6:2001:67c:2178:6::1c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EAA721217F4; Thu, 20 Oct 2022 05:36:07 -0700 (PDT) Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out1.suse.de (Postfix) with ESMTP id C8B06336C7; Thu, 20 Oct 2022 12:36:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1666269365; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=o4ei7yu6QWFyLMaeYgPNpdUb6xNNxRYG7Pz1Chl8oOg=; b=TCTHPh2Er+wUmxpEnRpZf3ieCEOZOXhVL2OvOL/blhd9yLGgfPeGmwG9aJk+4KlkG8bQnb xV95E7D8OVyvBS76T0pDEPaEPG0qvcDIzCDjM+n4VCJBzC1E4NjBkD4mDXzatbXmzwIpT1 zdnJxZ4wf+OCrFda3jhu4dDPBGPto7I= Received: from suse.cz (unknown [10.100.208.146]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by relay2.suse.de (Postfix) with ESMTPS id 857AB2C141; Thu, 20 Oct 2022 12:36:05 +0000 (UTC) Date: Thu, 20 Oct 2022 14:36:02 +0200 From: Petr Mladek To: John Ogness Cc: Sergey Senozhatsky , Steven Rostedt , Thomas Gleixner , linux-kernel@vger.kernel.org, Greg Kroah-Hartman , linux-fsdevel@vger.kernel.org Subject: Re: [PATCH printk v2 02/38] printk: Convert console_drivers list to hlist Message-ID: References: <20221019145600.1282823-1-john.ogness@linutronix.de> <20221019145600.1282823-3-john.ogness@linutronix.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20221019145600.1282823-3-john.ogness@linutronix.de> X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW,SPF_HELO_NONE, SPF_PASS,URIBL_BLOCKED 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: X-Mailing-List: linux-kernel@vger.kernel.org On Wed 2022-10-19 17:01:24, John Ogness wrote: > Replace the open coded single linked list with a hlist so a conversion > to SRCU protected list walks can reuse the existing primitives. > > Signed-off-by: John Ogness Reviewed-by: Petr Mladek Just one nit below. > @@ -3229,32 +3244,30 @@ int unregister_console(struct console *console) > if (res > 0) > return 0; > > - res = -ENODEV; > console_lock(); > - if (console_drivers == console) { > - console_drivers=console->next; > - res = 0; > - } else { > - for_each_console(con) { > - if (con->next == console) { > - con->next = console->next; > - res = 0; > - break; > - } > - } > + > + /* Disable it unconditionally */ > + console->flags &= ~CON_ENABLED; > + > + if (hlist_unhashed(&console->node)) { > + res = -ENODEV; > + goto out_unlock; Nit: It might make sense to replace this with: console_unlock(); return -ENODEV; This is the only code path using the extra goto target. It is just an idea. I do not resist on this change. > } > > - if (res) > - goto out_disable_unlock; > + hlist_del_init(&console->node); > > /* > + * > * If this isn't the last console and it has CON_CONSDEV set, we > * need to set it on the next preferred console. > + * > + * > + * The above makes no sense as there is no guarantee that the next > + * console has any device attached. Oh well.... > */ > - if (console_drivers != NULL && console->flags & CON_CONSDEV) > - console_drivers->flags |= CON_CONSDEV; > + if (!hlist_empty(&console_list) && console->flags & CON_CONSDEV) > + console_first()->flags |= CON_CONSDEV; > > - console->flags &= ~CON_ENABLED; > console_unlock(); > console_sysfs_notify(); > > @@ -3263,10 +3276,8 @@ int unregister_console(struct console *console) > > return res; > > -out_disable_unlock: > - console->flags &= ~CON_ENABLED; > +out_unlock: > console_unlock(); > - > return res; > } > EXPORT_SYMBOL(unregister_console); Best Regards, Petr