Re: [PATCH] arm: smp: Avoid false positive CPU hotplug Lockdep-RCU splat

From: Russell King (Oracle)
Date: Thu Mar 07 2024 - 13:55:05 EST


On Thu, Mar 07, 2024 at 09:45:36AM -0800, Paul E. McKenney wrote:
> > diff --git a/arch/arm/kernel/smp.c b/arch/arm/kernel/smp.c
> > index 3431c0553f45..6875e2c5dd50 100644
> > --- a/arch/arm/kernel/smp.c
> > +++ b/arch/arm/kernel/smp.c
> > @@ -319,7 +319,14 @@ void __noreturn arch_cpu_idle_dead(void)
> > {
> > unsigned int cpu = smp_processor_id();
> >
> > + /*
> > + * Briefly report CPU as online again to avoid false positive
> > + * Lockdep-RCU splat when check_and_switch_context() acquires ASID
> > + * spinlock.
> > + */
> > + rcutree_report_cpu_starting(cpu);
> > idle_task_exit();
> > + rcutree_report_cpu_dead();
> >
> > local_irq_disable();
>
> Both rcutree_report_cpu_starting() and rcutree_report_cpu_dead() complain
> bitterly via lockdep if interrupts are enabled. And the call sites have
> interrupts disabled. So I don't understand what this local_irq_disable()
> is needed for.

I think that's a question for this commit:

commit e78a7614f3876ac649b3df608789cb6ef74d0480
Author: Peter Zijlstra <peterz@xxxxxxxxxxxxx>
Date: Wed Jun 5 07:46:43 2019 -0700

Before this commit, arch_cpu_idle_dead() was called with IRQs enabled.
This commit moved the local_irq_disable() before calling
arch_cpu_idle_dead() but it seems no one looked at the various arch
implementations to clean those up. Quite how arch people are supposed
to spot this and clean up after such a commit, I'm not sure.

The local_irq_disable() that you're asking about has been there ever
since the inception of SMP on 32-bit ARM in this commit:

commit a054a811597a17ffbe92bc4db04a4dc2f1b1ea55
Author: Russell King <rmk@xxxxxxxxxxxxxxxxxxxxxxx>
Date: Wed Nov 2 22:24:33 2005 +0000

Where cpu_die() was later renamed to arch_cpu_idle_dead(). So it's
purely a case of a change being made to core code and arch code not
receiving any fixups for it.

--
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/
FTTP is here! 80Mbps down 10Mbps up. Decent connectivity at last!