From patchwork Mon Nov 14 16:29:27 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Ogness X-Patchwork-Id: 19909 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp2239979wru; Mon, 14 Nov 2022 08:34:47 -0800 (PST) X-Google-Smtp-Source: AA0mqf6zvwpGSndoimTDUQ3dNbrwsFYJrGmarIpVZW/768ykx/Qa1pvkWCrBBg5RcMi7NY1AYbnv X-Received: by 2002:a17:906:1458:b0:7ae:d8f:893c with SMTP id q24-20020a170906145800b007ae0d8f893cmr10533598ejc.359.1668443687322; Mon, 14 Nov 2022 08:34:47 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668443687; cv=none; d=google.com; s=arc-20160816; b=ISX5cXBItH9pPzc5RAdTqoF6RL+m0JUbFj3vf3sNEyKOP8a61H3/Bw5RZd75cLyxC7 eDtJd/FcINHFRA369dEzrSKy4CRDHhbkGZMeLVHYtkMPjQsrGGxVVu7f6Z1zDiofe9Be igOokb4OfREBYJXByxeqDNRwff+G+CqwN63YRlqbEwDHRD50HG1emSChTj0YBlNHEK04 1vxuXzZWeghzRDff3wzNrPTXhc+JpA8DAaKonVhI5i8DPVDJVBj0iUHTJiATcg6vCP72 UkZNnDwprBp2NlZQ8k4g4GlLImzEpl6FJEvC471iO8mzw+tHaagmDkyWniThhiy5iKah tUOA== 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=2wDn6g+8UuBdFK6wWrlxzslZkfyRUaJ6YAvy13J2JzM=; b=OhbG2tcFtcttqOm8oJreo0HtRjYL6uWQbHgavqXeWMIxo9H1z7i49BW5twusnYsDMR Ts0EuHSiJdt2rpgLeLkDKb+ftxYKPAn1AbMmSTZGa33+t1XjV+hCD2MksaH0nkqUX789 OUIdcY8ejLwBea+ZXLdpopM2gaI0DldgiO9HzAfb7QINQS/yWSnmBc4/X3HeQ3rrQxod ExwgipMDU2v8oo2aO1N42fBjPpAxgB1sHWK0resyagwY2wFiZa0/QxI4AP6Hrvh19qXj ePs8z1JIsRJgZb+K9F5QD8OEPKU2YiFAZM4pPFM/TjFwT25j84Iw56JxwM4yyowesi5n WPUA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=BImf087f; 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: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id v14-20020a170906b00e00b0078dec48d442si7275030ejy.680.2022.11.14.08.34.02; Mon, 14 Nov 2022 08:34:47 -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=BImf087f; 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 S237722AbiKNQbh (ORCPT + 99 others); Mon, 14 Nov 2022 11:31:37 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38690 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237700AbiKNQau (ORCPT ); Mon, 14 Nov 2022 11:30:50 -0500 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id ECB652F031; Mon, 14 Nov 2022 08:29:50 -0800 (PST) From: John Ogness DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1668443389; 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=2wDn6g+8UuBdFK6wWrlxzslZkfyRUaJ6YAvy13J2JzM=; b=BImf087f9JnZ88MWf7ANkPfWPNC7L78l8GKfPWaZ1afRJ+A+JBuMrpM8D1Ka321WprAnA3 EGloFZFKdW72lAGMkaKfGh8DjWcnX/CaE/PiSwUMI6Ev+J+j0YujoKIAviukaNA6BNfXG6 vZQKB3mcJni3b4fbuzwdnXl0zvRf10T9m37lJxrHpv2cksUNBagpZ2TxbYiXBkkwN8uGFR QmO4TI8BuMPRs08ILB69SI8eB5ifJwO3XFa/Na0Ps0ULOqzEpXNv/aY2+GJpk5tnowTx8g lQWj2mP+9P3cjsdwI04CGBTnOSDytJN+t4szjXImS/5DCyylCW1RsCBuFWAI7g== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1668443389; 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=2wDn6g+8UuBdFK6wWrlxzslZkfyRUaJ6YAvy13J2JzM=; b=1WUe4EQRUuyC882lbN52LVmxM2UtRXMjNbX4zkjqflQk4DO03Am6ce06RfjNxTxnINegur l44TkJN3V9duhpDA== 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 v4 34/39] tty: serial: kgdboc: use srcu console list iterator Date: Mon, 14 Nov 2022 17:35:27 +0106 Message-Id: <20221114162932.141883-35-john.ogness@linutronix.de> In-Reply-To: <20221114162932.141883-1-john.ogness@linutronix.de> References: <20221114162932.141883-1-john.ogness@linutronix.de> MIME-Version: 1.0 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1749490007958629693?= X-GMAIL-MSGID: =?utf-8?q?1749490007958629693?= 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");