Re: [perf] lockdep warning between cpu_add_remove_lock and &dev->mutex.

From: Peter Zijlstra
Date: Mon Jan 23 2023 - 10:29:28 EST


On Mon, Jan 23, 2023 at 11:10:57PM +0900, Tetsuo Handa wrote:
> On 2023/01/23 20:41, Peter Zijlstra wrote:
> > On Mon, Jan 23, 2023 at 07:39:24PM +0900, Tetsuo Handa wrote:
> >> Hello.
> >>
> >> I tried to apply below patch, and hit lockdep warning during boot.
> >> Can you break this dependency?
> >
> > cpu_add_remove_lock
> > cpu_hotplug_lock
> > pmus_lock
> > dev->mutex (pmu_dev_alloc)
> >
> > vs
> >
> > dev->mutex
> > cpu_add_remove_lock (pci_device_probe)
> >
> >
> > Possibly something like this might do -- I'm not entirely sure it's
> > fully correct, needs a bit of auditing.
> >
>
> After applying your diff, lockdep message changed like below. Is this
> the reason commit 1704f47b50b5 ("lockdep: Add novalidate class for
> dev->mutex conversion") was applied?

*sigh*, clearly I should have actually read the slat and not assumed it
was another perf splat.

Yes, something along these lines is why it was done. I think it was this
thread, but there might have been more:

https://lore.kernel.org/all/Pine.LNX.4.44L0.0804171117450.18040-100000@xxxxxxxxxxxxxxxxxxxx/