Received: by 2002:a05:6358:1087:b0:cb:c9d3:cd90 with SMTP id j7csp516537rwi; Thu, 20 Oct 2022 01:33:09 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4GiwvfxzxqDy+n4ZkeFRSUrnWo9OLH9rGMwe8G2e1sKmIkbSTpsqVMvRx0YQZx+3vsG4wE X-Received: by 2002:a17:907:2d0b:b0:78e:674:6b32 with SMTP id gs11-20020a1709072d0b00b0078e06746b32mr9925988ejc.226.1666254789325; Thu, 20 Oct 2022 01:33:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666254789; cv=none; d=google.com; s=arc-20160816; b=pgwR+2MEiNxkaFxibtnappL9kn0vXtp8c+bIoWQ/QqDZPKop64zhkK+gTcXiCBGieW /mL8SxOw6p9kStAUIStbyqkm8xCVDeX2WuYWBAkoRg5p23wHoA8ub1Tt+KuKNAepbNiF yYTAeOEwfMFvRd0JAC1aKQoL7wNX0L8Qi/1WVuNgmpkNS+LaJQ7s2JYMu7ajzM+rswGP 7TL2gpY4U4aSeQoypU4+jCmFQ0U18E7ZggI45BIQXGR5z/wFMHuWxPh5ydFdBzzcYXuc goljULExVSDWw2vHQsZ/DE9E2U73M8s6UB39vTF5tje9J/SvEPPPEQ0ABgtimPUA7SB7 pF4Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=gaJMagPscRDDrY47nF1qDOGZCqWd/UKHpEre1+sj5Vk=; b=xXIpmc1e+SHTKtlT1r/gcaohqjBntsagRToZc0nyb+olwemqlbRoXRw52H0cUSBHV1 2jrGIOy2rOeSozwcuKsjXFeDH7+Kx9dH673MIPL27LRfA4/mRE6fRAIblnoCuIX9Js9D CRcz6Pu6O2+FakwW67l3ryhYexxTk7fSPI9I+tHVr/cVo+P8p4G+njMA7idp9J1J0RFT sWzlbtWZh1jvhJJM8IZV+EdXMAEYe/B+9c/XzPXirFXfPsqawra0/CPL0DVqO68aFoBF Xyw15Dthffemhe2DwAwvYeA9ED69vTlsuWfCIQempDErdyxJdGsyV1Yc+qpAUpTg8LNJ l3uA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=IbrjTATv; 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=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id m25-20020aa7d359000000b004597aa082ddsi13862382edr.257.2022.10.20.01.32.44; Thu, 20 Oct 2022 01:33:09 -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=@linuxfoundation.org header.s=korg header.b=IbrjTATv; 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=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230035AbiJTHnp (ORCPT + 99 others); Thu, 20 Oct 2022 03:43:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56690 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231124AbiJTHnS (ORCPT ); Thu, 20 Oct 2022 03:43:18 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2F743175785; Thu, 20 Oct 2022 00:43:05 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id F3DF4B8265F; Thu, 20 Oct 2022 07:42:43 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 44184C433C1; Thu, 20 Oct 2022 07:42:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1666251762; bh=xRdVE9aidjuImN/AuV60ZkxbXja2doJEERbOAXKZNRE=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=IbrjTATvAI5DDOIzrV+B3jYVi019tIBwGxApFj9ewolUMaoHhqheBqZ+7Dgj2bp3d t9tKajcmMeu9z9qkmQ9nqsk4DRHGyhPNwRWENrDnUsPM75hroToM1/6UvKVd5fES3o w0ceeG1qALz8GEaD0r5Ga0sWcmUruwDMLb5E0Vkk= Date: Thu, 20 Oct 2022 09:42:39 +0200 From: Greg Kroah-Hartman To: John Ogness Cc: Petr Mladek , Sergey Senozhatsky , Steven Rostedt , Thomas Gleixner , linux-kernel@vger.kernel.org, Jason Wessel , Daniel Thompson , Douglas Anderson , Jiri Slaby , kgdb-bugreport@lists.sourceforge.net, linux-serial@vger.kernel.org Subject: Re: [PATCH printk v2 22/38] serial: kgdboc: document console_lock usage Message-ID: References: <20221019145600.1282823-1-john.ogness@linutronix.de> <20221019145600.1282823-23-john.ogness@linutronix.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20221019145600.1282823-23-john.ogness@linutronix.de> X-Spam-Status: No, score=-7.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED 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 On Wed, Oct 19, 2022 at 05:01:44PM +0206, John Ogness wrote: > kgdboc_earlycon_init() uses the console_lock to ensure that no consoles > are unregistered until the kgdboc_earlycon is setup. This is necessary > because the trapping of the exit() callback assumes that the exit() > callback is not called before the trap is setup. > > Explicitly document this non-typical console_lock usage. > > Signed-off-by: John Ogness > --- > drivers/tty/serial/kgdboc.c | 8 ++++++++ > 1 file changed, 8 insertions(+) > > diff --git a/drivers/tty/serial/kgdboc.c b/drivers/tty/serial/kgdboc.c > index e9d3f8c6e3dc..48000666789a 100644 > --- a/drivers/tty/serial/kgdboc.c > +++ b/drivers/tty/serial/kgdboc.c > @@ -545,6 +545,14 @@ static int __init kgdboc_earlycon_init(char *opt) > * Look for a matching console, or if the name was left blank just > * pick the first one we find. > */ > + > + /* > + * Hold the console_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. > + */ > console_lock(); > for_each_console(con) { > if (con->write && con->read && > -- > 2.30.2 > Reviewed-by: Greg Kroah-Hartman