Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp5739814rwb; Mon, 14 Nov 2022 08:49:20 -0800 (PST) X-Google-Smtp-Source: AA0mqf7sIUCN13frUv5eS0bDDqEuGSqBd6e2Ro6ZSHqYNs8nwaOZqQpAyZWv3IPTLGfEHB3syISn X-Received: by 2002:a05:6a00:15d2:b0:563:1231:1da with SMTP id o18-20020a056a0015d200b00563123101damr14943162pfu.5.1668444560560; Mon, 14 Nov 2022 08:49:20 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668444560; cv=none; d=google.com; s=arc-20160816; b=ZijJpTwxGRLSLpZjXnbIqEp3VcstCDM6CTa3z+0VwV9bnplBP0wlON59XYPQsy1aNm x9N7EQKMnRaD7XSi+JO3sRdz7rDednsK57dId8FcUxn303a4nunycJiKghPoGwW2tb3k BDKrXJJGY6YaUftLPVrFo3i1zA5rVhLHz7CjavzDryt8G5sNozvLmcHu09dBIDOP3OTG IsEzXWhIzewDXHubZaQwkIEyWwqKNELeZ+1LXiXd9DJo/E0E7C1DmjSWBAkAp/KpuAM0 fv4ZI63xFSywCjznlfCL1kj3QhQeXh7ZA7pEqxRdEtD1gJIv9SZHxViqkorAt+D5JAi3 kg7Q== 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=w8p5Oo+8cSj9fa2wd2zBiaW+ua+MtkASN+gimVgrJE/hM4xfqakN1vLWbNVcaON707 J3B2fdoMzaDO3zMxM5ykdwCZcr1OPrmoZBemZSIeHqLutvXcWoE8uZKoiU11HGT5e9vU FF6o47353FwVJbpE6H2zkYRsj7pYNSFldOlEDkc2CpI2NQAF9PFUcKJ0uq+Ph7/dc08P cNj0xXv+jC/NmIQFCCy4HKwotjfJ/4/XbOI7jArmc+H6oEFSOQEQQMncRImEaI+CEIcV sSSL1q0QXrAcJkXo/cflRL68G3QL6WYIjiJ4cF2mVSMxXCDt9Yw9KT2Xcw75M680zoUp W7jQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=JCoPP84G; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=XM0sZBUT; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id go10-20020a17090b03ca00b001fd7ced8960si14012864pjb.92.2022.11.14.08.49.08; Mon, 14 Nov 2022 08:49: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=JCoPP84G; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=XM0sZBUT; 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 S237605AbiKNQaO (ORCPT + 88 others); Mon, 14 Nov 2022 11:30:14 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35578 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237528AbiKNQ3k (ORCPT ); Mon, 14 Nov 2022 11:29:40 -0500 Received: from galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9189BEB1 for ; Mon, 14 Nov 2022 08:29:39 -0800 (PST) From: John Ogness DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1668443378; 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=JCoPP84GTD7S6ZKvY3Z/oW1faIG0mRb+VXwmEMq2/9maJnu2bJ4vVZwAKdnWc0JkCEwziB u9Z4tPX23Yk6Dq1b8w2jERlxWFg9DZ6B8ebtpQpj8Eh/HGr1vYGrbZvZRaddeJKAO3LlQx J1TeVrqc45Q8oimpMKSBUzA7sN8i9CC+jZFqFP8+fC6nuurYGVkEgO8NfYHmsCdyslWqR3 r49w15/LRtFVLv5xvSxiCEuHQy5VVbMYf5zi6z8gKRt9MYYconzIJI69+2S8dLZ+WC4xuX LH/xD2yPO2uk1n/+PeJzAvnTu0vVvHmwItiLx5zxsIDDlP21zAWNhv2/dqOwtQ== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1668443378; 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=XM0sZBUTpYOnV33YxdEq1ANzbOmI/ncNQRLlKWlmnypDTlRkCpe0fo3vqHy9OFToINmwjt D4N0MxF5n4UhX8DA== To: Petr Mladek Cc: Sergey Senozhatsky , Steven Rostedt , Thomas Gleixner , linux-kernel@vger.kernel.org, Greg Kroah-Hartman , Jiri Slaby Subject: [PATCH printk v4 08/39] tty: tty_io: document console_lock usage Date: Mon, 14 Nov 2022 17:35:01 +0106 Message-Id: <20221114162932.141883-9-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: X-Mailing-List: linux-kernel@vger.kernel.org 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 Reviewed-by: Petr Mladek --- 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) -- 2.30.2