Message ID | 20221116162152.193147-21-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 l7csp233178wru; Wed, 16 Nov 2022 08:25:20 -0800 (PST) X-Google-Smtp-Source: AA0mqf7Yul5CGtyyALZmbVnbBhMmkYIZTjJXXN+kWxoGcmBCr2lkrDY2fD/EOkt4aPGUH3jT9Y/p X-Received: by 2002:a63:565c:0:b0:46f:e658:a8ff with SMTP id g28-20020a63565c000000b0046fe658a8ffmr21125734pgm.493.1668615920192; Wed, 16 Nov 2022 08:25:20 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668615920; cv=none; d=google.com; s=arc-20160816; b=OAZCpMc7y1z7vx29KWyXL+MypAmAQrbKu44ojxgBvPM/d9yfElonVEgtgCdmKzdU5H AESwLUmT7RGGy1prZpiE2EvzaWCAAJnF6892Xa4AHZs3uCb4r6CfaKWQDSULwQUR8CLo l1GmCQoZeQ1DWmnYTc/FheU8OnS8VPq5dP5H2oGenISRB1ax/cC6HYgPsck9Ch4hHxek jrlUcGpHaBXi8lQcsXdmaVzVAt+xUiXIMAEu39sjJPZbcqxtiVPy1i3PzfWxVjyqcaLz Z3anfMskrQzrpThNuy8URTkENAcAhefUBIt4BIy0lMb+5bPJJ3XPgMpJRzGxXuHyl6OS BNUw== 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=KmfyhSE4r6WUxdHMjntiag5r5BjOY39c0HqbRdrpwyk=; b=IAZxx3VZrE27YhYBzXeeIfNl3tEAInzfk4hqzYcrXQDsGZeTdox6GQVnpPLMJFq1Q4 dmvOIqFODk4VPKpvi/gwJQYp9qlIy6tWgP5UkQ3Ns1F052EWy57ggO9THvpP1uYa8P/F jkRhSzkgeaJ8+jTnx5ALkQUrAw3Uh8X6wDfGHJ7jrPOM7Ctvvtz5uPhrcBXaLZEWj+0K UYcsr8tUXHQcsHus1Y5CrvksJfyXev0EQ6xQgrZ1p4kRhCOm0XBIAiJs26yCnL4QcahY vZbu/bjldtTw2RN7ucN/2b9/isJ4Cn80VbMHZ6LheOF++0Ksp8093ZVMjUp7dHyV+QiN Ebvw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b="k/cRkSzu"; 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 l27-20020a63571b000000b0046f622b47b9si15970811pgb.180.2022.11.16.08.25.07; Wed, 16 Nov 2022 08:25:20 -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="k/cRkSzu"; 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 S238791AbiKPQYB (ORCPT <rfc822;just.gull.subs@gmail.com> + 99 others); Wed, 16 Nov 2022 11:24:01 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58672 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233472AbiKPQWd (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Wed, 16 Nov 2022 11:22:33 -0500 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D8E27326F5 for <linux-kernel@vger.kernel.org>; Wed, 16 Nov 2022 08:22:07 -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=1668615726; 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=KmfyhSE4r6WUxdHMjntiag5r5BjOY39c0HqbRdrpwyk=; b=k/cRkSzuFCT+qLGQGkimjidC2S2ewQnumtvJw+ZaIw2kd+mtyfYy9IDf+wRPav3Z6JAB3W yPERjIarGDkPzFRVqTufPPgKmx4BK0i6aseuo+Yjja1rFdrV5XJ5k1WBdOguLmdv5QsyPe eqKAPKqI82efDymKZ0fsPD7RNWXNLJgD+noCTM8rnZDqxJzmYGbZ1OMcv23JC9HGjJGwsN HxoYF605s6qqpxK94MpbPyh543sKAnGUO88n/4muBc6o+CsE3JHTcKrxHVdNm/l2MncEfQ HlU7VMMmg6t4dEy7gqKJPyPqx/BEtOpKYzOp3OYAYVAS+eMHhFFJ9uSEvzJL6g== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1668615726; 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=KmfyhSE4r6WUxdHMjntiag5r5BjOY39c0HqbRdrpwyk=; b=ZgnqSOHRDB9ITTyaqG0OzhGDy6iC+fOzqVTExO/t8Tiuha/tipl08vwtipSqjr/KO4CXCI YfEAjtozcg8gaaBQ== 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 v5 20/40] printk: console_device: use srcu console list iterator Date: Wed, 16 Nov 2022 17:27:32 +0106 Message-Id: <20221116162152.193147-21-john.ogness@linutronix.de> In-Reply-To: <20221116162152.193147-1-john.ogness@linutronix.de> References: <20221116162152.193147-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?1749670607283797321?= X-GMAIL-MSGID: =?utf-8?q?1749670607283797321?= |
Series |
reduce console_lock scope
|
|
Commit Message
John Ogness
Nov. 16, 2022, 4:21 p.m. UTC
Use srcu console list iteration for console list traversal. It is acceptable because the consoles might come and go at any time. Strict synchronizing with console registration code would not bring any advantage over srcu. 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 | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-)
diff --git a/kernel/printk/printk.c b/kernel/printk/printk.c index 1a805ebdfe94..694c2da2919c 100644 --- a/kernel/printk/printk.c +++ b/kernel/printk/printk.c @@ -3076,15 +3076,25 @@ struct tty_driver *console_device(int *index) { struct console *c; struct tty_driver *driver = NULL; + int cookie; + /* + * Take console_lock to serialize device() callback with + * other console operations. For example, fg_console is + * modified under console_lock when switching vt. + */ console_lock(); - for_each_console(c) { + + cookie = console_srcu_read_lock(); + for_each_console_srcu(c) { if (!c->device) continue; driver = c->device(c, index); if (driver) break; } + console_srcu_read_unlock(cookie); + console_unlock(); return driver; }