Received: by 2002:a05:622a:251a:b0:39a:b4a2:e86 with SMTP id cm26csp529473qtb; Wed, 19 Oct 2022 08:11:42 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6xZ1h1vbXumgZhA1W8wxkcOwwhDq6t2foxOSB604WwJt3THT6lZueK6teFnyqcdDtfwGQk X-Received: by 2002:a17:906:730c:b0:791:997f:d65d with SMTP id di12-20020a170906730c00b00791997fd65dmr7361899ejc.18.1666192302277; Wed, 19 Oct 2022 08:11:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666192302; cv=none; d=google.com; s=arc-20160816; b=cAPQ9tczPiVDTyk63M8r1dur03RWMYwuqvRVtiWYhpzu8dcTVgiZwZDSOnOIHKBmG6 a1p0vbc4HBePSJ+J9wclKLcZy5jPVuTYljnsTSBLmsmDqPOLBGT3p37LMDI31QxMZ+74 uU01FrBIx6uH+DK8hAY7zyKR0ihn2sAtmzW59VbnWyjcJxdVFPZULqzQ7M70YQ/i8c49 r1gbXn/LYw7T2QQDreolrSl4h7MsRV4V1n5JzTdOKECVUdM6AkfMGlYFfHuL4oECd7LK yRBIjkC36cZpPqj82jl8mWGj/Mg2TV642dy3C/RYs3aLQrjMIae+WFmt892/EK6ZObGr r/mw== 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=vk9lLFSPw7DVFHn+Ltr9+ux4PzL45JriVQ+GTbz1WOY=; b=EK5+Sl7RRycigi1xgCpc1e/ZklpWCkacOe/zGWStrLF8cLDMVovxUjyqMppnWQwTYy DxCh6AqVaTtEhAMhQOCa/03H6G2jvhZaD8Et6QPO2IEzDi/9+U0Rn64xAOPbvc6NL1n3 uwTObEq+ZRhsGJAwtHDwrzVB6iug8s4pCwP56Vm0DjpRoMJlRBQv7O6drm/VLk16EegC SaIHZcUYdpT1NoYD9ehekIGyP3UD9SaWWay1rSfC4pR5wrjG6XiYIqtU+i4QOSBgx1jc zjnohDlcrmgyI/Wkr6SQt636MhfpM+Z2efDpBSDSK0EQbBBhQVgQDwWtZQqJsijSkzz4 xbtQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=qy+XfEMT; 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 g10-20020a1709065d0a00b0078277d265bcsi13738452ejt.204.2022.10.19.08.11.15; Wed, 19 Oct 2022 08:11:42 -0700 (PDT) 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=qy+XfEMT; 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 S229784AbiJSPHJ (ORCPT + 99 others); Wed, 19 Oct 2022 11:07:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40948 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231754AbiJSPFq (ORCPT ); Wed, 19 Oct 2022 11:05:46 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DACD4BE38; Wed, 19 Oct 2022 07:59:24 -0700 (PDT) From: John Ogness DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1666191376; 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=vk9lLFSPw7DVFHn+Ltr9+ux4PzL45JriVQ+GTbz1WOY=; b=qy+XfEMThEbkLnrE1n36Z2pN+sVWm/xcWaaykneLdYt/vpE15mr9kwHlg/KLo+RWPWYf34 etPdErRihRuc+qZDB4lMGkJwkzOj0k873ip2RAnXf1ME6l4C75Nr7d+ZfLt0A0Xix765FH uOFeEgTaLBDP2HXzMyNMjWIC6zZ5DT5w5YwqCIu/1LYCInpQWEgjFfzVpFkk5Po66g2mEg NgEYb4GBaW4tD2U/AaebbabvrhjAUfC3V7esyJ4gKfuPnB8m9poV9ANs+Oggu69i9E/XY4 u16HcZa6/YcQ4gML73ZuMD0kDTA/mUUFqcAiH6w2xMHdUNjXCQYt02KOINdzng== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1666191376; 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=vk9lLFSPw7DVFHn+Ltr9+ux4PzL45JriVQ+GTbz1WOY=; b=Bczhayh0iGG8icRI55cYRrg7pJAHOfB2u8QZ/VTPoePhI61+DqIcsXd3xFHatJNL5JU+gj 3w0K/ax5IwNRZjBw== To: Petr Mladek Cc: Sergey Senozhatsky , Steven Rostedt , Thomas Gleixner , linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org Subject: [PATCH printk v2 25/38] proc: consoles: document console_lock usage Date: Wed, 19 Oct 2022 17:01:47 +0206 Message-Id: <20221019145600.1282823-26-john.ogness@linutronix.de> In-Reply-To: <20221019145600.1282823-1-john.ogness@linutronix.de> References: <20221019145600.1282823-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 | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/fs/proc/consoles.c b/fs/proc/consoles.c index cf2e0788f9c7..32512b477605 100644 --- a/fs/proc/consoles.c +++ b/fs/proc/consoles.c @@ -63,6 +63,14 @@ static void *c_start(struct seq_file *m, loff_t *pos) struct console *con; loff_t off = 0; + /* + * Stop console printing because the device() callback may + * assume the console is not within its write() callback. + * + * 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