Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp884494rwb; Wed, 16 Nov 2022 08:56:17 -0800 (PST) X-Google-Smtp-Source: AA0mqf50M4MsfdTnO95daY++UZw2I3IwdVmse+2yEAG0Ra9g045eml065rfhh/q/NdRYl3T0ENw2 X-Received: by 2002:a63:fa11:0:b0:461:8b6a:fe30 with SMTP id y17-20020a63fa11000000b004618b6afe30mr20664083pgh.267.1668617776818; Wed, 16 Nov 2022 08:56:16 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668617776; cv=none; d=google.com; s=arc-20160816; b=v8TQLKjsPAxmEKvMKH9jVxoytWmK+9wCQGQpEKj4CE1hBU8tGiAVzDcznt/87dk5P7 U5Kn00lsTSlTfvc6jasPi+Al9RmKzcvIND9VoRQrP22MhrBAwO+E5irRXG9q64Epd/+M nF5VI9n9H2Yx12sZBEYVCTeD8QaTQPryfBBBj3zJSSjoZ84iqLbPUvYVcPnfZhohTNUz VmkdWMZCtgg01YClZMg5QubI4CpMb9d2/6bi4Sg7Ac4H6jsvfiiICM+nSMMbk3PSObgl W3ggZODkoPt9OivGsaju6lfvJEeHQL9CbhUJEbBLgsKRI7DDcrpaJpCh4e0MvWnFrLD4 KgiA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:dkim-signature :dkim-signature:from; bh=XOHwuBaQ1W+3awwG2RAkUq8lXTwRKxgLO4vJVGnxlV8=; b=Q38s19SAUod7FG5/3PA/dmhpQJ/bpkigIdgfTchnE2Vxdr3od6JtPyBos+8k5L+F1F EYsIZtRz11AqX/RDQUeIU1+owMdzuRFjMZ+30MZqk1QqgT9mBu5lsljSyc4kZnt4cKYP x6N1MOfkecu0q2JagRtuQuy5diSwC2NvAKyfQjSDkF0O5VswHaDq3gFNUcW/LmOh7oNo 151HIMXNf5Goxr/Snv5HzHv+l9xpOcMQ3NEDkuv4FMTQiFO9pkCiTQ7pMsAy3C93BvYx Yp5eAjEn37+Pb56sEAdHLt+Hzx76smSz6hNK3LQJXiUqDzhrw+BV5siEau5F/NCEGvaX XuKg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=zwABEZ9m; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=s9R0LFz1; 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 y1-20020a17090a2b4100b00216616c5fc4si2121386pjc.166.2022.11.16.08.56.05; Wed, 16 Nov 2022 08:56:16 -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=zwABEZ9m; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=s9R0LFz1; 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 S238982AbiKPQZy (ORCPT + 91 others); Wed, 16 Nov 2022 11:25:54 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58746 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238085AbiKPQXE (ORCPT ); Wed, 16 Nov 2022 11:23:04 -0500 Received: from galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DAD3958BE3; Wed, 16 Nov 2022 08:22:15 -0800 (PST) From: John Ogness DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1668615734; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=XOHwuBaQ1W+3awwG2RAkUq8lXTwRKxgLO4vJVGnxlV8=; b=zwABEZ9mxonAyBNUeWB10LZTBQNhVUWXnM4uJOtaQ2YyZadMZ5Bi3atLrrsSkVEU/BnViB xAZVnMRA2dR8k2nO0aVndbNd46Y1KfXjZxNnIMCd0MWCLq21gTPYXnDQlH47HazQ4NDvNt wmcJ6p2S4E6O3pkDLBoS7eyHnNAg3KsSCoQvLEKQjz/CSbQe3nu6Pon8WzaivpF79mr26K BAILjyp28M6MufGbgldEQGXoQwcNvfSuPpzdX/UBg8mB6SWPRgUX+uX2ZRJIGeOWZIQXpE 2Z/4P+skN/oruOza9baWAElWHHWGDsIWdsfXNjTGDHR5DZfUdF7y4XpQqQEB6w== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1668615734; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=XOHwuBaQ1W+3awwG2RAkUq8lXTwRKxgLO4vJVGnxlV8=; b=s9R0LFz1ZdiHDzIlIEwfz6Uf9mV1b7pU/Ru3/LSGYsFj+6aDJGhMs03+ARyz6ujFNcaXLF WcI0pM16uwfwndDg== To: Petr Mladek Cc: Sergey Senozhatsky , Steven Rostedt , Thomas Gleixner , linux-kernel@vger.kernel.org, Jason Wessel , Daniel Thompson , Douglas Anderson , Greg Kroah-Hartman , Jiri Slaby , kgdb-bugreport@lists.sourceforge.net, linux-serial@vger.kernel.org Subject: [PATCH printk v5 35/40] tty: serial: kgdboc: use srcu console list iterator Date: Wed, 16 Nov 2022 17:27:47 +0106 Message-Id: <20221116162152.193147-36-john.ogness@linutronix.de> In-Reply-To: <20221116162152.193147-1-john.ogness@linutronix.de> References: <20221116162152.193147-1-john.ogness@linutronix.de> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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 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; already_warned = true; pr_warn("kgdboc_earlycon is still using bootconsole\n"); -- 2.30.2