Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp1992808rwb; Mon, 7 Nov 2022 08:01:23 -0800 (PST) X-Google-Smtp-Source: AMsMyM4CnsHJ3G1RPPzGa84wmOpdE5sz31LNXn1N3ReEHzYRLmRS50zPibRnB+JEYJP+TiFOUM/j X-Received: by 2002:a17:907:75d0:b0:7ad:8a7a:1a53 with SMTP id jl16-20020a17090775d000b007ad8a7a1a53mr47963730ejc.47.1667836883121; Mon, 07 Nov 2022 08:01:23 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1667836883; cv=none; d=google.com; s=arc-20160816; b=DIgWOs12SFm59KgTGGtZQgln6ef6ybeVvlWj4Se39C4IUtRF+/egvtzJUjIx6D5Ot3 BzRk6jm/QmsONkPtUMbMvNSWL/tqL3lM+yeinHN90axAPbXDmmufxU+v2pkGiJDKzdkj bAdXBKyaF2OT3hrStlEf7okDdKpBuuBKgORNg29gLpfmiM+c29D/BXQhkCfK7Wo96u4j s2ZDr/yBf/XvDgtaCwuOEOtjp1OPBziH0bqMuo+JC84oxvnhurUNt3wXh9VcWatDiUfY pWbU6LvM/PuiG1BF2QRqn7GqcY0/HYAZ45Hb6aFGR/mIggcZF0Z6QuMChUk7iYtF7Pf6 foTQ== 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=I3yaMFjrCtNc3Px6vqfLokWlErUgA/SSe6zXZ59V8XY=; b=XylTgzFGGiw/CjeqD63Cl/o5w8VHWsgwWvby+wzi4CPgK1DI2qKUvQuzAoi6NqcS+Q AGGHz/VPAwYBC53RjOxfs74oFvUXAAekkErI8q/nUlkROj9d7Oo5H570UrPbZPgsrJ1y slbnvzB2U2MBGwk8aRohmFn0L6+SbMT0JzVs7/am5WBFVX9AWtMIoJGME/+Fhdq3/wA7 eCM0Y6/3UtrEoHRMdDIFBUHvHpMgLGbDQ4OvIsoWmTFIPDuZoM7kAbtiZqllzyawBhNo KweO7z54vk6tjpD9ZtinxEexSjTDRu4z7YrVc509miu5p6KEPgvfjY9JRQEwDbOcNoVi CNdA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=W7M6kX4a; dkim=neutral (no key) header.i=@linutronix.de header.b=YNgZvTTc; 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 b8-20020a056402278800b0045928479b71si11843289ede.405.2022.11.07.08.00.57; Mon, 07 Nov 2022 08:01: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=W7M6kX4a; dkim=neutral (no key) header.i=@linutronix.de header.b=YNgZvTTc; 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 S232285AbiKGORp (ORCPT + 93 others); Mon, 7 Nov 2022 09:17:45 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55748 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232148AbiKGOQu (ORCPT ); Mon, 7 Nov 2022 09:16:50 -0500 Received: from galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 54DE11D0FE; Mon, 7 Nov 2022 06:16:48 -0800 (PST) From: John Ogness DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1667830607; 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=I3yaMFjrCtNc3Px6vqfLokWlErUgA/SSe6zXZ59V8XY=; b=W7M6kX4aY2WaQhigk++ZxU/cDgnvB3Dl9STk1+geoLoCGHp7UPBDY5v+NeZ90ucRfC2HZc lDRqkLNmPbRjBpCbHs5tsKGthjWVMLdZWMxiNEI7NckgFq/qionlE3HamxH3X/5XmEp8i/ LvYvxgNjfgydovwy55cK34wbW767izonqt76pbi9y9xO0RkwY4CcHMM+xntUfQSktX66yz ojtVw2XzoK4YTR9iApgdp4QpWG0d3UrJirmW+3fYtI6H0PCdW8LnrEW/UfVs02EMFXShG/ ChC8lj5RsSsKp0+AoiQTwUUxu+kE5nZjTLQvr/wycTrZpqCOEAgBCZU8fBxvGg== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1667830607; 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=I3yaMFjrCtNc3Px6vqfLokWlErUgA/SSe6zXZ59V8XY=; b=YNgZvTTcrT+PyJJnxSALPiorJ0D8azX4yxEjkhd6xJt1i0DwjJgqovqxZLibOchEzYHoDL 88GvZxS2AnRgV7CQ== 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 v3 14/40] proc: consoles: document console_lock usage Date: Mon, 7 Nov 2022 15:22:12 +0106 Message-Id: <20221107141638.3790965-15-john.ogness@linutronix.de> In-Reply-To: <20221107141638.3790965-1-john.ogness@linutronix.de> References: <20221107141638.3790965-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 --- 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