Received: by 2002:ab2:710b:0:b0:1ef:a325:1205 with SMTP id z11csp1374491lql; Tue, 12 Mar 2024 15:39:59 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUUSxPOTweoLYsvaHdenl6ufreS4yc+a78EF1l5tmmZWmvwJbn6Sk45OPk7hT/bm5MV9JPZMuivnhJAcCNbleqEb0hCwTjjtiQFVkKcCA== X-Google-Smtp-Source: AGHT+IGsosQUPwuqXeZFllBIBC4swO4UtYHrmT8h4RJYHrq8/5R4JtmR1tdoJVz3rULpgY+obWuI X-Received: by 2002:a17:906:ba87:b0:a45:c1a0:5c03 with SMTP id cu7-20020a170906ba8700b00a45c1a05c03mr8389468ejd.47.1710283198829; Tue, 12 Mar 2024 15:39:58 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1710283198; cv=pass; d=google.com; s=arc-20160816; b=bpCqBn2kr0RW8o5zBKNCdsRlwDDcL0uLKuWXcx4mkQw4nPz56Yl01yHKbk7Joggpa+ 874puIfP6iXkuaDFC2u2i9cYrWTwIfJXMaf75ZcmzdHWJ9ywR7KpVtc6fzNpVz03T1Vm kYsTLQcly7INVtpMbmMh5c41af8kZZ2f1MwF9Wqht8nwT2hs/h4lDTSUocttwmVJrHK4 EvnyNKrqorGT82jdBramWHOng5L+7T+DAiuNM7bt+gq3TPVZ8sTmsWnoCVoM9jbAqgR1 KYMQ/PtLY/ZyFrVX12tFjwbj9Mt/c5FCVZmvpS1HYqq1JHTXZReQrPpxzWjylUxggli+ hmaA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:in-reply-to:content-disposition:mime-version :list-unsubscribe:list-subscribe:list-id:precedence:references :message-id:subject:cc:to:from:date:dkim-signature; bh=IW00bxPf22nPInwkJFq4lSI3c2JyJKalEpfx3FB1zio=; fh=CyzJfU06Rl9+oARFZuHDfAqCrbH5CnIb36BoA/lh20Y=; b=bFdWmNBfFxR6W0m4Dzf4X0dvqzMfkOzpJEv5nsa/5+5BCOSMJuYG/oqJkeIQIBmdQ9 JdurzROamiuEQCiYXl/Ek2AfbTPZt04rn9ngek36a7VVTuzM2Yi973y1CMBs4fFZHqKy 4e7tbR9c6m0uYwrqiW2/jBiCcFIPsP4MyMF9SQWjHn1L1nf0SooleHLLdqUrAojFjQBO WtlX9ZI9hQzOyWD3ghCJgFaiV/crUOGRlzBokfS2jfQogU1DWuRcVyQPBa0vIINoHQ3O SwNoSSdbd53ceVqpoANwO8gNiWpzu18BBS6fqjT/xtCS0IKbW2EfyqgSDyhqVTOChYXV Sb0A==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=fail (test mode) header.i=@armlinux.org.uk header.s=pandora-2019 header.b=c2HsHfC6; arc=pass (i=1 dkim=pass dkdomain=armlinux.org.uk dmarc=pass fromdomain=armlinux.org.uk); spf=pass (google.com: domain of linux-kernel+bounces-100901-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-100901-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=armlinux.org.uk Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id dt11-20020a170906b78b00b00a44ff956c17si3873548ejb.324.2024.03.12.15.39.58 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Mar 2024 15:39:58 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-100901-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=fail (test mode) header.i=@armlinux.org.uk header.s=pandora-2019 header.b=c2HsHfC6; arc=pass (i=1 dkim=pass dkdomain=armlinux.org.uk dmarc=pass fromdomain=armlinux.org.uk); spf=pass (google.com: domain of linux-kernel+bounces-100901-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-100901-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=armlinux.org.uk Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 6C17A1F22EAC for ; Tue, 12 Mar 2024 22:39:58 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 70EE72BB1E; Tue, 12 Mar 2024 22:39:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=armlinux.org.uk header.i=@armlinux.org.uk header.b="c2HsHfC6" Received: from pandora.armlinux.org.uk (pandora.armlinux.org.uk [78.32.30.218]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 08516BE7D; Tue, 12 Mar 2024 22:39:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=78.32.30.218 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710283191; cv=none; b=JyAUotztMXdF3i9nNJCj+nyHfTEepI7gmtxJa57kFNzlmQoXChjZAL6MqHxdDkZ9/lQNeQLYY9MxRbLsV1phom2Rn7SuN6mHi9UxSxe5S2UnCfa7vDintKLysTdOmGYAYYT7mYkMcAoU1WQRHteUpVL4D3Fp04N56FDr5JUh5xQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710283191; c=relaxed/simple; bh=lekLyCnOdnNs3oBm+2/covKa4A8rDcA1+veWI/xEDwk=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=Rzr2v7ldyyub2aOODz7f6UmurXO33xStngVirIOrn4Lv8KKktF/8+FtgFOKWPomQjMf9bh337aqMCA6rS8aL0p7k5adpRicki1xKWvRn3eGVNg8QxSW5eSzMDWCD56gZ/0TnQqDfYHD84rARNz0dquzR+WkssLMp5ycxqoeZl+g= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=armlinux.org.uk; spf=none smtp.mailfrom=armlinux.org.uk; dkim=pass (2048-bit key) header.d=armlinux.org.uk header.i=@armlinux.org.uk header.b=c2HsHfC6; arc=none smtp.client-ip=78.32.30.218 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=armlinux.org.uk Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=armlinux.org.uk DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=armlinux.org.uk; s=pandora-2019; h=Sender:In-Reply-To:Content-Type: MIME-Version:References:Message-ID:Subject:Cc:To:From:Date:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=IW00bxPf22nPInwkJFq4lSI3c2JyJKalEpfx3FB1zio=; b=c2HsHfC6XSjDkTcQwXA2jzOKXe LzloQp8SVaLEZtyEuGkEJapALmFdG04UCmtczVakGuFATt2K1heprGge0+y2Z+kBJMgmc8EgeEKp2 M4WKy/XAXnXwnibshvD+64inMS/ccfRe1uZ4gpIf543TGcFObvQY7BIFFyGXNqX2No0jk7eY1uqNM y/zTSzWKlE6BONMolApzpEtxgoc6oLbC+nkWL1gmFHy6mEa6CmJSVsKhNpP0H1ZN6V678KOHA2Je7 /6FtbSlP5M8L2IbJq0rNP0GjkVfvneoxMOo6O3sRB+rxDidLXT/FpadKFLtj9tmHW4iNSoYh2E9bL OqAOpAoA==; Received: from shell.armlinux.org.uk ([fd8f:7570:feb6:1:5054:ff:fe00:4ec]:45008) by pandora.armlinux.org.uk with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1rkAmV-00072y-1h; Tue, 12 Mar 2024 22:39:35 +0000 Received: from linux by shell.armlinux.org.uk with local (Exim 4.94.2) (envelope-from ) id 1rkAmQ-0003uo-NL; Tue, 12 Mar 2024 22:39:30 +0000 Date: Tue, 12 Mar 2024 22:39:30 +0000 From: "Russell King (Oracle)" To: Will Deacon Cc: Stefan Wiehler , Joel Fernandes , "Paul E. McKenney" , Josh Triplett , Boqun Feng , Steven Rostedt , Mathieu Desnoyers , Lai Jiangshan , Zqiang , linux-arm-kernel@lists.infradead.org, rcu@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] arm: smp: Avoid false positive CPU hotplug Lockdep-RCU splat Message-ID: References: <20240307160951.3607374-1-stefan.wiehler@nokia.com> <66fdce3a-c7f6-4ef4-ab56-7c9ece0b00e2@nokia.com> <20240312221440.GA29419@willie-the-truck> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20240312221440.GA29419@willie-the-truck> Sender: Russell King (Oracle) On Tue, Mar 12, 2024 at 10:14:40PM +0000, Will Deacon wrote: > Hi Russell, > > On Sat, Mar 09, 2024 at 09:57:04AM +0000, Russell King (Oracle) wrote: > > On Sat, Mar 09, 2024 at 08:45:35AM +0100, Stefan Wiehler wrote: > > > diff --git a/arch/arm/mm/context.c b/arch/arm/mm/context.c > > > index 4204ffa2d104..4fc2c559f1b6 100644 > > > --- a/arch/arm/mm/context.c > > > +++ b/arch/arm/mm/context.c > > > @@ -254,7 +254,8 @@ void check_and_switch_context(struct mm_struct *mm, struct task_struct *tsk) > > > && atomic64_xchg(&per_cpu(active_asids, cpu), asid)) > > > goto switch_mm_fastpath; > > > > > > - raw_spin_lock_irqsave(&cpu_asid_lock, flags); > > > + local_irq_save(flags); > > > + arch_spin_lock(&cpu_asid_lock.raw_lock); > > > /* Check that our ASID belongs to the current generation. */ > > > asid = atomic64_read(&mm->context.id); > > > if ((asid ^ atomic64_read(&asid_generation)) >> ASID_BITS) { > > > @@ -269,7 +270,8 @@ void check_and_switch_context(struct mm_struct *mm, struct task_struct *tsk) > > > > > > atomic64_set(&per_cpu(active_asids, cpu), asid); > > > cpumask_set_cpu(cpu, mm_cpumask(mm)); > > > - raw_spin_unlock_irqrestore(&cpu_asid_lock, flags); > > > + arch_spin_unlock(&cpu_asid_lock.raw_lock); > > > + local_irq_restore(flags); > > > > > > switch_mm_fastpath: > > > cpu_switch_mm(mm->pgd, mm); > > > > > > @Russell, what do you think? > > > > I think this is Will Deacon's code, so we ought to hear from Will... > > Thanks for adding me in. > > Using arch_spin_lock() really feels like a bodge to me. This code isn't > run only on the hot-unplug path, but rather this is part of switch_mm() > and we really should be able to have lockdep work properly there for > the usual case. > > Now, do we actually need to worry about the ASID when switching to the > init_mm? I'd have thought that would be confined to global (kernel) > mappings, so I wonder whether we could avoid this slow path code > altogether like we do on arm64 in __switch_mm(). But I must confess that > I don't recall the details of the pre-LPAE MMU configuration... As the init_mm shouldn't have any userspace mappings, isn't the ASID entirely redundant? Couldn't check_and_switch_context() just simply do the vmalloc seq check, set the reserved ASID, and then head to switch_mm_fastpath to call the mm switch code? -- RMK's Patch system: https://www.armlinux.org.uk/developer/patches/ FTTP is here! 80Mbps down 10Mbps up. Decent connectivity at last!