Message ID | 20221114162932.141883-16-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 l7csp2238173wru; Mon, 14 Nov 2022 08:31:28 -0800 (PST) X-Google-Smtp-Source: AA0mqf4wuIBql7FiYg41gWyp5BY3LH958nNWPIUpriwfq75PkSPh/OirTuww252wuOMNDFDHt4uy X-Received: by 2002:aa7:9156:0:b0:56c:a60d:54d7 with SMTP id 22-20020aa79156000000b0056ca60d54d7mr14402767pfi.18.1668443488219; Mon, 14 Nov 2022 08:31:28 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668443488; cv=none; d=google.com; s=arc-20160816; b=W1PFYlZNDx9lljRIMHR2G6UxGHUrWf3BKY8nre4c/GXmcBpJKNHjqlEONUGAwPQVt9 Wu0JiPaLwlSAb9bZeZSds/wRX3R0/GgHkY+ueVVYhNiU0J0YM2is1Xfa8lfIxXJK5a0A TATcbR/cfTg1TxsBBGYY1f1YkB4rePuOlYda2bnIPnPCSbe8uEtDvyj29lVmoqCgE4vA vvLictgUdmftYPbHgqQg8uhgsjU7DMD7QzxDkWTccEOHuKCPWvNl6w5KFyplH/IC+j08 OdX5FC1EOfQe9txvmjQKp8rPi7L0dg00jLWpdtzsKVmtPQ+u935LdEkS3BU1GLvEtYxS 87bA== 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=gNqL8lThA4YIywGDMJUU+3tDmR/wiL7uckrDiJUm3Yc=; b=uLEjms7cmwBmJMuzDEjOX0SiQEDR4VRaNisa6AEBd+1dtst+UfohNmXyZojDP0oIkJ wXz+fldKsDxRmWp4bAEcrNvGjzd6OQslEIP5cWOrJMmJ0s0/KaHGjzaFqYtwlkJexhJp 8+pZZaH2cwq5c8yxAbhHoAM8QrHeNjLL218MM0wjfeFmt8Shp/K6qwLcpkjCBWZKAcGy Udc6U39niWDXxaDr3wKuxYlfsjJxmQmmHf0k4FS+ZI+Dsgd2oAur6OGHIMoi4gzqrDqJ De77sHzjrvqSKL8Ya5tFG1dRSmaeLivGfA/ddJUSx3VJd5sEu3+qtWx4OxE3DgjVQxYK 3klw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=4P34KEWd; dkim=neutral (no key) header.i=@linutronix.de header.b=NtJVSn5M; 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 s18-20020a632152000000b0045ce0eba520si9424899pgm.751.2022.11.14.08.30.57; Mon, 14 Nov 2022 08:31:28 -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=4P34KEWd; dkim=neutral (no key) header.i=@linutronix.de header.b=NtJVSn5M; 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 S237658AbiKNQab (ORCPT <rfc822;winker.wchi@gmail.com> + 99 others); Mon, 14 Nov 2022 11:30:31 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35762 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237557AbiKNQ3q (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Mon, 14 Nov 2022 11:29:46 -0500 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5476E1CB07 for <linux-kernel@vger.kernel.org>; Mon, 14 Nov 2022 08:29:42 -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=1668443381; 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=gNqL8lThA4YIywGDMJUU+3tDmR/wiL7uckrDiJUm3Yc=; b=4P34KEWdum5Ad8J25GcIpklGjPLZyfP61f2N+FJq/EjuBLOCGQ402uYOuCvoGbXhkJRKlw TAFpdgqASC2/Qdr7QkpAThBldBcPuWfFfy5BtsG45GN3AISccx9ynbRBWAGkTSTgUcFfLP eLu1zs+FP/0ktSIiFPbtmQnqSC3lnyfQ0HrXy03qxk0YTMMqBhSxaXLyv4uc3dWa21Ln7t Wz4JMJAQcWlDqGjr0NBiQWWSiGOX4WyU9l/ySqaJpdS960EPrw/MOxErMLy0Co1qG++59U fTuggTBbCuSKexyxD578FCD/vn9pCaF5Qttt8ZjvuQ5uKVEPwa2YZRxbVtPSbA== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1668443381; 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=gNqL8lThA4YIywGDMJUU+3tDmR/wiL7uckrDiJUm3Yc=; b=NtJVSn5Mg5MJsfN6WJJF9AlssUQDo7vZxv3r93RxJ++DnBUK7rFjhIZE4JTLWwLHlvVAzC epjYOkxx+Piio4Bg== 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 Subject: [PATCH printk v4 15/39] printk: __pr_flush: use srcu console list iterator Date: Mon, 14 Nov 2022 17:35:08 +0106 Message-Id: <20221114162932.141883-16-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?1749489798935702153?= X-GMAIL-MSGID: =?utf-8?q?1749489798935702153?= |
Series |
reduce console_lock scope
|
|
Commit Message
John Ogness
Nov. 14, 2022, 4:29 p.m. UTC
Use srcu console list iteration for console list traversal. Document why the console_lock is still necessary. Note that this is a preparatory change for when console_lock no longer provides synchronization for the console list. Signed-off-by: John Ogness <john.ogness@linutronix.de> Reviewed-by: Petr Mladek <pmladek@suse.com> --- kernel/printk/printk.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-)
diff --git a/kernel/printk/printk.c b/kernel/printk/printk.c index b37ca16abbd0..3d9e5bb1a50b 100644 --- a/kernel/printk/printk.c +++ b/kernel/printk/printk.c @@ -3532,6 +3532,7 @@ static bool __pr_flush(struct console *con, int timeout_ms, bool reset_on_progre struct console *c; u64 last_diff = 0; u64 printk_seq; + int cookie; u64 diff; u64 seq; @@ -3542,9 +3543,15 @@ static bool __pr_flush(struct console *con, int timeout_ms, bool reset_on_progre for (;;) { diff = 0; + /* + * Hold the console_lock to guarantee safe access to + * console->seq and to prevent changes to @console_suspended + * until all consoles have been processed. + */ console_lock(); - for_each_console(c) { + cookie = console_srcu_read_lock(); + for_each_console_srcu(c) { if (con && con != c) continue; if (!console_is_usable(c)) @@ -3553,6 +3560,7 @@ static bool __pr_flush(struct console *con, int timeout_ms, bool reset_on_progre if (printk_seq < seq) diff += seq - printk_seq; } + console_srcu_read_unlock(cookie); /* * If consoles are suspended, it cannot be expected that they