Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp6848961rwb; Tue, 15 Nov 2022 04:40:01 -0800 (PST) X-Google-Smtp-Source: AA0mqf66Pye0JQAxd9hqfQSJiyqCQ3dCnCfdhGMENEaVaWlaDfPAmSxwJnWuH45VDvbvko/GySTQ X-Received: by 2002:a17:906:4d13:b0:78d:dddb:3974 with SMTP id r19-20020a1709064d1300b0078ddddb3974mr13315236eju.411.1668516000854; Tue, 15 Nov 2022 04:40:00 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668516000; cv=none; d=google.com; s=arc-20160816; b=Cl9YAG0bQkKdls332avEYcvkBT47fW6aPGxF5gPU+/QNJKtlGwJhWWxxSARYOJGdDX PRqD57tW6OWjvY4HedwSHurXkdXHVdZ+Stj/B1h5dzCo405HC/5dWmE2IhKr3sOdNW3H 0a9JEjhuRTvLrvGIOw+Skik6pUy9TdCukFUqIoRbN8fyt9YfseFKoHhFjzfPcyRCdVRt kQGznnP+efnDXcvMjELQbTcZfHFxZkCiQJZ85X8LI917eI3BUZICYucrArO1o7leHr5u oS3gdEKXso1Xp4YDhawAD1EjEkVLntlWPrE1M+LeFQjzB+tDZaZ/ZMGrqu38OVTTk2/b JP1g== 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=787wjDZOCndoyFt2mKQ1d7aZ2+xHAJpoA56kFzLmXlQ=; b=AVYlHhe8rt3IRAsYVhWLKjy3RqF5DTWGoj5z09hqim+Hu1ES8Q6cNyvHcEJGgkS44d YraQJt5EIHBKDJ+tEhmgdBBPEnVYPNZCZQhMFtIxObSksRAKy5D1ytB79eL8HehFKLFM gC7pCnQUPR/krhMSr8vWI3hH5MeSLVKWZWDLGWLn5tzuJF9OImyqLI/7p5SL7TPYQ7ee 5YVAXn9SmHmhJWBV0rVYJ6BnxnOPRcwtJhXDs9HaKRmWLMbvhnLXB+qf1zU/kLPFVEac 14LNwMvcIdduVhJzs19SmlZm1llaNodkrxAYEo95raE8RDLVVTEI3yly/GeebXKQVX3f FQFQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.com header.s=susede1 header.b=CuWLbwz0; 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 sg6-20020a170907a40600b007aeed47fca3si6344510ejc.475.2022.11.15.04.39.36; Tue, 15 Nov 2022 04:40:00 -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=CuWLbwz0; 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 S238293AbiKOMEo (ORCPT + 89 others); Tue, 15 Nov 2022 07:04:44 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54784 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238263AbiKOMER (ORCPT ); Tue, 15 Nov 2022 07:04:17 -0500 Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3084EFFB for ; Tue, 15 Nov 2022 04:03:31 -0800 (PST) Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out2.suse.de (Postfix) with ESMTP id 3F71A1F8B4; Tue, 15 Nov 2022 12:03:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1668513809; 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=787wjDZOCndoyFt2mKQ1d7aZ2+xHAJpoA56kFzLmXlQ=; b=CuWLbwz0Vpx5g2oOolZBnnZRoeokXfHLDVaQNE5CxrwqZ38l4wS7rk7eXcU1uOr0vqG6+J li3t4UPue1pzCXRN2WL7+IoddwlEdCDKdS3tGwjHDgZuDwLlAtcWHW1y1EIyvbFT5fnQf2 sYXPl2VPqt4Yhk0SmSM/aCuSMd6EtGw= 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 E170F2C143; Tue, 15 Nov 2022 12:03:28 +0000 (UTC) Date: Tue, 15 Nov 2022 13:03:28 +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> <875yfgo3k1.fsf@jogness.linutronix.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <875yfgo3k1.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 Tue 2022-11-15 12:39:18, John Ogness wrote: > On 2022-11-15, Petr Mladek wrote: > > 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. > > hlist_del_init_rcu() does not prevent the rest of the list from being > seen. It only unlinks @pprev for future iterators. I see. I looked at hlist_del_init() instead of on the _rcu() variant. hlist_del_init_rcu() is correct here. > > 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. > > For console_force_preferred_locked() it was about making sure that the > console always appears registered, even though it is temporarily removed > from the console list. > > For unregister_console() we want it to be seen as removed from the > console list. Makes sense. Best Regards, Petr