Re: [PATCH] locking/lockdep: Avoid recursion in lockdep_count_{for,back}ward_deps()

From: Joel Fernandes
Date: Mon Mar 16 2020 - 11:01:19 EST


On Mon, Mar 16, 2020 at 02:55:07PM +0100, Peter Zijlstra wrote:
> On Sat, Mar 14, 2020 at 09:04:22PM -0400, Joel Fernandes wrote:
> > On Fri, Mar 13, 2020 at 10:33:25AM +0100, Peter Zijlstra wrote:
>
> > Thanks Peter and Boqun, the below patch makes sense to me. Just had some nits
> > below, otherwise:
> > > @@ -1719,11 +1725,11 @@ unsigned long lockdep_count_forward_deps
> > > this.class = class;
> > >
> > > raw_local_irq_save(flags);
> > > - current->lockdep_recursion = 1;
> > > + current->lockdep_recursion++;
> > > arch_spin_lock(&lockdep_lock);
> > > ret = __lockdep_count_forward_deps(&this);
> > > arch_spin_unlock(&lockdep_lock);
> > > - current->lockdep_recursion = 0;
> > > + current->lockdep_recursion--;
> >
> > This doesn't look like it should recurse. Why not just use the
> > lockdep_recursion_finish() helper here?
>
> I chose to only add that to the sites that check recursion on entry.

Makes sense, thank you Peter.

- Joel