From patchwork Wed Oct 19 14:55:47 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Ogness X-Patchwork-Id: 5646 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp379247wrs; Wed, 19 Oct 2022 08:10:32 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6wZFiKZTx2l0o3hkebYJ6bIyjl34qrD3ruELlK3qciMWhQJ05DtN73+pKDY8s4XZ92Wvxl X-Received: by 2002:a05:6402:c4d:b0:457:99ec:1837 with SMTP id cs13-20020a0564020c4d00b0045799ec1837mr7880039edb.86.1666192232738; Wed, 19 Oct 2022 08:10:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666192232; cv=none; d=google.com; s=arc-20160816; b=D9H38dUKgHZu4ZumpZSlOYKUtNONmAxEFaQsJI7GUUkreO2mFU0qswPsBwzHlpgb8A Xi6pl9mOzPlWHSUeDoCdf9m1V2Wn8je1n7WC6OR01OCqVNHzRZfNyoslxFUjVFLprz74 DUPmBer4yNdUHYt9UGJLGksJGs7UpVOphjCam7YPqXd2JAvZFlDUEFg9Eb7xjL9nvYED Ek8FGR0c5fqAnG8ldw3nlVTDOd3zzJHvHWfuyXV6RUssfm48/pNo5jrtLGa/WAlcCm5P 4S0GTKssnwMX95z5732uk57OuLAqmAm38z7lzo412TlQQnj8ljCq+q8vQ9pJxj4bLNll Xi3A== 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 header.s=2020e header.b=Bczhayh0; 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 g10-20020a1709065d0a00b0078277d265bcsi13738452ejt.204.2022.10.19.08.10.04; Wed, 19 Oct 2022 08:10:32 -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 header.s=2020e header.b=Bczhayh0; 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 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?1747129186611816604?= X-GMAIL-MSGID: =?utf-8?q?1747129186611816604?= 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)