Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp6790193rwb; Tue, 15 Nov 2022 03:52:40 -0800 (PST) X-Google-Smtp-Source: AA0mqf5S9sJkyZgzmbWwBGOW2U2/UiuFK1B6UDoiuIZoMRJ8Cij6BndwNbIkgS2D9KdYQ4TQ4/jw X-Received: by 2002:a17:903:32c8:b0:186:9c70:9b7d with SMTP id i8-20020a17090332c800b001869c709b7dmr3730654plr.3.1668513159800; Tue, 15 Nov 2022 03:52:39 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668513159; cv=none; d=google.com; s=arc-20160816; b=iQsH+QKHjXO5JffMCybknD1Uop4uflfikRAzd3o/XT8dLImXJ0vUCwIfNim2dgHmnB /VyQdEIRJdZmAPvd9YmQVSpONOq+w0iyonJbQFIaUJDLWjGuVSFYcWAMKTUItK+0/qLx CvOMub0Cj0vgtQL61UVdivJ1YsFH2rKiOd4x/hhBGkzV2bFgYL1L/+8qZbbxLMBHWRGj yZnRQ9yzptN2MvckKby29BcFnF+QdBZ2t1nZnJa+jldMYRPfn7XPTRh+7fwpAWZJ2K+z p24HfC6hSXegMNHET88GN2l/8t+vg0OuS6fcPTVgAISvgVmx+qaZ+NuZmV425v2k1P12 oQOA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:message-id:date:references :in-reply-to:subject:cc:to:dkim-signature:dkim-signature:from; bh=84NxScZ/MpXsb6BzINZ3D5GdsaYfcLEsVFFGhZDaqNs=; b=UVe5K9FtipxR3Ge3berWzvAuC8M+ec/g4BoWBDJJ1vykdBLh8XAveNaDcrxhGwau+7 cNsqH/x4sR1tnNHW8Odr3orcKKJ+TeYGhcMV0w1lli0RcnYgSPEz6eNUBAZ37OSZuWzV YxwbNjj4gOhxgpWFx5qy3uexGYyxyySGS+AW0/2++l2nabcCZXhkbv6X2TQlB4vHtYar BQ9e/7pEQ0H40S/cvLfEIYwI0aVGlipSlk5Ad4fZ2NaGFnY1sOcu0RmGRBPxqYZBu8Qn +kSxKcyL0Bb7D9lxi60mz+2b/4LkmCf9yMY46BXIBVLRskOGx5MUhBu9LOx1dma2m0U9 3oEw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=ts5xpglo; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id z17-20020a170903019100b00188d23093e8si2671436plg.319.2022.11.15.03.52.28; Tue, 15 Nov 2022 03:52:39 -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=@linutronix.de header.s=2020 header.b=ts5xpglo; 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 S237972AbiKOLei (ORCPT + 89 others); Tue, 15 Nov 2022 06:34:38 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37322 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237845AbiKOLeL (ORCPT ); Tue, 15 Nov 2022 06:34:11 -0500 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AE3AD27FE3 for ; Tue, 15 Nov 2022 03:33:21 -0800 (PST) From: John Ogness DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1668511998; h=from:from:reply-to:subject:subject: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=84NxScZ/MpXsb6BzINZ3D5GdsaYfcLEsVFFGhZDaqNs=; b=ts5xpgloRXL6Bunef+ZM/bPFUqmdLJR9Fj0gjVcG20l9/BfANk1rz82SZRCUgQBgX//850 Ap8HafTsPFCj2AZHXPDPDECyWxITIwYNjLlyZjk+vNMGyA6YiXfGcyISY7CF+L74gx8zjF 4vIZkUAgwW+wI3Mxq2O4of7SB6H3KQV6gjlB02xGpAwHEYy+OVvZNvV7J2jnfwQZQN/hsm jEB9UlqjTJ+5sI917o0GbbI6iSCAxrzY594W+Usbq0C4XkPco6HrTnk/seqmXyYJOPgwGz FD8Wl6tTIwTT395I1vX0WbWGVFAPljWiELKwlWH3JJebNigzm9l/v5W9A4dsOA== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1668511998; h=from:from:reply-to:subject:subject: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=84NxScZ/MpXsb6BzINZ3D5GdsaYfcLEsVFFGhZDaqNs=; b=fDpUTw9c7fbDdNnYcH2Vuqv+sl7xjT616YBgKGInE1iEr7jAFZA1j8ks1dC3zwkU+1T7Lr 2PYhwVIbuP7HqNAA== To: Petr Mladek 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 In-Reply-To: References: <20221114162932.141883-1-john.ogness@linutronix.de> <20221114162932.141883-4-john.ogness@linutronix.de> Date: Tue, 15 Nov 2022 12:39:18 +0106 Message-ID: <875yfgo3k1.fsf@jogness.linutronix.de> MIME-Version: 1.0 Content-Type: text/plain 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: X-Mailing-List: linux-kernel@vger.kernel.org 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. > 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. John