From patchwork Wed Nov 16 16:21:22 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Ogness X-Patchwork-Id: 21157 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp233487wru; Wed, 16 Nov 2022 08:25:58 -0800 (PST) X-Google-Smtp-Source: AA0mqf7/d+kaJaYxRebOdiAbJOUmdEg4WuaQ5T8HMJCXMtkQHaUNBfAH49z7hSmVZStk1+DUByYd X-Received: by 2002:a17:902:b598:b0:186:8516:cd5f with SMTP id a24-20020a170902b59800b001868516cd5fmr9796447pls.11.1668615957803; Wed, 16 Nov 2022 08:25:57 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668615957; cv=none; d=google.com; s=arc-20160816; b=WpsM/IHVbk43qay2cHvmX5zjxRGXQigoLqnDa4kuy8hMzt+EC4Elv/3gtI66cTsaFH FRgJ13Hn54ekpiPGy0Eq1OdSPgddS4lUyVMkHBtu3xxjU2WTRP6vQmgmW/afXvpIBWgF sF/aBOsyVgFKB+VRIlOxSwDr47CVYK2lJEVptnmbdZ91fV9zdTpzLtgehXQK8YBwuGjO 4r7FS9IYusx0J8gIRMMguUXqKqZPyVmJE6lUf1uD0hWYqGWmZlv+p+7DnyMknrrJwQll +vDaiNfWf0tzp4w7b1azC9Z7G/RagH50eV33Pee0zl9mZmVeYb6BrU3WA148hch0yXul r4nA== 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 Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id b22-20020a056a000cd600b0056d67d820ecsi16693460pfv.258.2022.11.16.08.25.45; Wed, 16 Nov 2022 08:25:57 -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 + 99 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 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1749670646759914535?= X-GMAIL-MSGID: =?utf-8?q?1749670646759914535?= 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)