Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp1415508rwb; Wed, 16 Nov 2022 17:39:59 -0800 (PST) X-Google-Smtp-Source: AA0mqf6r1ECuPaZttO6ZGcme0hByzRMRC3b4I05Gms5Poa+BbG4Yy8cnoyJhBhxgnFxZZTPMhVwE X-Received: by 2002:a65:6d95:0:b0:46f:f482:6920 with SMTP id bc21-20020a656d95000000b0046ff4826920mr47070pgb.327.1668649199633; Wed, 16 Nov 2022 17:39:59 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668649199; cv=none; d=google.com; s=arc-20160816; b=Cqo8ZB5ePnamEPOtt1o6a7K4SbUlPRplJ3RQ5PmHycllncZtiHkffHqHuzLNdGuiqr zd0zIj2Bvw0BVun1sHcqhGkCqq8258c/HMaPvcfRlssYAm0+GNG+bpRqUIq5ojSDx45s 9LH7jhZ4zUcPCMXmFDe7VnLdIuRhL9uFYmHfZON7V8wAdbXAPIGsUaMOdbY3F+GmBJGO bigu0YLzNSoaaB+scoBE1tkkReqL57JZ1vCMuTnTtOYci3NSetcL4hifSUEzshNipCnm KhcYgXm4CEn+XcSVedbzQS8m/0gbxHNry4JriP4L2hhD9mg4Lmsj0H6weWam7XgpQKgl c2Tw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=7IItaZa/7I4VBu5cw0wrKUsh/hbQDFMwGlkpESbfAao=; b=LRaFrouxjDz5KCkP6ckaQtn7KrD9hIfxF1+7ey3VpsxhCIyNj7jtbg6BZPQoRVQfeQ 0VmkD+siy+AdN08xj8iqCF5f1iMJnrnwzEKsosemQ2jeImkFRAskc7WeI0dn1XT8sXNj YlQkyMiwaIgtclOXFaNTYsXSRUUUNwY+kyO+G7SZCu8Mppf0ZNziZptnESjLWe29EfDp e8uhzv4bFEJidR1qrzAoFDTwd8fp/Z4tAnOIOkFZAT4vW7g/LLU36COSJe1JezWKgVlu LLQ8qeEvBZV5Pa98Haio+x6O320B2PSxrM/nQhvm49ZTP87wDYs8GCb6SQdLKAFf1mMa ew0w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=HAD+QNbZ; 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=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id f12-20020a63dc4c000000b0045f7fc4b812si16313146pgj.295.2022.11.16.17.39.48; Wed, 16 Nov 2022 17:39:59 -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=@chromium.org header.s=google header.b=HAD+QNbZ; 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=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234704AbiKQBAH (ORCPT + 90 others); Wed, 16 Nov 2022 20:00:07 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49602 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238704AbiKQA75 (ORCPT ); Wed, 16 Nov 2022 19:59:57 -0500 Received: from mail-ej1-x629.google.com (mail-ej1-x629.google.com [IPv6:2a00:1450:4864:20::629]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1C7A06AED4 for ; Wed, 16 Nov 2022 16:59:51 -0800 (PST) Received: by mail-ej1-x629.google.com with SMTP id f18so1363761ejz.5 for ; Wed, 16 Nov 2022 16:59:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=7IItaZa/7I4VBu5cw0wrKUsh/hbQDFMwGlkpESbfAao=; b=HAD+QNbZhmm80gWWfMxazQiOdxU/8OoWGwpppi16ividblCxYrow2hz0E0zZ7AhQ0z cJqUTprf41aF4MbLXaLFlbvRQJVq6IL9gsK+Kqxa/h2queVIuT30rA6VyDlCgXIBzNyT qslBCis6l11GbiAG8lz7dScccivWN8QaYUE08= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=7IItaZa/7I4VBu5cw0wrKUsh/hbQDFMwGlkpESbfAao=; b=WrgqmdoB6xx6tUc6fVs97/EHR6SdTPwaOmgwkUuVtq8tJrMUCy7h5fc6wFjnptu1QF nL6b16KDnCw5K/g4WgQMWJ+v/tRwOGnZHUOTuHfARBbVhDOAb6cCx0xnIS8AomVeAMFI /UDSpwmRJqWzC0CRxuX0YznJW3hEkVJ0bXDIUsaiIJyCGr/FpLc3KHUpa2wGnwbazIb6 1Gs4KlEpspwvwqsLT8EHMWZdw7YrJ9IECGNeRJ9TuonuhGNdK3qFLIFGS6x/2Zk8Ya58 RN+alphoQ3FkBXKeI5WnHrgoWep9yPXtYleJU1aN6MHKKD3LRfEWiGtjDKgJ+H7ZdNp1 TyGA== X-Gm-Message-State: ANoB5pkL76NGUwpeysFtIPqGe5kaLnF0u2kxXwjKq2jwO0F++ffPsS/o V37mf37pHI+58Ji+MkvmZUoTR7itwoA3nakW X-Received: by 2002:a17:906:a418:b0:7a5:e944:9e48 with SMTP id l24-20020a170906a41800b007a5e9449e48mr323674ejz.109.1668646789331; Wed, 16 Nov 2022 16:59:49 -0800 (PST) Received: from mail-wr1-f52.google.com (mail-wr1-f52.google.com. [209.85.221.52]) by smtp.gmail.com with ESMTPSA id 13-20020a170906318d00b007822196378asm7574170ejy.176.2022.11.16.16.59.47 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 16 Nov 2022 16:59:48 -0800 (PST) Received: by mail-wr1-f52.google.com with SMTP id z14so410229wrn.7 for ; Wed, 16 Nov 2022 16:59:47 -0800 (PST) X-Received: by 2002:adf:fb4c:0:b0:236:5270:735e with SMTP id c12-20020adffb4c000000b002365270735emr35889wrs.659.1668646787360; Wed, 16 Nov 2022 16:59:47 -0800 (PST) MIME-Version: 1.0 References: <20221116162152.193147-1-john.ogness@linutronix.de> <20221116162152.193147-36-john.ogness@linutronix.de> In-Reply-To: <20221116162152.193147-36-john.ogness@linutronix.de> From: Doug Anderson Date: Wed, 16 Nov 2022 16:59:35 -0800 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH printk v5 35/40] tty: serial: kgdboc: use srcu console list iterator To: John Ogness Cc: Petr Mladek , Sergey Senozhatsky , Steven Rostedt , Thomas Gleixner , linux-kernel@vger.kernel.org, Jason Wessel , Daniel Thompson , Greg Kroah-Hartman , Jiri Slaby , kgdb-bugreport@lists.sourceforge.net, linux-serial@vger.kernel.org Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, 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 Hi, On Wed, Nov 16, 2022 at 8:22 AM John Ogness wrote: > > Use srcu console list iteration for safe console list traversal. > Note that this is a preparatory change for when console_lock no > longer provides synchronization for the console list. > > Signed-off-by: John Ogness > Reviewed-by: Petr Mladek > --- > drivers/tty/serial/kgdboc.c | 10 ++++++++-- > 1 file changed, 8 insertions(+), 2 deletions(-) > > diff --git a/drivers/tty/serial/kgdboc.c b/drivers/tty/serial/kgdboc.c > index 5be381003e58..c6df9ef34099 100644 > --- a/drivers/tty/serial/kgdboc.c > +++ b/drivers/tty/serial/kgdboc.c > @@ -451,6 +451,7 @@ static void kgdboc_earlycon_pre_exp_handler(void) > { > struct console *con; > static bool already_warned; > + int cookie; > > if (already_warned) > return; > @@ -463,9 +464,14 @@ static void kgdboc_earlycon_pre_exp_handler(void) > * serial drivers might be OK with this, print a warning once per > * boot if we detect this case. > */ > - for_each_console(con) > + cookie = console_srcu_read_lock(); > + for_each_console_srcu(con) { > if (con == kgdboc_earlycon_io_ops.cons) > - return; > + break; > + } > + console_srcu_read_unlock(cookie); > + if (con) > + return; Is there truly any guarantee that "con" will be NULL if for_each_console_srcu() finishes naturally (AKA without a "break" being executed)? It looks as if currently this will be true but nothing in the comments of for_each_console_srcu() nor hlist_for_each_entry_srcu() (which it calls) guarantees this, right? It would be nice if that was documented, but I guess it's not a huge deal. Also: wasn't there just some big issue about people using loop iteration variables after the loop finished? https://lwn.net/Articles/885941/ Ah, I guess that's a slightly different problem and probably not relevant here. So it seems like this is fine. Reviewed-by: Douglas Anderson