Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp866060rwb; Wed, 16 Nov 2022 08:39:03 -0800 (PST) X-Google-Smtp-Source: AA0mqf6Pezn1hIGOeNKMRZdbnc5RKAzPHhnZSRDtem5e7Pw8VBX9LR/gKPoTy/FNMBYpexjYhc1E X-Received: by 2002:a17:907:f99:b0:7aa:57c3:3f26 with SMTP id kb25-20020a1709070f9900b007aa57c33f26mr18181829ejc.195.1668616743570; Wed, 16 Nov 2022 08:39:03 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668616743; cv=none; d=google.com; s=arc-20160816; b=ctSQh5x0LICyB1KOANq7vPUfr7mF7JcpxeOGdZbMDZY4uED+21ZT55a6fiUSOWSx8y FHBeutU7jkToclpE6gzwnfTsL2qr3vfsouF7Xs77wIlz2dMOatUYUoWRms9gowu4XBbL KcQwtWrHYjEjb3RwpC8Be7HBccmKH8QR7vA0cJ47tORJ4kzs75kWUJgqdSWDHyJmQDw+ +6HHM9mBcJR5neKwIapQolscHo5yTQ8RUEu+wt52kyZOylLL/2mUy2b8wS2QMV67Glvd q/SIcBcLJNCeOu4kt9UopuiPRRfBYJ2LDmbvuS5zZoxEg5qfs+BKOK8FJb5m/n2xjCEK yeMA== 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=WyGtVM99u5kVDH70iZExE1J1KzxzFf6H5/dTCHJGWmg=; b=ieOg0TnZ+Krvtfn7MsgXK8z7fxIE8EXYwXmo2Outf0FwxZWeWW3LwrYratywrq7oqj Nge48x9JY8XxoDdiNcM+2bi0ujzRNu7kJjHTrlJhqIQ9fuAD8jQlgIGaOraXW9CM/Y7c Yxe8DCi/5t2k59engZ4nGUxl8+t5Osk1+doTzSKiCiVjPE8aLtv8KoHzWQJDqi8B0r0F ZRIaDEpdolKU7DDt0qa5sdCXpfVyv1hLAZ2sonO3SNvJ2Nl0F/2pPZRZgltKdiI39hXr dxLj9y0924BJKBfI7R/caMJ9mhGDCXmaNGpFbw6fvAe3683HTmBLF5FEwnz/t9lt9b3n VUiQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=OkggJBlH; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id x24-20020a1709064a9800b007808f3f4cbcsi11216406eju.239.2022.11.16.08.38.41; Wed, 16 Nov 2022 08:39:03 -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=OkggJBlH; 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 S235995AbiKPQWt (ORCPT + 91 others); Wed, 16 Nov 2022 11:22:49 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58670 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233587AbiKPQWE (ORCPT ); Wed, 16 Nov 2022 11:22:04 -0500 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BE17D49B68; Wed, 16 Nov 2022 08:22:03 -0800 (PST) From: John Ogness DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1668615722; 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=WyGtVM99u5kVDH70iZExE1J1KzxzFf6H5/dTCHJGWmg=; b=OkggJBlHCa9L4cp9ZDwwAsfL5ubRsoOncME3GDT90isJ+qp7J73h9NygngEEZiEoWr+es/ 3Upl4H1KrQnB9vC4v5gJ8xNfgM03fTyq0Hvw3HyW+NTRBO9RDXHTzuY5yyRaWNip4KoUlo jv8o3KtDRDJ5vnJjCybJF2iNMAlOfQr0Z0EssP9z6UoZbQUp+vf741jMgzncq8Q944gZyU q/EDZaCvZe+84tYeDpcZt+1MrsFtlBB5PuIi0o6f70Fv1eF0z3tUS8sMp3rL7kwVtceE+v QzzsEhnN/iuaaeQLCD0aYQE0OgwigXV3QCHRchsu1ujqaQU2+c+KX3u9rJFQzQ== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1668615722; 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=WyGtVM99u5kVDH70iZExE1J1KzxzFf6H5/dTCHJGWmg=; b=05p9Fgr9oIC1rseJZa7drAisqg0/FWrb79iEbbJ3VXznN77H03kThzDxWjsXNFc/82FzCY mJAwymv7Gr0kdEBw== To: Petr Mladek Cc: Sergey Senozhatsky , Steven Rostedt , Thomas Gleixner , linux-kernel@vger.kernel.org, Greg Kroah-Hartman , linux-fsdevel@vger.kernel.org Subject: [PATCH printk v5 10/40] proc: consoles: document console_lock usage Date: Wed, 16 Nov 2022 17:27:22 +0106 Message-Id: <20221116162152.193147-11-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: X-Mailing-List: linux-kernel@vger.kernel.org The console_lock is held throughout the start/show/stop procedure to print out device/driver information about all 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 --- fs/proc/consoles.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/fs/proc/consoles.c b/fs/proc/consoles.c index cf2e0788f9c7..46b305fa04ed 100644 --- a/fs/proc/consoles.c +++ b/fs/proc/consoles.c @@ -63,6 +63,15 @@ static void *c_start(struct seq_file *m, loff_t *pos) struct console *con; loff_t off = 0; + /* + * Take console_lock to serialize device() callback with + * other console operations. For example, fg_console is + * modified under console_lock when switching vt. + * + * Hold the console_lock to guarantee safe traversal of the + * console list. SRCU cannot be used because there is no + * place to store the SRCU cookie. + */ console_lock(); for_each_console(con) if (off++ == *pos) -- 2.30.2