Received: by 2002:a05:6358:45e:b0:b5:b6eb:e1f9 with SMTP id 30csp932422rwe; Thu, 1 Sep 2022 09:42:48 -0700 (PDT) X-Google-Smtp-Source: AA6agR6rBZyF7t2QKfi0LNnCtLBUc/TTKyFMjoMYx+ghcnyPXadHPRDjdDaj0WqIJHGaZHu5o7z5 X-Received: by 2002:a17:902:ef50:b0:170:9f15:b998 with SMTP id e16-20020a170902ef5000b001709f15b998mr31779305plx.102.1662050568648; Thu, 01 Sep 2022 09:42:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1662050568; cv=none; d=google.com; s=arc-20160816; b=QP+OthR9ZMvlbBPMkAlQFZ0rTVAU7mVLM9zIIDrv8682JSQ3DQq1YnAbxpzyifp67r 9xuR/Fyzuh57FFlpVboVZIFd0YRf/+adRt57VcQQFpOIyd8iSx9N4hu665SAhGfodOmC Qv0zk1SnRLV+5ggu3UoIB6DLmXmwl2Cm9qucvizYiT5Vt+5jVpCCy0OWEi7hbq+AfOYK XmmDrKz5QzcYlRGpbNCBxdIorZf5evtPsg6tUdr7IAUP1xKiaB7qtwNkZ8kzJv5aT+uz +fvhtd7IOqTneGs0d/gBuNHN9nQGY0j50pwQ1BL4rS8QXcY/N+flyfdMY+TnGZkIeyc9 RV/A== 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=SPAsUNcz2yuS0Pz02gl1KdFSOYiGXC/bLHd8Ushzzc0=; b=U/6Qh4HAUP4nxHGSyFJKW6EtsSNrzP5tVpIbf9iUGtAv1wJMxFiDKH0Qo6762K0HBO iIqrsQDo190xoS7vCrcbbY0zf3N8eeLtY4Y/9l+ls6ZGkmYOrnpcFuARqIyBXYAC+kDz 2suiU/uzLLotA0B3SAA6gl+sxlAQhrGjd1pxTN1q5D92e4PMjMx/SgTnjv59QGHid3q+ UQRYxNE2EbOqNCUCkYMKoIglxSBsiFr654QW5bE2HhpKxwfDc1fdIWSz0Cr0xrOP7lcz BqQ2TDmOsptqn3oAcSXGbbYcs8RQaQzKnFNVr4E1dacYsLca4U8/abwIudn1GEJEVJbW pu1w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=YKvG4cLl; 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 s3-20020a170902ea0300b0017567224521si951184plg.320.2022.09.01.09.42.37; Thu, 01 Sep 2022 09:42:48 -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=YKvG4cLl; 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 S234790AbiIAQE0 (ORCPT + 99 others); Thu, 1 Sep 2022 12:04:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52822 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234678AbiIAQES (ORCPT ); Thu, 1 Sep 2022 12:04:18 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5085E90192; Thu, 1 Sep 2022 09:04:17 -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 dfw.source.kernel.org (Postfix) with ESMTPS id 9447261F4E; Thu, 1 Sep 2022 16:04:16 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 65754C433D7; Thu, 1 Sep 2022 16:04:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1662048256; bh=pQxU1Hx46HVa2BGwTDDJODoaJZM5iDl3ZsY/PMp4qC0=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=YKvG4cLldxg1T5JujRz9O5eOwa24UxQBobo+/k9BoBr1pDUEnOY4PHX0/8TRhF8jD 5UKOiUDwk5Qs4htZO8FpFF2gsqBhoO+InB8oQ+j9u4g9d7ENoIipfMZk4wfENP3PGo XZon6VqQSRWwwEFRETAfPCmFrceK8z3ldQPwxtb0= Date: Thu, 1 Sep 2022 18:04:07 +0200 From: Greg KH To: "Guilherme G. Piccoli" Cc: evgreen@chromium.org, arnd@arndb.de, linux-efi@vger.kernel.org, linux-kernel@vger.kernel.org, kernel@gpiccoli.net, ardb@kernel.org, davidgow@google.com, jwerner@chromium.org, Petr Mladek Subject: Re: [PATCH V3] firmware: google: Test spinlock on panic path to avoid lockups Message-ID: References: <20220819155059.451674-1-gpiccoli@igalia.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-7.1 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,T_SCC_BODY_TEXT_LINE 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 Thu, Sep 01, 2022 at 12:59:36PM -0300, Guilherme G. Piccoli wrote: > + Petr, since this was extensively discussed in the original thread [0] > and maybe he can help with the argument. > > [0] > https://lore.kernel.org/lkml/20220427224924.592546-1-gpiccoli@igalia.com/ > > > On 01/09/2022 12:52, Greg KH wrote: > > [...] > > >> + * Perform the lock check before effectively trying > >> + * to acquire it on gsmi_shutdown_reason() to avoid > >> + * potential lockups in atomic context. > >> + */ > >> + if (spin_is_locked(&gsmi_dev.lock)) > >> + return NOTIFY_DONE; > >> + > > > > What happens if the lock is grabbed right after testing for it? > > Shouldn't you use lockdep_assert_held() instead as the documentation > > says to? > > How, if in this point only a single CPU (this one, executing the code) > is running? How are we supposed to know this here? > Remember this is the panic path - before this point we disabled all > other CPUs, except this one executing the code. So, either the lock was > taken (and we bail), or it wasn't and it's safe to continue. Then who else could have taken the lock? And if all other CPUs are stopped, who cares about the lock at all? Just don't grab it (you should check for that when you want to grab it) and then you can work properly at that point in time. thanks, greg k-h