Received: by 2002:ab2:710b:0:b0:1ef:a325:1205 with SMTP id z11csp1417500lql; Tue, 12 Mar 2024 17:33:00 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUUBg6Slezb+LkXRj3NI2OG4ck7Si2QmdUp7/vlI+taefeFbgDEKE2gnZyJBZwc7SToA4iGpnPd2LITUwUOOxdIUdUmJQ76WM5bOnO7bw== X-Google-Smtp-Source: AGHT+IG9+XLQGRuQLKyKVYrf4KL7qf1Kj9JJgARJoBgzhzK7xjJvT5FnA06S4pkPH/jwLOpfeos5 X-Received: by 2002:a25:ce51:0:b0:dcf:ad31:57c9 with SMTP id x78-20020a25ce51000000b00dcfad3157c9mr1101284ybe.0.1710289980699; Tue, 12 Mar 2024 17:33:00 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1710289980; cv=pass; d=google.com; s=arc-20160816; b=XJHCWIhtGBPdMD7xglR/4l3kTg5Z0EqoBLpdICkI4vnesrCbg2AFwxxiy0sV+bxSSL c4X9Ty53kVuwCgz8h4PBazM/rh2jiTRHrXhWAlPY9W4S92abxmbpkQyjL56kQq8ZqTVQ h612S+6acrGCeF6ps25Jlr+4HUGApEVzu4vlaeE6e7/776MPZc+dx2C7+i0J+eXJ4er2 wQpYa9t3vPhqUl64VpTwwgjuBWtEpwre5vbeV4+WKyRL9TYn/ltwRXUOqO3cNkYToMnk OKMIIYjHAx4aoaadYoNAZFXgaQWfo7JOdd1StzHLayI3VCFg+L/BETWC1emEm5VvhcXH JyOg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=user-agent: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=x43xCKhVffoOZ2o4Y6TIv6+obHV6Rz2qiR9WQ99KHxU=; fh=+RXzqASDhyRqFy5ronVx6vr26vemf3jvc4N69ZxwOdU=; b=JF0BBSNfjknPTciDnRmAVwN+V4nRyqJweoPh6/xHbNVMjnFgeDJNkBI9T4WTcTADdg UOSRCMwKQi6wkmHEVpMvElLb42T9usTDEnJ8YbK+Qugk/eaXJS2vOWEb0I8mbkBTIb2c YYP/3pvHHsIeDOIQAcKUriRAmS7M0bY8bTj/wcX1DB3HXJv+Yta2l5ViRZK5/FAyjUXU IsDnzF0DO8JJFzmlGVRZRn9t0OX/y1uU09vUXcXmLKCGWERetJzfLm1DmUtxDq61/fc+ pmOjOVLQLDs9KdUgB1vpb8Skaq5WAZPgp7FK5sqd2ke0rf7M/1O9qBLYOPUN/30qhAac 42Ug==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=K1nFluVL; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-100965-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-100965-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id y8-20020a05622a164800b0042ef4852a36si8939706qtj.500.2024.03.12.17.33.00 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Mar 2024 17:33:00 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-100965-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=K1nFluVL; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-100965-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-100965-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org 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 ny.mirrors.kernel.org (Postfix) with ESMTPS id 6DBAF1C21599 for ; Wed, 13 Mar 2024 00:33:00 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 449DEBA27; Wed, 13 Mar 2024 00:32:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="K1nFluVL" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 6BE7BB654; Wed, 13 Mar 2024 00:32:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710289971; cv=none; b=ejUzj4OtcHo0vJ4szZ60kHiZZCAPuskwzSBxPzkCSdTPOXXy0XJ4dUZZP7aQE/OljhjVI8nMzO3Yrl7MubBNnpx5xteOSA8HvOadhdye8YKlZxpzw6RgtgI56pQ8+tDTnWEkg+EyuRSCK9ulM3lrCNlQTS4zAuRA8DPqAJ5kdDI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710289971; c=relaxed/simple; bh=kYD2EpLgbT4sPCWd/jlC/Lu5P5Sa6jt2PmeMn6R10fI=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=qa9+MwotbZhbV0Hy8oV7fTWF1Ma/WSB3xEoEi792e0myq5hAbXlw8NJcWRp/KcfuGTjfwQLapVwUviDFMRZDdMDCLalJ3/sqyMa87Nq1FoHd611F4v8dBmHg4BlDGplg54/MdtCC1mgo27YQfZNtIgUW0T3IswK0c9oU7rKBtqg= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=K1nFluVL; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7C1FFC433F1; Wed, 13 Mar 2024 00:32:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1710289970; bh=kYD2EpLgbT4sPCWd/jlC/Lu5P5Sa6jt2PmeMn6R10fI=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=K1nFluVLxRu/u5a/qGTLoH5nSjbx2dz43KNXq480rVe6fo4AnMhZLRY2rrC7moBkh eM8TEawAxTq85gYZ3LSakhqBM1htUlT7ndZfPKzN+Jc01S1n26191w79G9xlNtpPfU h0shHYo+wXzMGO9a1kT+t/qn0lndJ03yuDmk0P8wW4rAc5Jjf8HgjnZ+fP8sAf/pxc 7tSln8gbmdkWVQMuuKNn1A2XI7hGHI8aSsxnyTbWV4NeLUbceyyVfgCbgIP0+umhdR nyi2nUdmG0hxmz7EbUinnCzGpb5w8uHqoUKn7shlTpf9RCNQdxybicI/KTMFg/CTNW IrowB/k6isRvw== Date: Wed, 13 Mar 2024 00:32:44 +0000 From: Will Deacon To: "Russell King (Oracle)" 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: <20240313003244.GA29568@willie-the-truck> 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: User-Agent: Mutt/1.10.1 (2018-07-13) On Tue, Mar 12, 2024 at 10:39:30PM +0000, Russell King (Oracle) wrote: > On Tue, Mar 12, 2024 at 10:14:40PM +0000, Will Deacon wrote: > > 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? Right, that's what I was thinking too, but I have some distant memories of the module space causing potential issues in some configurations. Does that ring a bell with you? Will