Commit 5a26db5b authored by Nick Piggin's avatar Nick Piggin Committed by Peter Zijlstra

lockdep: fix internal double unlock during self-test

Lockdep, during self-test (when it was simulating double unlocks) was
sometimes unconditionally unlocking a spinlock when it had not been
locked. This won't work for ticket locks.
Signed-off-by: default avatarNick Piggin <npiggin@suse.de>
Signed-off-by: default avatarIngo Molnar <mingo@elte.hu>
Signed-off-by: default avatarPeter Zijlstra <a.p.zijlstra@chello.nl>
parent cbd9c883
...@@ -2943,9 +2943,10 @@ void lockdep_free_key_range(void *start, unsigned long size) ...@@ -2943,9 +2943,10 @@ void lockdep_free_key_range(void *start, unsigned long size)
struct list_head *head; struct list_head *head;
unsigned long flags; unsigned long flags;
int i; int i;
int locked;
raw_local_irq_save(flags); raw_local_irq_save(flags);
graph_lock(); locked = graph_lock();
/* /*
* Unhash all classes that were created by this module: * Unhash all classes that were created by this module:
...@@ -2959,6 +2960,7 @@ void lockdep_free_key_range(void *start, unsigned long size) ...@@ -2959,6 +2960,7 @@ void lockdep_free_key_range(void *start, unsigned long size)
zap_class(class); zap_class(class);
} }
if (locked)
graph_unlock(); graph_unlock();
raw_local_irq_restore(flags); raw_local_irq_restore(flags);
} }
...@@ -2969,6 +2971,7 @@ void lockdep_reset_lock(struct lockdep_map *lock) ...@@ -2969,6 +2971,7 @@ void lockdep_reset_lock(struct lockdep_map *lock)
struct list_head *head; struct list_head *head;
unsigned long flags; unsigned long flags;
int i, j; int i, j;
int locked;
raw_local_irq_save(flags); raw_local_irq_save(flags);
...@@ -2987,7 +2990,7 @@ void lockdep_reset_lock(struct lockdep_map *lock) ...@@ -2987,7 +2990,7 @@ void lockdep_reset_lock(struct lockdep_map *lock)
* Debug check: in the end all mapped classes should * Debug check: in the end all mapped classes should
* be gone. * be gone.
*/ */
graph_lock(); locked = graph_lock();
for (i = 0; i < CLASSHASH_SIZE; i++) { for (i = 0; i < CLASSHASH_SIZE; i++) {
head = classhash_table + i; head = classhash_table + i;
if (list_empty(head)) if (list_empty(head))
...@@ -3000,6 +3003,7 @@ void lockdep_reset_lock(struct lockdep_map *lock) ...@@ -3000,6 +3003,7 @@ void lockdep_reset_lock(struct lockdep_map *lock)
} }
} }
} }
if (locked)
graph_unlock(); graph_unlock();
out_restore: out_restore:
......
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