Merge branch 'locking-urgent-for-linus' of git://git.kernel.org/pub/scm/linux/kernel...
authorLinus Torvalds <torvalds@linux-foundation.org>
Tue, 7 Mar 2017 22:33:11 +0000 (14:33 -0800)
committerLinus Torvalds <torvalds@linux-foundation.org>
Tue, 7 Mar 2017 22:33:11 +0000 (14:33 -0800)
Pull locking fixes from Ingo Molnar:

 - Change the new refcount_t warnings from WARN() to WARN_ONCE()

 - two ww_mutex fixes

 - plus a new lockdep self-consistency check for a bug that triggered in
   practice

* 'locking-urgent-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip:
  locking/ww_mutex: Adjust the lock number for stress test
  locking/lockdep: Add nest_lock integrity test
  locking/ww_mutex: Replace cpu_relax() with cond_resched() for tests
  locking/refcounts: Change WARN() to WARN_ONCE()

1  2 
kernel/locking/lockdep.c

diff --combined kernel/locking/lockdep.c
@@@ -28,8 -28,6 +28,8 @@@
  #define DISABLE_BRANCH_PROFILING
  #include <linux/mutex.h>
  #include <linux/sched.h>
 +#include <linux/sched/clock.h>
 +#include <linux/sched/task.h>
  #include <linux/delay.h>
  #include <linux/module.h>
  #include <linux/proc_fs.h>
@@@ -3262,10 -3260,17 +3262,17 @@@ static int __lock_acquire(struct lockde
        if (depth) {
                hlock = curr->held_locks + depth - 1;
                if (hlock->class_idx == class_idx && nest_lock) {
-                       if (hlock->references)
+                       if (hlock->references) {
+                               /*
+                                * Check: unsigned int references:12, overflow.
+                                */
+                               if (DEBUG_LOCKS_WARN_ON(hlock->references == (1 << 12)-1))
+                                       return 0;
                                hlock->references++;
-                       else
+                       } else {
                                hlock->references = 2;
+                       }
  
                        return 1;
                }