Commit 21199f27 authored by Peter Zijlstra's avatar Peter Zijlstra Committed by Ingo Molnar

locking/lockdep: Fix hlock->pin_count reset on lock stack rebuilds

Various people reported hitting the "unpinning an unpinned lock"
warning. As it turns out there are 2 places where we take a lock out
of the middle of a stack, and in those cases it would fail to preserve
the pin_count when rebuilding the lock stack.
Reported-by: default avatarSasha Levin <sasha.levin@oracle.com>
Reported-by: default avatarTim Spriggs <tspriggs@apple.com>
Tested-by: default avatarSasha Levin <sasha.levin@oracle.com>
Signed-off-by: default avatarPeter Zijlstra (Intel) <peterz@infradead.org>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: davej@codemonkey.org.uk
Link: http://lkml.kernel.org/r/20150916141040.GA11639@twins.programming.kicks-ass.netSigned-off-by: default avatarIngo Molnar <mingo@kernel.org>
parent bcee19f4
...@@ -3068,7 +3068,7 @@ static int __lock_is_held(struct lockdep_map *lock); ...@@ -3068,7 +3068,7 @@ static int __lock_is_held(struct lockdep_map *lock);
static int __lock_acquire(struct lockdep_map *lock, unsigned int subclass, static int __lock_acquire(struct lockdep_map *lock, unsigned int subclass,
int trylock, int read, int check, int hardirqs_off, int trylock, int read, int check, int hardirqs_off,
struct lockdep_map *nest_lock, unsigned long ip, struct lockdep_map *nest_lock, unsigned long ip,
int references) int references, int pin_count)
{ {
struct task_struct *curr = current; struct task_struct *curr = current;
struct lock_class *class = NULL; struct lock_class *class = NULL;
...@@ -3157,7 +3157,7 @@ static int __lock_acquire(struct lockdep_map *lock, unsigned int subclass, ...@@ -3157,7 +3157,7 @@ static int __lock_acquire(struct lockdep_map *lock, unsigned int subclass,
hlock->waittime_stamp = 0; hlock->waittime_stamp = 0;
hlock->holdtime_stamp = lockstat_clock(); hlock->holdtime_stamp = lockstat_clock();
#endif #endif
hlock->pin_count = 0; hlock->pin_count = pin_count;
if (check && !mark_irqflags(curr, hlock)) if (check && !mark_irqflags(curr, hlock))
return 0; return 0;
...@@ -3343,7 +3343,7 @@ __lock_set_class(struct lockdep_map *lock, const char *name, ...@@ -3343,7 +3343,7 @@ __lock_set_class(struct lockdep_map *lock, const char *name,
hlock_class(hlock)->subclass, hlock->trylock, hlock_class(hlock)->subclass, hlock->trylock,
hlock->read, hlock->check, hlock->hardirqs_off, hlock->read, hlock->check, hlock->hardirqs_off,
hlock->nest_lock, hlock->acquire_ip, hlock->nest_lock, hlock->acquire_ip,
hlock->references)) hlock->references, hlock->pin_count))
return 0; return 0;
} }
...@@ -3433,7 +3433,7 @@ __lock_release(struct lockdep_map *lock, int nested, unsigned long ip) ...@@ -3433,7 +3433,7 @@ __lock_release(struct lockdep_map *lock, int nested, unsigned long ip)
hlock_class(hlock)->subclass, hlock->trylock, hlock_class(hlock)->subclass, hlock->trylock,
hlock->read, hlock->check, hlock->hardirqs_off, hlock->read, hlock->check, hlock->hardirqs_off,
hlock->nest_lock, hlock->acquire_ip, hlock->nest_lock, hlock->acquire_ip,
hlock->references)) hlock->references, hlock->pin_count))
return 0; return 0;
} }
...@@ -3583,7 +3583,7 @@ void lock_acquire(struct lockdep_map *lock, unsigned int subclass, ...@@ -3583,7 +3583,7 @@ void lock_acquire(struct lockdep_map *lock, unsigned int subclass,
current->lockdep_recursion = 1; current->lockdep_recursion = 1;
trace_lock_acquire(lock, subclass, trylock, read, check, nest_lock, ip); trace_lock_acquire(lock, subclass, trylock, read, check, nest_lock, ip);
__lock_acquire(lock, subclass, trylock, read, check, __lock_acquire(lock, subclass, trylock, read, check,
irqs_disabled_flags(flags), nest_lock, ip, 0); irqs_disabled_flags(flags), nest_lock, ip, 0, 0);
current->lockdep_recursion = 0; current->lockdep_recursion = 0;
raw_local_irq_restore(flags); raw_local_irq_restore(flags);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment