Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp5775478rwb; Mon, 14 Nov 2022 09:15:22 -0800 (PST) X-Google-Smtp-Source: AA0mqf4Cik8s+GKjIyTvcyXg4E3V/a45i06W3zZb+Kfn0cv2hhptKkx6AViaNec4/ZP3CltWqMYs X-Received: by 2002:a05:6a00:27a3:b0:563:771d:417f with SMTP id bd35-20020a056a0027a300b00563771d417fmr14674019pfb.45.1668446121902; Mon, 14 Nov 2022 09:15:21 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668446121; cv=none; d=google.com; s=arc-20160816; b=Y9EEOAp1RkU6EQ8E6u0NjHJZAQ7GQY7zATxbx1dqqGYM0ttqHRn48aBzqPiZntqW6D p/FiMDib3LY96mZWuRr6WTe1mB/kV33hp12qO9rpQzPlxj3IFhaWPwC0hfCIQVp+mBzv hcraHJZvjMfmTc9X4p9ZNyYFr14X/pxJ7NXbjW6cy0pjjGe/Qu3ewygMOYscWA2wJZi1 MwwzBaP16GQzvC1JydFVnr9sAAb+6L/higR8K6NiFIATO9uDVKVaSe5BwUCCM6y4W5LY PYABNVY+6mZF5t6FfC/cJrweVyyu+oNx0IlmaAu8bFVTuEa+fe+Xx3d604CG8nJC6NKT 2Org== 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=uw5Ocx7V5IOaKkzAwx8ZYzJoQbHiH28/mNakL75NWLmYhpVtnhCvk5sacTzQbBFOGG /vKHWt8a6ypTWj3vo6kz6OTliiKNPe813rFaVYXk6y5qa/eyUW8aC+ysxqyd883sZhQk BLxtKHpKZwrCIJ6QQnm+1/BVyPlC5EnDuF6iovepT3TCWNHhnQ/cIGftMIkawu4m45Fo XY6cRwr9JvNMpBH0hN3j825YqEngV370RLcCZqB0sxxjGTGHF202Qio63whH1mwzeguO 3Dja1UNeW0etmpDy6I166hGSTYeuFmgWw4dU3bHFPOsOyRbW9ALItWjnNmBlEprf2Mwk pnPg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=FqAoNjaB; dkim=neutral (no key) header.i=@linutronix.de header.b=TSOchCPg; 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 pf14-20020a17090b1d8e00b00200ad6b1554si16755953pjb.6.2022.11.14.09.15.05; Mon, 14 Nov 2022 09:15:21 -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=FqAoNjaB; dkim=neutral (no key) header.i=@linutronix.de header.b=TSOchCPg; 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 S237600AbiKNQaJ (ORCPT + 87 others); Mon, 14 Nov 2022 11:30:09 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35558 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237539AbiKNQ3l (ORCPT ); Mon, 14 Nov 2022 11:29:41 -0500 Received: from galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1C99426B; Mon, 14 Nov 2022 08:29:40 -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=WyGtVM99u5kVDH70iZExE1J1KzxzFf6H5/dTCHJGWmg=; b=FqAoNjaBB2Rlp2mNiLSbghpPzLzwe/mxSu1PahgKtAnhy0JYz8REmdtNz9jHFQFaj113nY ywZ/YEc1WnqLUt/lbm8feA+MyPzbJIRZv3VyR+hVIHoOTru/KIzygWDs2cWOkXnelZvsoo 32AkyhpdUEvPRj7CPilKpeib4j1jznLqH+nKWXz7/7IBnl7Xk86MCDk0tWzXGSqSVG/RUv QRAw1Gqdw/S2PhYt+lV+WuN3kZ8zlf7KMaF8BftoCfYw9WENgLe5lBCaUXBOUsalZFaZAb 9ZPCStORGaRXJVDKwcBdwVGTJacSupeBxD5165H9Ma8QabshUKzxXOyMSguQiA== 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=WyGtVM99u5kVDH70iZExE1J1KzxzFf6H5/dTCHJGWmg=; b=TSOchCPgjdlhJPka+GKTvoyPM/0XtrZC5Yjg7o2tlsAmZW/yw3oP7dxd3MB5cXFma4zBBg 1gDZE59V6J1GTfDQ== 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 v4 09/39] proc: consoles: document console_lock usage Date: Mon, 14 Nov 2022 17:35:02 +0106 Message-Id: <20221114162932.141883-10-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 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