Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp5739046rwb; Mon, 14 Nov 2022 08:48:46 -0800 (PST) X-Google-Smtp-Source: AA0mqf5QqWYZP2sGXPDcfhyVCffUYfWyUjj0NfMTSisxyU6X1sPbu6rC2JDnLCQfcRsKoMQ9np3n X-Received: by 2002:a17:90a:bf87:b0:212:d404:5513 with SMTP id d7-20020a17090abf8700b00212d4045513mr14576417pjs.27.1668444525790; Mon, 14 Nov 2022 08:48:45 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668444525; cv=none; d=google.com; s=arc-20160816; b=esawLeexK7nmj43DhYTDlvAeWN0/DwbegVUcFCHJ8NeVCZMZzW2ErOrnUxLmK3IRU0 P6tCeuUBeJac0OjoYus1HOBrzR+O+PVUO9ONwPA8YbNZaMN+k4EaODSiGV89CC8hNjk7 2/4YS9RG9027UzUwttiVbLQiEDSZFXER9akL98lAmDHsf9aoX9+OCxcYyBdI3U18JImT uPxE2PQsM6f/AG5n7O+GmU86YFqkRqDfQRzg8/xTn+uqNK787Q20QrZqq11TuS1Qqagl iHwNAaKRqZu6gOwXwqr0RXKsw0p+5g5JxSETOGtInILrr+0imuF/gAJURzEMlE64Gneg nfXw== 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=GEhKO0dJc2f16pdA5isP3tyKiWxAMb8gJwHLg9bJtvU=; b=I4avksfeFSio7DoQ3Qnd9VzTlUYnwkKt7GvmFNZQdgWg5F+7PUCXGvhVf5eJznSZfW 9ErVk3JdZaym9m8YH+6w2Bb7eOwkVKN5CyYBlX37JiX7QRCqcbDri7Su3DvyfFvvPZ6Y T7uuN1ETZa1WB3hVg18giBUIB95ami5x/sZLObq6i3xrQpWegDJT+qAcRuXCLgJKLbjp F69fJcDPl+e5rQp3ap9tBcHc+Vue/o0aFPK2EINmdE7BhMiJC7sS62n6gxmfPvREH8Fn u9p+jUJGkTNF6zTT7KfdQqwkWsvoU6tLc9TZZNViLa/iNvGm/UJvVtZ/dkGPHdPTdoEQ ZM/g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=fED6VtmD; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=X+VenatF; 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 j16-20020aa79290000000b0056e41e4272dsi8430381pfa.315.2022.11.14.08.48.34; Mon, 14 Nov 2022 08:48:45 -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=fED6VtmD; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=X+VenatF; 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 S237620AbiKNQaX (ORCPT + 87 others); Mon, 14 Nov 2022 11:30:23 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35626 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237537AbiKNQ3l (ORCPT ); Mon, 14 Nov 2022 11:29:41 -0500 Received: from galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2BA13102C for ; Mon, 14 Nov 2022 08:29:41 -0800 (PST) From: John Ogness DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1668443379; 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=GEhKO0dJc2f16pdA5isP3tyKiWxAMb8gJwHLg9bJtvU=; b=fED6VtmDED6MuLvYHCpr7jg0s8uQ4ubFuV+VJrDBURlb+sRmrPLVdZhbCg7C9vkvldCcZC O3jnP3sS40Xc/9Nl61qOPe4tQo5M701OfeqSfviyYjbM9aVF5lpkSd4rH9cAes5ZiqmRXV qSC0fmcpzoHohSsnvCqpR2jm74hLpeXfas4Urmb+nz47yUrVVMWUckuYe0K6QhSQ0thxYe Do4tLzYO/CeZJ4lQo1ewHWpTh8mj47O/uroIOAzyntCZsQtDNfsDD/JIDWJTssmb6VX7O6 7zwiYUW4aXXfoFUuEEQfPo3tGoBVRNEWeL66ULaqMgc89bm5V3SqUuiZVWBb3A== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1668443379; 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=GEhKO0dJc2f16pdA5isP3tyKiWxAMb8gJwHLg9bJtvU=; b=X+VenatF4kHSWTowXfqC0zSVEJludzZYKhc6X1KeZyez9dy82GgAGpy+a7Avhfw9vUOvoe nAz42aPySqUAAZDA== To: Petr Mladek Cc: Sergey Senozhatsky , Steven Rostedt , Thomas Gleixner , linux-kernel@vger.kernel.org, Richard Weinberger , Anton Ivanov , Johannes Berg , linux-um@lists.infradead.org Subject: [PATCH printk v4 12/39] um: kmsg_dumper: use srcu console list iterator Date: Mon, 14 Nov 2022 17:35:05 +0106 Message-Id: <20221114162932.141883-13-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 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 Rather than using the console_lock to guarantee safe console list traversal, use srcu console list iteration. Signed-off-by: John Ogness Reviewed-by: Petr Mladek --- arch/um/kernel/kmsg_dump.c | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/arch/um/kernel/kmsg_dump.c b/arch/um/kernel/kmsg_dump.c index 40abf1e9ccb1..427dd5a61a38 100644 --- a/arch/um/kernel/kmsg_dump.c +++ b/arch/um/kernel/kmsg_dump.c @@ -16,29 +16,26 @@ static void kmsg_dumper_stdout(struct kmsg_dumper *dumper, struct console *con; unsigned long flags; size_t len = 0; + int cookie; /* * If no consoles are available to output crash information, dump * the kmsg buffer to stdout. */ - if (!console_trylock()) - return; - - for_each_console(con) { + cookie = console_srcu_read_lock(); + for_each_console_srcu(con) { /* * The ttynull console and disabled consoles are ignored * since they cannot output. All other consoles are * expected to output the crash information. */ if (strcmp(con->name, "ttynull") != 0 && - (con->flags & CON_ENABLED)) { + (console_srcu_read_flags(con) & CON_ENABLED)) { break; } } - - console_unlock(); - + console_srcu_read_unlock(cookie); if (con) return; -- 2.30.2