Subject: Re: [tip: locking/core] lockdep: Fix lockdep recursion

From: "Paul E. McKenney" <[email-masked]>
Date: Fri, 9 Oct 2020 11:21:50 -0700

On Fri, Oct 09, 2020 at 01:54:34PM -0400, Qian Cai wrote:
> On Fri, 2020-10-09 at 13:36 -0400, Qian Cai wrote:
> > Back to x86, we have:
> > 
> > start_secondary()
> >   smp_callin()
> >     apic_ap_setup()
> >       setup_local_APIC()
> >         printk() in certain conditions.
> > 
> > which is before smp_store_cpu_info().
> > 
> > Can't we add a rcu_cpu_starting() at the very top for each start_secondary(),
> > secondary_start_kernel(), smp_start_secondary() etc, so we don't worry about
> > any printk() later?
> 
> This is rather irony. rcu_cpu_starting() is taking a lock and then reports
> itself.
> 
> [    8.826732][    T0]  __lock_acquire.cold.76+0x2ad/0x3e0
> [    8.826732][    T0]  lock_acquire+0x1c8/0x820
> [    8.826732][    T0]  _raw_spin_lock_irqsave+0x30/0x50
> [    8.826732][    T0]  rcu_cpu_starting+0xd0/0x2c0
> [    8.826732][    T0]  start_secondary+0x10/0x2a0
> [    8.826732][    T0]  secondary_startup_64_no_verify+0xb8/0xbb

Fun!!!

There should be some way around this.  I cannot safely record the
offline-to-online transition without acquiring a lock.  I suppose
I could trick lockdep into thinking that it was a recursive lockdep
report.  Any other approaches?

						Thanx, Paul