public inbox for linux-arm-kernel@lists.infradead.org
 help / color / mirror / Atom feed
From: Will Deacon <will@kernel.org>
To: "Russell King (Oracle)" <linux@armlinux.org.uk>
Cc: Stefan Wiehler <stefan.wiehler@nokia.com>,
	Joel Fernandes <joel@joelfernandes.org>,
	"Paul E. McKenney" <paulmck@kernel.org>,
	Josh Triplett <josh@joshtriplett.org>,
	Boqun Feng <boqun.feng@gmail.com>,
	Steven Rostedt <rostedt@goodmis.org>,
	Mathieu Desnoyers <mathieu.desnoyers@efficios.com>,
	Lai Jiangshan <jiangshanlai@gmail.com>,
	Zqiang <qiang.zhang1211@gmail.com>,
	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
Date: Wed, 13 Mar 2024 00:32:44 +0000	[thread overview]
Message-ID: <20240313003244.GA29568@willie-the-truck> (raw)
In-Reply-To: <ZfDZolTDQa76hhaS@shell.armlinux.org.uk>

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

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

  reply	other threads:[~2024-03-13  0:33 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-03-07 16:09 [PATCH] arm: smp: Avoid false positive CPU hotplug Lockdep-RCU splat Stefan Wiehler
2024-03-07 17:45 ` Paul E. McKenney
2024-03-07 17:49   ` Paul E. McKenney
2024-03-07 18:54   ` Russell King (Oracle)
2024-03-07 19:08     ` Paul E. McKenney
2024-03-07 18:49 ` Boqun Feng
2024-03-08 10:20   ` Stefan Wiehler
2024-03-08 14:57 ` Joel Fernandes
2024-03-09  7:45   ` Stefan Wiehler
2024-03-09  9:57     ` Russell King (Oracle)
2024-03-12 22:14       ` Will Deacon
2024-03-12 22:39         ` Russell King (Oracle)
2024-03-13  0:32           ` Will Deacon [this message]
2024-03-13  9:58             ` Russell King (Oracle)
2024-08-09 13:37               ` Stefan Wiehler
2024-08-09 13:48                 ` Russell King (Oracle)
2024-08-09 14:06                   ` Stefan Wiehler
2024-03-11 16:08 ` Russell King (Oracle)
2024-03-11 16:17   ` Stefan Wiehler
2024-03-11 19:01     ` Paul E. McKenney

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240313003244.GA29568@willie-the-truck \
    --to=will@kernel.org \
    --cc=boqun.feng@gmail.com \
    --cc=jiangshanlai@gmail.com \
    --cc=joel@joelfernandes.org \
    --cc=josh@joshtriplett.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@armlinux.org.uk \
    --cc=mathieu.desnoyers@efficios.com \
    --cc=paulmck@kernel.org \
    --cc=qiang.zhang1211@gmail.com \
    --cc=rcu@vger.kernel.org \
    --cc=rostedt@goodmis.org \
    --cc=stefan.wiehler@nokia.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox