Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp6730189rwb; Tue, 15 Nov 2022 02:57:42 -0800 (PST) X-Google-Smtp-Source: AA0mqf7UU8iY248VK9Sn02RnuT/ehp+hsAxRIxNOXvcfmNSxPmcer+PjTkhtqHGYWMeAuFRND1kY X-Received: by 2002:a17:906:1d47:b0:78c:fda3:c025 with SMTP id o7-20020a1709061d4700b0078cfda3c025mr13536669ejh.461.1668509862462; Tue, 15 Nov 2022 02:57:42 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668509862; cv=none; d=google.com; s=arc-20160816; b=S4qUySYvVceMthtEF+zY8mNHGhe147/wfZXbqJSo+PV73t0Q3OpJ+6B4g+JE7olws/ RB/78/MBSNYp2CwqXSlsCgNMHC2HjJYmt4Hky6GOf/zRlH9XUBesvJ135Ff9fSUjQ/rG aM3hQ5/urSV9nPt/YDXZnrmIMaMwVMHIZXUPPGpQMoSpORh6YYWPuChVeNAnl3K7kxI8 iGoY7C3MRIg+RGStSAorXFLUbOQ+NAy+SCRIDnEw9VCgX1+rlFjqsZwEO4uhUsBXH/dS qogoMj8ZWGTgr0w45gIgOq8Y7Iatd82BAsTVcQfzvcp+FdROGde7c3BmrKZ4wYrPi2Q9 clpg== 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=/FTzh3IqYnsvgJzPb6LH/DCDSa8tDLbBI2Cl4le4c+k=; b=D20h2ojZoRzpCp5YIJ1N7ovvj3H+fxNSOLOuUp0urhBjtxu65lsHPBuLXqkscoENGv vEoPtd5/cevBR9l6+O6WGUOfsAH0y7oVn78kmljpEcFXyjN3J8QAD76dVPsfI8rqvT/A wsmLg+L8XgpmRZOxlfHlKKEirF8eesdyQaRPLPxt4gRGW8HvHOsNm0VNvTqKMoI73RUh DZisipMVdYmczwxqYk/e3FolAonp9Tiqy4+MRqC+F9S8Yt7ZmgLpiGjKeNxmC/xWy3rJ CrSEORtdH5qdFQ21r86yuO3BnxKSthiWlAefXwDFw4rk15GV65hThJAMt/toyFHPD+SS tiPg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.com header.s=susede1 header.b=clQHvMuY; 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 hz3-20020a1709072ce300b007acc6769292si11375624ejc.365.2022.11.15.02.57.20; Tue, 15 Nov 2022 02:57:42 -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=clQHvMuY; 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 S238471AbiKOKvn (ORCPT + 89 others); Tue, 15 Nov 2022 05:51:43 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59496 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232690AbiKOKuz (ORCPT ); Tue, 15 Nov 2022 05:50:55 -0500 Received: from smtp-out2.suse.de (smtp-out2.suse.de [IPv6:2001:67c:2178:6::1d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6D6C321E23 for ; Tue, 15 Nov 2022 02:50:35 -0800 (PST) Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out2.suse.de (Postfix) with ESMTP id 21BD81F8B5; Tue, 15 Nov 2022 10:50:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1668509434; 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=/FTzh3IqYnsvgJzPb6LH/DCDSa8tDLbBI2Cl4le4c+k=; b=clQHvMuYUmo0CX84Qp1eGE9cTD09zVwxq2prklM6iZ2FuKryLC4kXT5f0w90oG64MeRI+F UB9sh+z2SnRCSwxkI74rIZ5IhTuUP5U+6SuSaX+0Pg6aUQnY+RsEs7HXniFUVW22u6MFU0 QgmZMnc6/95IeIQlaUHA/yeX1+w9ISs= Received: from suse.cz (unknown [10.100.201.202]) (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 C19E82C142; Tue, 15 Nov 2022 10:50:33 +0000 (UTC) Date: Tue, 15 Nov 2022 11:50:32 +0100 From: Petr Mladek To: John Ogness Cc: Sergey Senozhatsky , Steven Rostedt , Thomas Gleixner , linux-kernel@vger.kernel.org, Miguel Ojeda , Greg Kroah-Hartman , "Paul E . McKenney" Subject: Re: [PATCH printk v4 03/39] printk: Prepare for SRCU console list protection Message-ID: References: <20221114162932.141883-1-john.ogness@linutronix.de> <20221114162932.141883-4-john.ogness@linutronix.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20221114162932.141883-4-john.ogness@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-14 17:34:56, John Ogness wrote: > Provide an NMI-safe SRCU protected variant to walk the console list. > > Note that all console fields are now set before adding the console > to the list to avoid the console becoming visible by SCRU readers > before being fully initialized. > > This is a preparatory change for a new console infrastructure which > operates independent of the console BKL. > > --- a/kernel/printk/printk.c > +++ b/kernel/printk/printk.c > @@ -3254,7 +3303,7 @@ int unregister_console(struct console *console) > return -ENODEV; > } > > - hlist_del_init(&console->node); > + hlist_del_init_rcu(&console->node); This should be hlist_del_rcu() here so that a list walker that it just processing this console could see the rest of the list. It seems that hlist_unhashed() checks only node.pprev pointer so that we even do not need to initialize it. We discussed this in v3 in the patch implementing console_force_preferred_locked(), see https://lore.kernel.org/r/Y20aBwNWT19YDeib@alley. I forgot that unregister_console() might have the same problem. Best Regards, Petr > > /* > * > @@ -3269,6 +3318,14 @@ int unregister_console(struct console *console) > console_first()->flags |= CON_CONSDEV; > > console_unlock(); > + > + /* > + * Ensure that all SRCU list walks have completed. All contexts > + * must not be able to see this console in the list so that any > + * exit/cleanup routines can be performed safely. > + */ > + synchronize_srcu(&console_srcu); > + > console_sysfs_notify(); > > if (console->exit) > -- > 2.30.2