Message ID | 20221116162152.193147-10-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 l7csp233207wru; Wed, 16 Nov 2022 08:25:23 -0800 (PST) X-Google-Smtp-Source: AA0mqf4QnYljy5Mgm8dPVMmh00e6uBiRIUbQUgi9EKSSIjokBamwdj4ek1zD9VJkqIvKoxoylMMO X-Received: by 2002:a17:90a:3f89:b0:217:90e0:3f8c with SMTP id m9-20020a17090a3f8900b0021790e03f8cmr4465806pjc.192.1668615923593; Wed, 16 Nov 2022 08:25:23 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668615923; cv=none; d=google.com; s=arc-20160816; b=H1AmMcS/6v1Rx1aVSRSdBe9xCGk5nAEiMXC60ngsGB3eThvYT1IV2X3ocx/soO1SLh poDojhrrB0ZiNkQ0FH1Kte9UXwtD6twoD8XG5rYcPL58tL7gHVuOLEyKj8jxAqsoupxB XQeGl+lio9j7nOagbUeD1yi8fK/LnycLrZMiUO6dg8cS8W953XrLoO0Me8+NmJFDRAkY PiAmWtPjkKBJHUuC9R0rRUqecmaNtkN4RZe9P4sz02DBy2gFbAHed1EZBrq6hY4rrmKw 6gGfC4KymXq52dhAWGm4GidMa1fxuGH9RJny0QCVh60rCIloP6+qXtT0gsb9WXvEAWTS FpVA== 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=6POxijvlWYTfJk68FJg54j07I7MpPRBTNu3UsEFQG6Y=; b=u+3brIg9NUZrAkYSOrjHBRwdSk0oiRDKbp+DqZjBhODdl72PFyAV8EJzOfamK05yuJ rtBdFheXQvtDbqHNWEuFBDrvTh6biyhe38mcx8+lbkadvrzz/uD8yVeOo3PaozaoYlGL nIHJtGnh04UT582jpLu6BcQqiC5NtGi1WMTPhJCzZmphBcNLl/suBc+clsYod/cklF4N gF/ek5G8V0fL5fbiZMudsb30OB6DVKn6RG4wTt/Q6XQrZQSee8PGyuf2M/0hdhXsRAqU N3HElSQOyOIQTfeL5yABDDhb8xSGayaSC95lvqyC6XO+6N85J++LmMA2IlS3gUE+hnpH epTA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=OebKUG+9; dkim=neutral (no key) header.i=@linutronix.de header.b=B51xiNcC; 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 n3-20020a638f03000000b00476b6fa2963si3051628pgd.599.2022.11.16.08.25.09; Wed, 16 Nov 2022 08:25:23 -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=OebKUG+9; dkim=neutral (no key) header.i=@linutronix.de header.b=B51xiNcC; 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 S234780AbiKPQWh (ORCPT <rfc822;just.gull.subs@gmail.com> + 99 others); Wed, 16 Nov 2022 11:22:37 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58660 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233565AbiKPQWE (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Wed, 16 Nov 2022 11:22:04 -0500 Received: from galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7591C4387A for <linux-kernel@vger.kernel.org>; Wed, 16 Nov 2022 08:22:03 -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=1668615721; 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=6POxijvlWYTfJk68FJg54j07I7MpPRBTNu3UsEFQG6Y=; b=OebKUG+9hP69pRlZMztMu0OHTK0KmUwcaRtKZFHo5zqyxDOLI65rXuEET4p1Lk1V+7m0f3 7x10qYARiDy6hBZPGK6/eBM5e0tGVfVLLq0NITUsDAEgNa+4ywiA9Yg+rmjkwBOWCh4mN6 2wdIFM5W9Q50P5rD5AAye7Mu+gsKGSmUizLR3B2K9Id+i/01EEdGIuaGY4NcxnXfr8rWgW 8a5BQHscjbfIDbTPwi5zAl9JIHQqvkctfgIkseR6QoLsaNgOvkkfTI/FsYqPWlxSg+T74Q pyqCWXCqxiPPwM5dhO0rgRPNcPEkryBYtlOEf5+KvmyK2XMVJ1n9dlOBhUqAwA== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1668615721; 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=6POxijvlWYTfJk68FJg54j07I7MpPRBTNu3UsEFQG6Y=; b=B51xiNcCGa1IY9q1AAsoLFLq22Zmf3cYE2XoyKGJbHGKFoq0JcF8rDLof3zNoY/T1BrlGv Qb/xofw3wS72f9Dw== 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, Greg Kroah-Hartman <gregkh@linuxfoundation.org>, Jiri Slaby <jirislaby@kernel.org> Subject: [PATCH printk v5 09/40] tty: tty_io: document console_lock usage Date: Wed, 16 Nov 2022 17:27:21 +0106 Message-Id: <20221116162152.193147-10-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?1749670610401272503?= X-GMAIL-MSGID: =?utf-8?q?1749670610401272503?= |
Series |
reduce console_lock scope
|
|
Commit Message
John Ogness
Nov. 16, 2022, 4:21 p.m. UTC
show_cons_active() uses the console_lock to gather information on registered consoles. Since the console_lock is being used for multiple reasons, explicitly document these reasons. This will be useful when the console_lock is split into fine-grained locking. Signed-off-by: John Ogness <john.ogness@linutronix.de> Reviewed-by: Petr Mladek <pmladek@suse.com> --- drivers/tty/tty_io.c | 10 ++++++++++ 1 file changed, 10 insertions(+)
diff --git a/drivers/tty/tty_io.c b/drivers/tty/tty_io.c index de06c3c2ff70..ee4da2fec328 100644 --- a/drivers/tty/tty_io.c +++ b/drivers/tty/tty_io.c @@ -3526,6 +3526,16 @@ static ssize_t show_cons_active(struct device *dev, struct console *c; ssize_t count = 0; + /* + * Hold the console_lock to guarantee that no consoles are + * unregistered until all console processing is complete. + * This also allows safe traversal of the console list and + * race-free reading of @flags. + * + * 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) { if (!c->device)