Message ID | 20221116162152.193147-39-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 l7csp238101wru; Wed, 16 Nov 2022 08:35:50 -0800 (PST) X-Google-Smtp-Source: AA0mqf47nQB4sWvAYLe+Bp2nzYpQ/T9WaC1zva9rlpG26bAMLZaqLM/wQJTyhDKMUJUoKGgAK7cs X-Received: by 2002:a17:902:70c3:b0:186:af8e:7ed4 with SMTP id l3-20020a17090270c300b00186af8e7ed4mr9682489plt.7.1668616550305; Wed, 16 Nov 2022 08:35:50 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668616550; cv=none; d=google.com; s=arc-20160816; b=QWIuwGBb9QSNlJI2QRAS2QwXIxCjUqABDkASjyeTNdGIyqYlhLjSsTmNw4pT1AbipY NJjIiQhu/pJ4gw/w0QDQvdHtbm5eeqwXqV9CxbOytweeOHhc51acB1ZQkw1x8LObUUj4 MLhWb3F9L0p0U+lc81prlpSq6kqsakmBSujjLGSf6gvNSFMpik2asM9FwFeCKIUrey8V vdSywJ6u2tjnDxOaJx/2TpTvsjSUcut+iqyC5xkZLaOQ7kWNsBC4IShjAexc+c56oxev 8XyVHsm/9Xwt+tuU3VUqb+QqiVev98wX5npJiVbzG9rkuHCHWcua5R789XnphEMsS0SD Y8Ag== 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=R9VqGyF+glKoWbwrATKZGXQP3ZfoC2SELt3pYx7i6e4=; b=oOkr1ysd9dSsSBi+pjKUthH9Z9sePRO3HCeKMfHwYbyQD1bdvXFgj/X1SRTuC5QiaC BMrJU5BSQhIGPLEdq6IMcZcZOKqFqmy+fdXBJlK2ax5axiUAlYUrWE6OUEjIkQwg6irc yS2XweBukzZRtBBys1cjW1dES3RT/NQypo3d9tyfGT7qoJWCV8fwFYXfAN33VGnpqKvY 7a8sVvWpCMH8rtMwe3YOHTlMglTGJJKoFFW1l6EeUDnpUM5eZNxzdQhfdgl//H79Gsin goc+8mvOhQbfrFcALZdtyBJgYGodfFVbdk6bFXEYIOquWMesQouMsTTMSE/k5y+/EV7b FdBg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=JFsQt9Ym; dkim=neutral (no key) header.i=@linutronix.de header.b=4QlR9bdm; 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 e20-20020a63f554000000b0046fe97419aasi16040567pgk.120.2022.11.16.08.35.36; Wed, 16 Nov 2022 08:35:50 -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=JFsQt9Ym; dkim=neutral (no key) header.i=@linutronix.de header.b=4QlR9bdm; 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 S238808AbiKPQ0I (ORCPT <rfc822;just.gull.subs@gmail.com> + 99 others); Wed, 16 Nov 2022 11:26:08 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58754 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238551AbiKPQXR (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Wed, 16 Nov 2022 11:23:17 -0500 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3FED059848; Wed, 16 Nov 2022 08:22:18 -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=1668615736; 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=R9VqGyF+glKoWbwrATKZGXQP3ZfoC2SELt3pYx7i6e4=; b=JFsQt9YmKmGYiNMCmtvxB3r69uHQoFqE8e46/QPCeV4UzhXpIrH/WBkT8OVqrE9LmK1igd 8MYMnuoCiKcekVXCEqztixtf06Z+X0tmr4ZCp4z2KnxJX4XizYz6iFOt4XbmEnOrfWpMEd 9pJfm2udp0lnzaqCp9qDyM7fk/zZO8dGcumh8J4QcUMBqF2OsCea9tAj0AmtK+QRm10uw2 STmOa5knG3Xl4Ae3JELKSNNr1ur3iSmPTmxeT36HTAadHweraHKRNB9IUvEnThYR5yot/r BFK8xrc0lOODKN2Lb2Rqnd0X+EUw0Z5u+ngrj+fd0rY+uQAN8YbkjA/WOCmrAw== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1668615736; 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=R9VqGyF+glKoWbwrATKZGXQP3ZfoC2SELt3pYx7i6e4=; b=4QlR9bdmeVF94Qc5Vu64CzXPINchKf2DFGK9G/aISYm0uexwOLYizOLQ6gSDk2jDy/Sr04 FB7QWs6ZgcD1g+Cw== 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, Jason Wessel <jason.wessel@windriver.com>, Daniel Thompson <daniel.thompson@linaro.org>, Douglas Anderson <dianders@chromium.org>, Greg Kroah-Hartman <gregkh@linuxfoundation.org>, Jiri Slaby <jirislaby@kernel.org>, kgdb-bugreport@lists.sourceforge.net, linux-serial@vger.kernel.org Subject: [PATCH printk v5 38/40] tty: serial: kgdboc: use console_list_lock to trap exit Date: Wed, 16 Nov 2022 17:27:50 +0106 Message-Id: <20221116162152.193147-39-john.ogness@linutronix.de> In-Reply-To: <20221116162152.193147-1-john.ogness@linutronix.de> References: <20221116162152.193147-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?1749671267533369546?= X-GMAIL-MSGID: =?utf-8?q?1749671267533369546?= |
Series |
reduce console_lock scope
|
|
Commit Message
John Ogness
Nov. 16, 2022, 4:21 p.m. UTC
kgdboc_earlycon_init() uses the console_lock to ensure that no consoles are unregistered until the kgdboc_earlycon is setup. The console_list_lock should be used instead because list synchronization responsibility will be removed from the console_lock in a later change. Signed-off-by: John Ogness <john.ogness@linutronix.de> Reviewed-by: Daniel Thompson <daniel.thompson@linaro.org> Reviewed-by: Petr Mladek <pmladek@suse.com> --- drivers/tty/serial/kgdboc.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
Comments
Hi, On Wed, Nov 16, 2022 at 8:22 AM John Ogness <john.ogness@linutronix.de> wrote: > > kgdboc_earlycon_init() uses the console_lock to ensure that no consoles > are unregistered until the kgdboc_earlycon is setup. The console_list_lock > should be used instead because list synchronization responsibility will > be removed from the console_lock in a later change. > > Signed-off-by: John Ogness <john.ogness@linutronix.de> > Reviewed-by: Daniel Thompson <daniel.thompson@linaro.org> > Reviewed-by: Petr Mladek <pmladek@suse.com> > --- > drivers/tty/serial/kgdboc.c | 6 +++--- > 1 file changed, 3 insertions(+), 3 deletions(-) > > diff --git a/drivers/tty/serial/kgdboc.c b/drivers/tty/serial/kgdboc.c > index 8c2b7ccdfebf..a3ed9b34e2ab 100644 > --- a/drivers/tty/serial/kgdboc.c > +++ b/drivers/tty/serial/kgdboc.c > @@ -558,13 +558,13 @@ static int __init kgdboc_earlycon_init(char *opt) > */ > > /* > - * Hold the console_lock to guarantee that no consoles are > + * Hold the console_list_lock to guarantee that no consoles are > * unregistered until the kgdboc_earlycon setup is complete. > * Trapping the exit() callback relies on exit() not being > * called until the trap is setup. This also allows safe > * traversal of the console list and race-free reading of @flags. > */ > - console_lock(); > + console_list_lock(); > for_each_console(con) { > if (con->write && con->read && > (con->flags & (CON_BOOT | CON_ENABLED)) && Officially don't we need both the list lock and normal lock here since we're reaching into the consoles? -Doug
On 2022-11-16, Doug Anderson <dianders@chromium.org> wrote: >> /* >> - * Hold the console_lock to guarantee that no consoles are >> + * Hold the console_list_lock to guarantee that no consoles are >> * unregistered until the kgdboc_earlycon setup is complete. >> * Trapping the exit() callback relies on exit() not being >> * called until the trap is setup. This also allows safe >> * traversal of the console list and race-free reading of @flags. >> */ >> - console_lock(); >> + console_list_lock(); >> for_each_console(con) { >> if (con->write && con->read && >> (con->flags & (CON_BOOT | CON_ENABLED)) && > > Officially don't we need both the list lock and normal lock here since > we're reaching into the consoles? AFAICT the only synchronization we need here is iterating the console list, reading con->flags of a registered console, and modifying con->exit of a registered console. The console_list_lock provides synchronization for all of these things. By the end of this series the console_lock does not provide synchronization for any of these things. Is there something else that requires synchronization here? After this series the console_lock is still responsible for: - serializing console->write() callbacks - stopping console->write() callbacks - stopping console->device() callbacks - synchronizing console->seq - synchronizing console->dropped - synchronizing the global @console_suspended - providing various unclear protection for vt consoles - some bizarre misuses in bcache The scope may be larger than the above list. The investigation is still ongoing. John
diff --git a/drivers/tty/serial/kgdboc.c b/drivers/tty/serial/kgdboc.c index 8c2b7ccdfebf..a3ed9b34e2ab 100644 --- a/drivers/tty/serial/kgdboc.c +++ b/drivers/tty/serial/kgdboc.c @@ -558,13 +558,13 @@ static int __init kgdboc_earlycon_init(char *opt) */ /* - * Hold the console_lock to guarantee that no consoles are + * Hold the console_list_lock to guarantee that no consoles are * unregistered until the kgdboc_earlycon setup is complete. * Trapping the exit() callback relies on exit() not being * called until the trap is setup. This also allows safe * traversal of the console list and race-free reading of @flags. */ - console_lock(); + console_list_lock(); for_each_console(con) { if (con->write && con->read && (con->flags & (CON_BOOT | CON_ENABLED)) && @@ -606,7 +606,7 @@ static int __init kgdboc_earlycon_init(char *opt) } unlock: - console_unlock(); + console_list_unlock(); /* Non-zero means malformed option so we always return zero */ return 0;