Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp1948225rwb; Fri, 11 Nov 2022 02:53:19 -0800 (PST) X-Google-Smtp-Source: AA0mqf5lnnujg8cK4IUGt53aRF7HHal9Rr0paX3MsYcCg5Kpz9QUcYdkJaMk9K9c1N3tlzQf/XQp X-Received: by 2002:a17:902:8e83:b0:186:e68a:9aa8 with SMTP id bg3-20020a1709028e8300b00186e68a9aa8mr1956825plb.104.1668163999224; Fri, 11 Nov 2022 02:53:19 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668163999; cv=none; d=google.com; s=arc-20160816; b=zXk4mO8GqasliulywljoanoYZEDx0vfIyoFnt0zSfFpXO9ZkjakrOgIYpRbuAEXMRg okSgfEL9XjzrB/Gn6R3zG7aVAfP/7BIukazJiMGiflK2G+KIEEGOXP6PgNlw7EH94b6v sLYquT3USxCp1ljlv7IzMmZ27pTJGVZjVT/v3TipWiThYqLMZoyQ/5kGMIblPk42nvKb UYXsl2BdNeJck2wPWgXWnWubKAoMVk2mx1Ot004ua8IZMv3zNe2Cnquy8gcOEjP1bUVU /qA2IrOjDbBLob6aJDrHKKeN5MdSA+JoSqd1RPa8SMKIsyOghUGJTuMaMgH2bsOdtEzH cpHA== 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=zRnotCSwwpTe65f/KJdeiKaNSmLCv5EuT1e7hywId2U=; b=bR+wjDpm6X79EuXHcnmwTyaSsjmIlVkFPGg8bwZ4hnXO0ZMfK/YQsN9MqJh9jZY9ge pP/+yTFNK0q25J7c1dKxYKIKkWasJKZ++7gR/yRGjN1Mp1QDgo/iXLO+ScBk9+txDEmu 93uTCNO4uSJNnY9H9nPpIbHM5R/8o+DWI6Z/8mgUegAmLxfot4MPcPLNm3pmYp4FP09O V3m5U+ywLFCVjSRVEGaNxKzuMKHIqR5aJiBTnRE8eCkY3J6qdXgfCAQy5UfAK82lrxDx iydKZNVIFEwJpXje1+sOzaARNDkmxY/rLU57kDtZlVM3HPonyHdMwuPiWFsHSQt+HJG2 j1Kg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.com header.s=susede1 header.b=Hk6k65GZ; 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 p12-20020a654bcc000000b00470086d9f5esi2071201pgr.780.2022.11.11.02.53.07; Fri, 11 Nov 2022 02:53:19 -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=@suse.com header.s=susede1 header.b=Hk6k65GZ; 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 S233892AbiKKK2S (ORCPT + 92 others); Fri, 11 Nov 2022 05:28:18 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37460 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233876AbiKKK1m (ORCPT ); Fri, 11 Nov 2022 05:27:42 -0500 Received: from smtp-out1.suse.de (smtp-out1.suse.de [IPv6:2001:67c:2178:6::1c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 701D917596 for ; Fri, 11 Nov 2022 02:27:27 -0800 (PST) Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out1.suse.de (Postfix) with ESMTP id 02F6C22A78; Fri, 11 Nov 2022 10:27:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1668162446; 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=zRnotCSwwpTe65f/KJdeiKaNSmLCv5EuT1e7hywId2U=; b=Hk6k65GZEtfwzi/hIlqDUlb2hm9Hxrqyh57Yn5ppiolHk5skH8sH+Z4lMY9HZ0U37DIJ5L 5nbjZuys5QG/Hntq+WZMlYvK1ddoSmcnoUiI6tFm2PgEFPCIDLwgf1LS0OQwW7SbfZtQE3 ppHudoLNs6UjeVOPQUmgWnx+pDBdHBI= 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 A9E842C142; Fri, 11 Nov 2022 10:27:25 +0000 (UTC) Date: Fri, 11 Nov 2022 11:27:25 +0100 From: Petr Mladek To: John Ogness Cc: Sergey Senozhatsky , Steven Rostedt , Thomas Gleixner , linux-kernel@vger.kernel.org Subject: Re: [PATCH printk v3 39/40] printk: relieve console_lock of list synchronization duties Message-ID: References: <20221107141638.3790965-1-john.ogness@linutronix.de> <20221107141638.3790965-40-john.ogness@linutronix.de> <87r0ye916v.fsf@jogness.linutronix.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <87r0ye916v.fsf@jogness.linutronix.de> X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,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: X-Mailing-List: linux-kernel@vger.kernel.org On Mon 2022-11-07 17:36:48, John Ogness wrote: > On 2022-11-07, John Ogness wrote: > > @@ -3344,7 +3340,6 @@ void register_console(struct console *newcon) > > * Put this console in the list - keep the > > * preferred driver at the head of the list. > > */ > > - console_lock(); > > if (hlist_empty(&console_list)) { > > /* Ensure CON_CONSDEV is always set for the head. */ > > newcon->flags |= CON_CONSDEV; > > @@ -3358,7 +3353,6 @@ void register_console(struct console *newcon) > > } else { > > hlist_add_behind_rcu(&newcon->node, console_list.first); > > } > > - console_unlock(); > > > > /* > > * No need to synchronize SRCU here! The caller does not rely > > I just realized that because of the new @seq initialization (patch 5/40) > that we cannot completely remove the console_lock from > register_console(). It will still be needed for @seq synchronization > when registering non-boot/non-printbuffer consoles. So something like > the patch below will need to be folded into this one. Great catch! > I am not happy with this. If an enabled boot console is behind, the > console_unlock() will probably catch it up and we will end up with some > repeat messages. But maybe this is "good enough" until we implement some > real coordination between boot console and normal console takeovers. The same problem actually has been there even before. The new console was added in console_list under console_lock(). console_unlock() was called before the early consoles were unregistered. A solution would be to call pr_flush() before. But it should be done in a separate patch. > diff --git a/kernel/printk/printk.c b/kernel/printk/printk.c > index 17765166ac42..bb119001df56 100644 > --- a/kernel/printk/printk.c > +++ b/kernel/printk/printk.c > @@ -3328,12 +3328,21 @@ void register_console(struct console *newcon) > * that message instead. That boot console will be > * unregistered shortly and may be the same device. > */ > + > + /* > + * Hold the console_lock to guarantee safe access to > + * console->seq. > + */ > + console_lock(); > + > for_each_console(con) { > if ((con->flags & (CON_BOOT | CON_ENABLED)) == (CON_BOOT | CON_ENABLED) && > con->seq < newcon->seq) { > newcon->seq = con->seq; > } > } > + > + console_unlock(); > } This should be added already into the 5th patch that added this cycle. We just must keep it in this patch. Best Regards, Petr