Commit 786fa29e authored by Bart Van Assche's avatar Bart Van Assche Committed by Ingo Molnar

locking/lockdep: Make concurrent lockdep_reset_lock() calls safe

Since zap_class() removes items from the all_lock_classes list and the
classhash_table, protect all zap_class() calls against concurrent
data structure modifications with the graph lock.
Signed-off-by: default avatarBart Van Assche <bvanassche@acm.org>
Signed-off-by: default avatarPeter Zijlstra (Intel) <peterz@infradead.org>
Cc: Johannes Berg <johannes@sipsolutions.net>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Sasha Levin <sasha.levin@oracle.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Waiman Long <longman@redhat.com>
Cc: johannes.berg@intel.com
Cc: tj@kernel.org
Link: https://lkml.kernel.org/r/20181207011148.251812-13-bvanassche@acm.orgSigned-off-by: default avatarIngo Molnar <mingo@kernel.org>
parent a66b6922
...@@ -4122,6 +4122,9 @@ void lockdep_reset(void) ...@@ -4122,6 +4122,9 @@ void lockdep_reset(void)
raw_local_irq_restore(flags); raw_local_irq_restore(flags);
} }
/*
* Remove all references to a lock class. The caller must hold the graph lock.
*/
static void zap_class(struct lock_class *class) static void zap_class(struct lock_class *class)
{ {
int i; int i;
...@@ -4229,6 +4232,7 @@ void lockdep_reset_lock(struct lockdep_map *lock) ...@@ -4229,6 +4232,7 @@ void lockdep_reset_lock(struct lockdep_map *lock)
int j, locked; int j, locked;
raw_local_irq_save(flags); raw_local_irq_save(flags);
locked = graph_lock();
/* /*
* Remove all classes this lock might have: * Remove all classes this lock might have:
...@@ -4245,7 +4249,6 @@ void lockdep_reset_lock(struct lockdep_map *lock) ...@@ -4245,7 +4249,6 @@ 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.
*/ */
locked = graph_lock();
if (unlikely(lock_class_cache_is_registered(lock))) { if (unlikely(lock_class_cache_is_registered(lock))) {
if (debug_locks_off_graph_unlock()) { if (debug_locks_off_graph_unlock()) {
/* /*
......
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