Message ID | 20221114162932.141883-13-john.ogness@linutronix.de |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp2238145wru; Mon, 14 Nov 2022 08:31:25 -0800 (PST) X-Google-Smtp-Source: AA0mqf6Ga6CUeipRovayzzaEa1Tli4mnXtpQvAPhU/AhxzfAZDLfsgmVB23N5oi+xrNax2vF6c9v X-Received: by 2002:a17:90b:2784:b0:213:d1d5:d661 with SMTP id pw4-20020a17090b278400b00213d1d5d661mr14637142pjb.43.1668443485158; Mon, 14 Nov 2022 08:31:25 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668443485; cv=none; d=google.com; s=arc-20160816; b=BYTITHSMqYpWRM3+eBeT45ISHd0g67iVfOXt7U/nKa8lwfLVkBL62loeFWEERA6tG3 4xbUaHRWxoEuJOaqiA/jXflT+3MdzwmN0wSHoXjosylqDKPShSKa8ZEF5YCehvrmb17u e7MCFHWVptncXVtVqBRuuqnraeAKx41KFCWYWhflHIcqOng++C7g2BDTGWcjdtlwHufq daiLBNN7wv/1OKpaGvTNCgK12LN8PPRHB9fypwrOBlWqO2q5Jp14flVSALuyyuH++FZd /+bTOvYqhjR3B5xgKul2RkTYxkZRFDpBRogpk6J1UEgK0S7K8Y9Cr10pD7mhhS2VXeYn XYIQ== 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; 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 l186-20020a6388c3000000b004767ae4f4aasi4062852pgd.486.2022.11.14.08.30.43; Mon, 14 Nov 2022 08:31:25 -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; 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 <rfc822;winker.wchi@gmail.com> + 99 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 <rfc822;linux-kernel@vger.kernel.org>); 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 <linux-kernel@vger.kernel.org>; Mon, 14 Nov 2022 08:29:41 -0800 (PST) From: John Ogness <john.ogness@linutronix.de> 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 <pmladek@suse.com> Cc: Sergey Senozhatsky <senozhatsky@chromium.org>, Steven Rostedt <rostedt@goodmis.org>, Thomas Gleixner <tglx@linutronix.de>, linux-kernel@vger.kernel.org, Richard Weinberger <richard@nod.at>, Anton Ivanov <anton.ivanov@cambridgegreys.com>, Johannes Berg <johannes@sipsolutions.net>, 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: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1749489795911860001?= X-GMAIL-MSGID: =?utf-8?q?1749489795911860001?= |
Series |
reduce console_lock scope
|
|
Commit Message
John Ogness
Nov. 14, 2022, 4:29 p.m. UTC
Rather than using the console_lock to guarantee safe console list traversal, use srcu console list iteration. Signed-off-by: John Ogness <john.ogness@linutronix.de> Reviewed-by: Petr Mladek <pmladek@suse.com> --- 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;