For the special novalidate class (lockdep_set_novalidate_class), multiple locks with different names may use the same class. The WARN_ON_ONCE() check in look_up_lock_class() will then report an unnecessary warning.
The current users of lockdep_set_novalidate_class() includes the device mutex, one mutex and one rwsem in drivers/md/bcache/btree.c. So the novalidate class is now excluded from the check. Signed-off-by: Waiman Long <long...@redhat.com> --- kernel/locking/lockdep.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/kernel/locking/lockdep.c b/kernel/locking/lockdep.c index dd13f865ad40..10babc35953b 100644 --- a/kernel/locking/lockdep.c +++ b/kernel/locking/lockdep.c @@ -693,9 +693,12 @@ look_up_lock_class(const struct lockdep_map *lock, unsigned int subclass) if (class->key == key) { /* * Huh! same key, different name? Did someone trample - * on some memory? We're most confused. + * on some memory? We're most confused unless it is + * __lockdep_no_validate__ where different locks can + * use the same class. */ - WARN_ON_ONCE(class->name != lock->name); + WARN_ON_ONCE((key != __lockdep_no_validate__.subkeys) && + (class->name != lock->name)); return class; } } -- 2.18.0