Message ID | 20221114162932.141883-19-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 l7csp2238226wru; Mon, 14 Nov 2022 08:31:34 -0800 (PST) X-Google-Smtp-Source: AA0mqf5VFqUTib27peVJLHwKFjy8sgOKAp/gwgdVEjADIxBcAO0MsL4g3F1iLnENX6hqwrfEkuFN X-Received: by 2002:a17:902:c652:b0:187:4920:3a78 with SMTP id s18-20020a170902c65200b0018749203a78mr67622pls.88.1668443494044; Mon, 14 Nov 2022 08:31:34 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668443494; cv=none; d=google.com; s=arc-20160816; b=p11578aroSDiSEiKR9OyrZaI/XVHKkpGQVc7DxiD57+g8fmjFMDxczU2q5LZeRzWxK 8KKxiVLWJ3jBLapQb831h1G0L6EwABgnBynb/+MLUZsD3BX1OeZYM8Rw3s2uoeWsk7cv j/ESq+s6NusRFadwHbKBO9Oi4wUYfedERGBwktehIfjzT3JtWaI8dJQU8Kag/PLDgzQU LYbOZaX0oDYtZ4P9zxhVvaHOxjejtPJcZ128FN48C39MA0n17ASuyieYvgJBrAEonLo7 Wo7aFaCfqYNHOobbUw1CylMxnV5iNOKJyKPpB5TtMa4diXDN0GZpdsmJX08iEtbqkBHB FsDQ== 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=EQ/FYtHGXP7iZ3ZSMRcPCs9DaQP+JVaa/N3ps9AS5hs=; b=eDxFiplFMiWC1SV+Ih2NLBb2Zc54Yj22/afhFjjfBaDUKcih2xdUIcpRqevOn08KDD 6mveLZ2akPUCLal+yyQadq7DTyoV2cILN1jOGlTiZ7Z2AfVsbThT49WxCzuA/RBrMPzx 5R3FapFgdFqXA+9tat7wjKo+ixEiDl4e9LopC8+mOsZ81bYzkAtRT0XSojPENKMZK+g2 gZPjput19x1Pf0Cdi8919fbYiHW6e10DIdFqSiFjjn0+yZezxCyKOohI25YExMn1x8HP ZW8StYTacZSVJMbg+Gj3RkbELduLQy56edKutg2UykP0VUOkvy0VRdWSGbpzU0UYeYxy 5hLw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=MCbYSrYZ; 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 c3-20020a170902d48300b0018890a7e9c5si11446871plg.509.2022.11.14.08.31.07; Mon, 14 Nov 2022 08:31:34 -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=MCbYSrYZ; 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 S237623AbiKNQan (ORCPT <rfc822;winker.wchi@gmail.com> + 99 others); Mon, 14 Nov 2022 11:30:43 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35896 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237434AbiKNQ3u (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Mon, 14 Nov 2022 11:29:50 -0500 Received: from galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 70BA6220E3 for <linux-kernel@vger.kernel.org>; Mon, 14 Nov 2022 08:29:43 -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=1668443382; 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=EQ/FYtHGXP7iZ3ZSMRcPCs9DaQP+JVaa/N3ps9AS5hs=; b=MCbYSrYZGc9XGEtVr6ccRpZvWfKLFaOdeuaK62QMBUjXY+nfurYfNzu1EaGFQXD4PWSFYv yC3uItnVyTLScP+KoaZPkU3ZlvX/JdrHb/LDYnsWmxGdhmA2IYQQiuDc4Nyq8WcPkI2m+8 2977dgIpYMx/aZzyOsn5DNCt6dh5ybpZ03+YZI+oQBh0VuzrfbpbpZi1zxcvsAX+HDP2Nj QxvNsTi7ox5bS4/LrxMnDpm9XNbVkD+0mnBXAdSSV2oj9t7W+cru5ioit5vrDHcaigPeLZ s86s9DxaQDNOxjWehsNlywPhM9W1CpB6ai700ZB8BoKfu7M2pLyAuVUCupIVwg== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1668443382; 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=EQ/FYtHGXP7iZ3ZSMRcPCs9DaQP+JVaa/N3ps9AS5hs=; b=Ll08qw3MXmbQitfwoSqB+iIxBeEp9Lp6vRijiwhXG+cyEp/aoivI+HXmJ18Yri27v1x/u+ nqBFumtsCVXWYIAA== 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 18/39] printk: console_flush_on_panic: use srcu console list iterator Date: Mon, 14 Nov 2022 17:35:11 +0106 Message-Id: <20221114162932.141883-19-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?1749489805210101599?= X-GMAIL-MSGID: =?utf-8?q?1749489805210101599?= |
Series |
reduce console_lock scope
|
|
Commit Message
John Ogness
Nov. 14, 2022, 4:29 p.m. UTC
With SRCU it is now safe to traverse the console list, even if the console_trylock() failed. However, overwriting console->seq when console_trylock() failed is still an issue. Switch to SRCU iteration and document remaining issue with console->seq. Signed-off-by: John Ogness <john.ogness@linutronix.de> Reviewed-by: Petr Mladek <pmladek@suse.com> --- kernel/printk/printk.c | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-)
diff --git a/kernel/printk/printk.c b/kernel/printk/printk.c index 7304cbcd6dd4..f536233d8234 100644 --- a/kernel/printk/printk.c +++ b/kernel/printk/printk.c @@ -3049,21 +3049,22 @@ void console_flush_on_panic(enum con_flush_mode mode) console_may_schedule = 0; if (mode == CONSOLE_REPLAY_ALL) { - struct hlist_node *tmp; struct console *c; + int cookie; u64 seq; seq = prb_first_valid_seq(prb); - /* - * This cannot use for_each_console() because it's not established - * that the current context has console locked and neither there is - * a guarantee that there is no concurrency in that case. - * - * Open code it for documentation purposes and pretend that - * it works. - */ - hlist_for_each_entry_safe(c, tmp, &console_list, node) + + cookie = console_srcu_read_lock(); + for_each_console_srcu(c) { + /* + * If the above console_trylock() failed, this is an + * unsynchronized assignment. But in that case, the + * kernel is in "hope and pray" mode anyway. + */ c->seq = seq; + } + console_srcu_read_unlock(cookie); } console_unlock(); }