Message ID | 20221114162932.141883-33-john.ogness@linutronix.de |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp2239288wru; Mon, 14 Nov 2022 08:33:25 -0800 (PST) X-Google-Smtp-Source: AA0mqf54YWOu554hoQuH5vxs1aTAwrjhUM2J/rFby4hUNc1FN7aSIqEXpmNsmoqiqQGueUP/JQFs X-Received: by 2002:a17:906:348a:b0:78d:85fe:4946 with SMTP id g10-20020a170906348a00b0078d85fe4946mr11600587ejb.268.1668443605023; Mon, 14 Nov 2022 08:33:25 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668443605; cv=none; d=google.com; s=arc-20160816; b=iUMs7+PPbOA4iS/G/4oabfy9qK07SJH+B++BdhGjoq2sLxiyjzZjwObke2Lc2yROOh gj0jjRWvFniVYLzsalj/RUH4NffbjzY5wlKdKLMrLm5IexxO0vV4cZbCFF5VbBO6+CIj 4AeVwbj/+k51jBLyzYClA+ttxTMeDftG8YL9ZdQFU0W/X7VrjufbcNQglEL5Ys2qw8il 8T1Q4VDIuSLTT+lAEO/UDyWn5Se9RmbayFsIWT7lZqCfQ+Yk8X2JEEc6EgZPojiMV+Sw JuM6E6riDmhYeJD+yHZA+pn9brpKuTgwLpE8S3XLboAtDgJ6tPqKBLafk7h3vceINfDQ AIiA== 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=OuuuTA4YWeOsJFG5PLdantkjarf2V1vxrJ2SuyPt64s=; b=jp0NQ9F6tyZq6knRIIGgMw2ViV8KxhEYrQesrg4ewuV2tFX53gMGXu73n1g+2n3xdu 21O+4krW5zlNrAro2hAQrFiIRznpMbOuhV3lxqzSybiW4fEMRRqLpjOTbUp6f/2FhBKV QBQZ+N9m8EeQzOq7vGP2jnKp+TeV6kOOYTmG1FoA+mzfWA12vsEbJswpVzsyc6HQgsvI 39HENfYK4LDPCbJ/klCYvziJNvz5eVcty8nz+xg6IfJOyIDftNHfyjEiMVeDrsYwYifp TWKZsJogp1z7knkJwhabJx+wPXWnuV/kE15NhYnqtrir3ttQnQrVnKPFuHSisvZp9elI WTZQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=e4RGxHKa; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e; 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 c6-20020a50d646000000b00461f5bb2b79si6506884edj.458.2022.11.14.08.32.24; Mon, 14 Nov 2022 08:33:25 -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=e4RGxHKa; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e; 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 S237830AbiKNQbc (ORCPT <rfc822;winker.wchi@gmail.com> + 99 others); Mon, 14 Nov 2022 11:31:32 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38268 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237685AbiKNQan (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Mon, 14 Nov 2022 11:30:43 -0500 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 108D32F013 for <linux-kernel@vger.kernel.org>; Mon, 14 Nov 2022 08:29:49 -0800 (PST) From: John Ogness <john.ogness@linutronix.de> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1668443388; 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=OuuuTA4YWeOsJFG5PLdantkjarf2V1vxrJ2SuyPt64s=; b=e4RGxHKaV+A6csE32Npmc1LaNjJO+yGnaJgyxNw2Ydb3n/MlFfdp82k5IGopNh9rhkPYDc uw5hpPJdQ9ylYsQ9smrb/4vApeL9YZXdK5GIKLZKXolbEeKOusV0baI8MatuMHZXt/Zdl7 vRLvig/O1OpP2pw0iChfCqh7HN9Zm/S155mIsokKbczREbnhitaxZY+66E1BHVfkMmbCHq rTno7pXQLb2kcRRDNrWP2OwmNRLYWATgHQ3tNRdCoJKvWl1JiKCXVDEOwu64fTcFNkRdA2 SeNwU1lAURpblTJJrxMfJRupptlyB9Qwcss3zfW1BRc6/a9btE8XWyYHzQTjIw== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1668443388; 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=OuuuTA4YWeOsJFG5PLdantkjarf2V1vxrJ2SuyPt64s=; b=E+rT8J6y62Ltbv82PAwVnzioIzj4vZKL8ItN+HqqGjerV11bIFE3QSoLN6mLQ97U8z8pGq sAn83Tyri7FWyCAA== To: Petr Mladek <pmladek@suse.com> Cc: Sergey Senozhatsky <senozhatsky@chromium.org>, Steven Rostedt <rostedt@goodmis.org>, Thomas Gleixner <tglx@linutronix.de>, linux-kernel@vger.kernel.org, Greg Kroah-Hartman <gregkh@linuxfoundation.org>, Jiri Slaby <jirislaby@kernel.org> Subject: [PATCH printk v4 32/39] tty: tty_io: use console_list_lock for list synchronization Date: Mon, 14 Nov 2022 17:35:25 +0106 Message-Id: <20221114162932.141883-33-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: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1749489921806972166?= X-GMAIL-MSGID: =?utf-8?q?1749489921806972166?= |
Series |
reduce console_lock scope
|
|
Commit Message
John Ogness
Nov. 14, 2022, 4:29 p.m. UTC
show_cons_active() uses the console_lock to gather information on registered consoles. It requires that no consoles are unregistered until it is finished. The console_list_lock should be used because list synchronization responsibility will be removed from the console_lock in a later change. Note, the console_lock is still needed to serialize the device() callback with other console operations. Signed-off-by: John Ogness <john.ogness@linutronix.de> Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Reviewed-by: Petr Mladek <pmladek@suse.com> --- drivers/tty/tty_io.c | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-)
diff --git a/drivers/tty/tty_io.c b/drivers/tty/tty_io.c index ee4da2fec328..cafdff575716 100644 --- a/drivers/tty/tty_io.c +++ b/drivers/tty/tty_io.c @@ -3527,16 +3527,13 @@ static ssize_t show_cons_active(struct device *dev, ssize_t count = 0; /* - * Hold the console_lock to guarantee that no consoles are + * Hold the console_list_lock to guarantee that no consoles are * unregistered until all console processing is complete. * This also allows safe traversal of the console list and * race-free reading of @flags. - * - * Take console_lock to serialize device() callback with - * other console operations. For example, fg_console is - * modified under console_lock when switching vt. */ - console_lock(); + console_list_lock(); + for_each_console(c) { if (!c->device) continue; @@ -3548,6 +3545,13 @@ static ssize_t show_cons_active(struct device *dev, if (i >= ARRAY_SIZE(cs)) break; } + + /* + * Take console_lock to serialize device() callback with + * other console operations. For example, fg_console is + * modified under console_lock when switching vt. + */ + console_lock(); while (i--) { int index = cs[i]->index; struct tty_driver *drv = cs[i]->device(cs[i], &index); @@ -3563,6 +3567,8 @@ static ssize_t show_cons_active(struct device *dev, } console_unlock(); + console_list_unlock(); + return count; } static DEVICE_ATTR(active, S_IRUGO, show_cons_active, NULL);