Re: [PATCH] lockdep: Do no validate wait context for novalidate class

From: peterz
Date: Thu Aug 20 2020 - 07:41:02 EST


On Mon, Jun 29, 2020 at 10:15:29PM +0200, Sebastian Andrzej Siewior wrote:
> The novalidate class is ignored in the lockchain validation but is
> considered in the wait context validation.
> If a mutex and a spinlock_t is ignored by using
> lockdep_set_novalidate_class() then both locks will share the same lock
> class. From the wait validation point of view the mutex will then appear
> like a spinlock_t and the validator will complain if another mutex will
> be acquired.
>
> Ignore the nonvalidate locks from wait context checking.

Hurmph.. but how? There was only a single user... /me greps.

drivers/base/core.c: lockdep_set_novalidate_class(&dev->mutex);
drivers/md/bcache/btree.c: lockdep_set_novalidate_class(&b->lock);
drivers/md/bcache/btree.c: lockdep_set_novalidate_class(&b->write_lock);

Urgh.. there's more now :-(

So write_lock, like dev->mutex is a mutex.

Kent, what's the story with b->lock? It appears to have lockdep
annotations, but then is also the novalidate class. Also neither of
these lockdep_set_novalidate_class() thingies have a comment.

Anyway, all 3 users should have the same wait context, so where is the
actual problem?