Re: [PATCH V2] lockdep: fix deadlock issue between lockdep and rcu

From: Boqun Feng
Date: Thu Feb 01 2024 - 16:56:51 EST


On Thu, Feb 01, 2024 at 01:24:48PM -0800, Bart Van Assche wrote:
> On 2/1/24 11:48, Boqun Feng wrote:
> > raw_spin_lock_irqsave():
> > lock_acquire():
> > __lock_acquire():
> > validate_chain():
> > lookup_chain_cache_add():
> > graph_lock();
> >
> > Basically, every lock acquisition may lock the lockdep graph because
> > of dependency checking.
>
> Wouldn't it be simpler to make __lock_acquire() return early if
> this_cpu_read(lockdep_recursion) indicates that the graph lock is held?
>

Note that lockdep_recursion doesn't indicate graph lock is held, it
indicates we enter lockdep internal, which means if there was any lock
acquisition, __lock_acquire() would skip the check, so we don't go into
lockdep internal again, therefore avoid infinite recursion.

Regards,
Boqun

> Thanks,
>
> Bart.