Received: by 2002:a05:6358:1087:b0:cb:c9d3:cd90 with SMTP id j7csp8666670rwi; Tue, 25 Oct 2022 09:20:12 -0700 (PDT) X-Google-Smtp-Source: AMsMyM67sgRmTwyVBtgthm1KN057BxM3huv3b9bkdMC/qc/cCHtIdZ2eCGArKfdBvDRt2hO72EjN X-Received: by 2002:a05:6402:278d:b0:461:60d4:8ea4 with SMTP id b13-20020a056402278d00b0046160d48ea4mr19830258ede.419.1666714811954; Tue, 25 Oct 2022 09:20:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666714811; cv=none; d=google.com; s=arc-20160816; b=lPH+GkW/nOFGWoUDOMoKL9cb3MC4z9WvBXtO/Fv170CSiz/BG8cI4Ox+I3OAIATY5j iJ5YiC4cDaxM43/LxU8Q6IgaTJqrmT/qVhlOqLXeLWxNQbkEzJXZghT3t09e9Q/br2+0 MRHztx7AI7Fe8EgZF5pzyUAylowe83cI9gNwhKGttpXMtDUqau9ib8atiwNR4zR2UJhG /g/S9MxdXMwoFZq3ckUVZEZPvc9GK8Ok9PjgBAmi+62PxZKZLWZA3bM4yupP8fXP+F1B u1AJs4qTc+nrKeWsVT8TlZLJ8t1LkqfY7gffCP+iH7o8gRKdeTgChTy4iBG3zVi4217x 6IKQ== 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=0OnjWi2pdEy4n7cmfWwSconN2E9bcsinJA3k/vOB3j8=; b=sHl7JxwLQmuvGGp9aB0QUAYw5De4G2uC09JurUUtJ5MOUvHzcg8pn4e77KBOH72dZs qzRp0d2Dhski96DlxLG+DAIPVxv/MN8M24bxtihPojbE3xpY1xTIF7bY37B1CwROqLP/ IxuveQKdUiX9ebNI9GX3gXic07gZUIovubxwzLU0F7XEwbyBCyXIfe5LDKsnM9ki25zE lPNJmVLLg+PpZFqjyajJwIBE/wa34xFBcF1zQq9elfhcHVZmwIB4tjIYd/m73GQynefP 3LIKJ1/9PhAoyvi+EFmdDwkE62bWyVxt/Oz9AsULqTwGugy9JMIQKlwzpeOhcBjxof95 3beg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.com header.s=susede1 header.b=Bi1oUHuh; 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 he9-20020a1709073d8900b0078e54eda758si4051947ejc.611.2022.10.25.09.19.45; Tue, 25 Oct 2022 09:20:11 -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=Bi1oUHuh; 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 S232282AbiJYO7s (ORCPT + 99 others); Tue, 25 Oct 2022 10:59:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39404 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231352AbiJYO7q (ORCPT ); Tue, 25 Oct 2022 10:59:46 -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 C637BE55 for ; Tue, 25 Oct 2022 07:59:44 -0700 (PDT) Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out1.suse.de (Postfix) with ESMTP id 0E04B21FEE; Tue, 25 Oct 2022 14:59:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1666709983; 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=0OnjWi2pdEy4n7cmfWwSconN2E9bcsinJA3k/vOB3j8=; b=Bi1oUHuhLNJkMqAAT63Md2prAKktFZVVGkXOzu9qROi0Bdaf1vvw5UL4KVunD3eEI5jq6f GHfIq5RXCZz68W80UEQ6EKYzDtPI/GLOX14CT77FWtITKpe8z0dmgwg7dlu6sUMU+Gsbht Zs8XwXnA11RSgttxqYJBtCOJC+LxFLs= 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 9F55D2C141; Tue, 25 Oct 2022 14:59:42 +0000 (UTC) Date: Tue, 25 Oct 2022 16:59:42 +0200 From: Petr Mladek To: Doug Anderson Cc: John Ogness , Sergey Senozhatsky , Steven Rostedt , Thomas Gleixner , linux-kernel@vger.kernel.org, Jason Wessel , Daniel Thompson , Luis Chamberlain , Aaron Tomlin , kgdb-bugreport@lists.sourceforge.net Subject: Re: [PATCH printk v2 26/38] kdb: use srcu console list iterator Message-ID: References: <20221019145600.1282823-1-john.ogness@linutronix.de> <20221019145600.1282823-27-john.ogness@linutronix.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: 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 Mon 2022-10-24 17:47:25, Doug Anderson wrote: > Hi, > > On Wed, Oct 19, 2022 at 7:56 AM John Ogness wrote: > > > > Guarantee safe iteration of the console list by using SRCU. > > > > Signed-off-by: John Ogness > > --- > > kernel/debug/kdb/kdb_io.c | 5 ++++- > > 1 file changed, 4 insertions(+), 1 deletion(-) > > > > diff --git a/kernel/debug/kdb/kdb_io.c b/kernel/debug/kdb/kdb_io.c > > index 550fe8b456ec..5c0bd93c3574 100644 > > --- a/kernel/debug/kdb/kdb_io.c > > +++ b/kernel/debug/kdb/kdb_io.c > > @@ -545,6 +545,7 @@ static void kdb_msg_write(const char *msg, int msg_len) > > { > > struct console *c; > > const char *cp; > > + int cookie; > > int len; > > > > if (msg_len == 0) > > @@ -558,7 +559,8 @@ static void kdb_msg_write(const char *msg, int msg_len) > > cp++; > > } > > > > - for_each_console(c) { > > + cookie = console_srcu_read_lock(); > > + for_each_console_srcu(c) { > > Maybe it wouldn't hurt to also have a comment saying that normally the > console_srcu_read_lock() wouldn't be enough given that we're poking > into each individual console and calling ->write() but that we're > relying on the fact that all the other CPUs are stopped at the moment > and thus we should be safe. True. I guess that the SRCU lock is not really needed from the same reason. Well, the SRCU walk makes sense. It makes sure that the list can be safely traversed. I mean that pointers are updated and read in the right order with the right barriers. Yes, it would be nice to add a comment. Best Regards, Petr