From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 45390C433FE for ; Thu, 17 Nov 2022 11:09:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234839AbiKQLJT (ORCPT ); Thu, 17 Nov 2022 06:09:19 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55026 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239771AbiKQLIQ (ORCPT ); Thu, 17 Nov 2022 06:08:16 -0500 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E55BD69DEF; Thu, 17 Nov 2022 03:08:14 -0800 (PST) From: John Ogness DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1668683293; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=fM6pYfjkvRx7D7oK5QPuCSEfKgQ75z+OzhgRrY5Yew0=; b=NHfM5e69zJKKBVggrBKMdzCfCQ/i0woaUHO1FuTmngDf6Enqb3JsIZ5OslxwnAjQaI5YnF 2fyOkINghdiSpnDop2rk5F1FCadPVLEiYjRD9shRNBjzEBkQe3pKtMakInkjLEubdyfadX CKnygxiBuqGR+qkcO4YIDgFUo/67kb8yc+FazMktocPrN2HR65KngYoBpFmoKT4x3yLobC hlZAt0vuzLQw2tsfrQ+sHg+U4NwpsJBjSM8eWRaQfJqvD1TsbI5Gk/3Y+AxIjjAQeK1Wf6 vG7s1rP4bMgrdVKNWHYnpfPlh1STzAphJo3fL84enaSIWWmhZpnfSENZNSXeZg== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1668683293; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=fM6pYfjkvRx7D7oK5QPuCSEfKgQ75z+OzhgRrY5Yew0=; b=2VKA10Ovb0d8YDLPtBnjaYd9pwyjhK6e+g1zXJWgFLQB0TUpM7kQQM/siDEKLe9NLpdKQX 1C2bbwpsn4uPCEAw== To: Doug Anderson Cc: Petr Mladek , Sergey Senozhatsky , Steven Rostedt , Thomas Gleixner , linux-kernel@vger.kernel.org, Jason Wessel , Daniel Thompson , Greg Kroah-Hartman , Jiri Slaby , kgdb-bugreport@lists.sourceforge.net, linux-serial@vger.kernel.org Subject: Re: [PATCH printk v5 38/40] tty: serial: kgdboc: use console_list_lock to trap exit In-Reply-To: References: <20221116162152.193147-1-john.ogness@linutronix.de> <20221116162152.193147-39-john.ogness@linutronix.de> Date: Thu, 17 Nov 2022 12:14:09 +0106 Message-ID: <87mt8pon3a.fsf@jogness.linutronix.de> MIME-Version: 1.0 Content-Type: text/plain Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2022-11-16, Doug Anderson 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