Message ID | 20221107141638.3790965-12-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 l7csp2078685wru; Mon, 7 Nov 2022 06:20:58 -0800 (PST) X-Google-Smtp-Source: AMsMyM5VHZd7YghPNyaP2Vi4+tq0svzEWTzgMHGoNrNIB93v7yd/jHL5IDFbz27wvEGw4wPfvsR1 X-Received: by 2002:a17:902:e945:b0:186:ba20:76e8 with SMTP id b5-20020a170902e94500b00186ba2076e8mr51384017pll.165.1667830858381; Mon, 07 Nov 2022 06:20:58 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1667830858; cv=none; d=google.com; s=arc-20160816; b=PF/JLiBKVtcBdtpMfuTcDhUCbx/rEUNubY4swk5xLsRHEyoLdOovrBmirjVkwG8gV5 xRtKUhpshYHp7FCWzUhTLz4REpa2f5kLsim4vZea+sQT/w7jPnXabqYSsGI0ccArlKfO Vev9wKIgqQpbmwO7T6fGxYNLOtu1qTmVmUqWRs7FZVC5UIu/jq+asM9PPIe9dIpley6k cWDNaJgSXPrnV4qVPpl0vB9S/UzzeQ1oinGgMAycZI0ENNAaUwwjslYNjf8AL+G2QaYC Nb+bOGuLmXTbVp21HWkgnY28TJS2JZ4uHrqZWfLa0pGl8p5w7iXeXQ3hNRXHRKsNYgAy pcmg== 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=jHu0DmQ8f1rgQbiyd2Suu9x07qh6zOdBEqqZ/26ftRk=; b=Z/0R5y0YiNEODEh3H+9B9jBOGUG2P0p2Rofh5A3ExbO2iaUbvLPn8YTEqjnFwEnAQC rEKR7bXDGS3TGy7t8wAuGkLd+jD1Ty5Qt/TldmO2vF8ymkSoEvcNaoZb/Gfs6ImRqaUU DN+epi1JXO8LdAl6AqzSlfjlgj5uutIUuxfXQ2CIdARMFqVDOGIw8nZIDshrPYW2LvoC 5m7XjiTD0cBtAUyZ4+u5ZhhhW4lw64eW8tHNvLf/YQ2ZeWZs8VL6SUs2bZTGwCVfRFHg +mt0P6rASJYUniW/xHRQ/V6W6U+7a4KR1DzZSLTpa7iREjz7dhTLjVi6r/b/q1yYfvg9 C8Rg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=hGwj6giz; 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 t16-20020a634450000000b0045650ec7a49si10946329pgk.821.2022.11.07.06.20.44; Mon, 07 Nov 2022 06:20:58 -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=hGwj6giz; 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 S232304AbiKGORz (ORCPT <rfc822;hjfbswb@gmail.com> + 99 others); Mon, 7 Nov 2022 09:17:55 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55704 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232131AbiKGOQr (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Mon, 7 Nov 2022 09:16:47 -0500 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1A42C1D0E8 for <linux-kernel@vger.kernel.org>; Mon, 7 Nov 2022 06:16:47 -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=1667830605; 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=jHu0DmQ8f1rgQbiyd2Suu9x07qh6zOdBEqqZ/26ftRk=; b=hGwj6gizl96NQKwR498k6uAl6XSNfXs5DgtmC5L8WU7gQWVMnV7NlRaPDbm+f6yjkhmslu QucFR7Y2mtVq5FQDr4sTthdt7CY0EmINf9SVUOxmemZNSxstqrHpUbc6G88hCPT21Yegbw eqg3pL91M6+PPtd1gM+QJUhLzSCTMEpbM2aJhVq6e1aoD+8XkEN/nxIGyiR1B32A6BlAV6 m19ypo58YK7PSvx6wjWoCQiTVJgwBKEG3xfqcKheTXfurqjSDhZxeg3XVqGOZTLfPijIy1 IOG5h4UQmGKMeBTZ1D2406gA5WuWTokF1Wsn3rGlck+/9hA/SyrLA4qUBFxMzA== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1667830605; 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=jHu0DmQ8f1rgQbiyd2Suu9x07qh6zOdBEqqZ/26ftRk=; b=P9Gxvfan7DCC1ih4Knt2kaKzs4QeQhU+whuk/d07z5yqj/O+rOCCGJvNj0Wj3ZUD3GFgTP nGuJe2YaCbe55ACw== 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 v3 11/40] um: kmsg_dumper: use srcu console list iterator Date: Mon, 7 Nov 2022 15:22:09 +0106 Message-Id: <20221107141638.3790965-12-john.ogness@linutronix.de> In-Reply-To: <20221107141638.3790965-1-john.ogness@linutronix.de> References: <20221107141638.3790965-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?1748847410379052453?= X-GMAIL-MSGID: =?utf-8?q?1748847410379052453?= |
Series |
reduce console_lock scope
|
|
Commit Message
John Ogness
Nov. 7, 2022, 2:16 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>
---
arch/um/kernel/kmsg_dump.c | 11 ++++-------
1 file changed, 4 insertions(+), 7 deletions(-)
Comments
On Mon 2022-11-07 15:22:09, John Ogness wrote: > Rather than using the console_lock to guarantee safe console list > traversal, use srcu console list iteration. It might be obvious. But I would add: "It allows to dump the messages even when console_lock() is blocked during panic()." It will help to understand this is a clear win. > Signed-off-by: John Ogness <john.ogness@linutronix.de> After merging with 9th patch for using the racy console_is_enabled(con): Reviewed-by: Petr Mladek <pmladek@suse.com> Best Regards, Petr
diff --git a/arch/um/kernel/kmsg_dump.c b/arch/um/kernel/kmsg_dump.c index f0233e2f8de0..b6acb3837f1d 100644 --- a/arch/um/kernel/kmsg_dump.c +++ b/arch/um/kernel/kmsg_dump.c @@ -16,16 +16,15 @@ 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 @@ -36,9 +35,7 @@ static void kmsg_dumper_stdout(struct kmsg_dumper *dumper, break; } } - - console_unlock(); - + console_srcu_read_unlock(cookie); if (con) return;