Message ID | 20221107141638.3790965-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 l7csp2077904wru; Mon, 7 Nov 2022 06:19:41 -0800 (PST) X-Google-Smtp-Source: AMsMyM7Z65X+EMHlueA3RtuOFe1gAey5Sc7vySDIYJdq3wmT7zQOXjgG/A8+uReH9cQOZDflHg/e X-Received: by 2002:a05:6402:1c0a:b0:463:3cda:3750 with SMTP id ck10-20020a0564021c0a00b004633cda3750mr45437611edb.341.1667830780834; Mon, 07 Nov 2022 06:19:40 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1667830780; cv=none; d=google.com; s=arc-20160816; b=VPc/1Q6Iohk6VpAIAX9tQ5ilYaq6lUX7gJSsYDBlYSNCVMSUgDccqSHOWY3hbPG4F6 MINUlW8mUqSSNLlsSLzr7BDDHTI6i9HH24UxDpPRUVK1tfmjdc9y7qGir2eAanoKHCOa yA4+n4lAG7hVwYb29LOGagAuNdtYDFSBGWBjiOZRdY8aLLsuqHtxvpGKmckQ4GzF9fcI 451RKXbKa0tOlQde+QcYKgWcDTw64GOjRRCA9/vAWOFPA0795vMTInTXNXOAOvZBg4m5 MukpeDhMDh4gsIp0UvOhPAvaZU3PNsmw6Edbyin29Eiir45rU6YZnJbyKJvsxCglL8To 35aA== 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=ytJB+9rgO+EqU8LkGZl4Tw4Z1RzQttqyi+dgPG2Y3pw=; b=WOkuzG4V6wPzHNX8wFS9viB8RI6wdAYZ1NyvQydMGrSXuLwc33fxzW+7LnCqcoLk69 pCUYRdXDU9RPDTlomQGXVVyrvBAv4CUKCAM1pSq9JsslKHydgr6P1+HuEUu3qQaLZ00a P10ieVPgMOfvTNPQWFDkbpkS9JdOjaeB1wQ4Sz+ZMgqcFLQJai6ei2h2ye0emh58ELN+ qQKqS+DKnOfw0LbMLlD1wFK4Ql1pNDju7lkPOVFphCw2hwgFX7nWu8GJCFmS2zSJTOk0 QWdcc49N/nAaiwbssk6PI44ea6ddg4ObOJCTR9Wro+JAl8BEZaFbz28JJSMxvDc+tVED 0FCg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=tvfgWdUO; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=SCvymT3g; 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 s6-20020a056402520600b00461d2ed78afsi12443507edd.563.2022.11.07.06.19.16; Mon, 07 Nov 2022 06:19:40 -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=tvfgWdUO; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=SCvymT3g; 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 S232334AbiKGOSM (ORCPT <rfc822;hjfbswb@gmail.com> + 99 others); Mon, 7 Nov 2022 09:18:12 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55780 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232167AbiKGOQv (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Mon, 7 Nov 2022 09:16:51 -0500 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EE2651D31E for <linux-kernel@vger.kernel.org>; Mon, 7 Nov 2022 06:16:49 -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=1667830608; 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=ytJB+9rgO+EqU8LkGZl4Tw4Z1RzQttqyi+dgPG2Y3pw=; b=tvfgWdUOKJ0foJ5Ejz1gne/uLe6ouS6lUxWKG3dZ78D1ctsy+KDk2k1UeJK+dflBFF5tQB LJErgvWTqWgYNJ9RiE82R/HpInSf3dywVtBQfWyimnALZtruD6kAAachO9zUSBlQXQb1v9 ZfIAI3z4F4+u62e+QbuPGSc8h1z/f7By8TMR80eErlPO0Zn0EXUBJWoLox4XFLfx8Zm9ve CykXIPWP1DQ21t9FMDfMu4wp5jEwrXyYbWVjSrn8/D4zdw/7E+f/JLOl6EPXRSLRF7k1io Eroz+kmQWCyOTDUSwy1xtwV2PvLWHmp99oxSnhexLUqROQFPb9YQGkMeuoYtMQ== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1667830608; 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=ytJB+9rgO+EqU8LkGZl4Tw4Z1RzQttqyi+dgPG2Y3pw=; b=SCvymT3gXMX272XYBl/YKBg+avdcP3e+KZW6cTXiDF6OuHHUQtY/cy7sw6vjxvzae6HxQS 5FlXwyzw/ecLD+AQ== 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 v3 18/40] printk: console_flush_on_panic: use srcu console list iterator Date: Mon, 7 Nov 2022 15:22:16 +0106 Message-Id: <20221107141638.3790965-19-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?1748847328774505947?= X-GMAIL-MSGID: =?utf-8?q?1748847328774505947?= |
Series |
reduce console_lock scope
|
|
Commit Message
John Ogness
Nov. 7, 2022, 2:16 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 c3191dc24742..de86a502b50b 100644 --- a/kernel/printk/printk.c +++ b/kernel/printk/printk.c @@ -3002,21 +3002,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(); }