Re: lockdep && recursive-read

From: Peter Zijlstra
Date: Tue Aug 29 2017 - 13:31:08 EST


On Tue, Aug 29, 2017 at 07:07:57PM +0200, Oleg Nesterov wrote:
> On 08/29, Oleg Nesterov wrote:
> >
> > Plus process_one_work() does lock_map_acquire_read(), I don't really
> > understand this too.
>
> and in fact I don't understand lock_map_acquire_read() itself. I mean, read == 2
> and this code in check_prevs_add()
>
> /*
> * Only non-recursive-read entries get new dependencies
> * added:
> */
> if (hlock->read != 2 && hlock->check) {
> if (!check_prev_add(curr, hlock, next,
> distance, &stack_saved))
>
>
> Well, I forgot everything I ever knew about lockdep, unlikely I understand what
> the code above actually does. But I verified that this code
>
> static DEFINE_SPINLOCK(exlk);
> static DEFINE_RWLOCK(rwlk);
>
> spin_lock(&exlk);
> write_lock(&rwlk);
> write_unlock(&rwlk);
> spin_unlock(&exlk);
>
> read_lock(&rwlk);
> spin_lock(&exlk);
> spin_unlock(&exlk);
> read_unlock(&rwlk);
>
> runs without any warning from lockdep. Doesn't look right or I am totally
> confused...

Long standing lockdep issue that you used to know about ;-)

Boqun recently started working on it:

https://lkml.kernel.org/r/20170828151608.19636-1-boqun.feng@xxxxxxxxx