diff options
author | Bart Van Assche <bvanassche@acm.org> | 2019-02-14 18:00:46 -0500 |
---|---|---|
committer | Ingo Molnar <mingo@kernel.org> | 2019-02-28 01:55:43 -0500 |
commit | a0b0fd53e1e67639b303b15939b9c653dbe7a8c4 (patch) | |
tree | 2ad0c4039a0bd9ebc15e03cc6f7f3d2325a23900 /include/linux/lockdep.h | |
parent | 29fc33fb7283970701355dc89badba4ed21c7092 (diff) |
locking/lockdep: Free lock classes that are no longer in use
Instead of leaving lock classes that are no longer in use in the
lock_classes array, reuse entries from that array that are no longer in
use. Maintain a linked list of free lock classes with list head
'free_lock_class'. Only add freed lock classes to the free_lock_classes
list after a grace period to avoid that a lock_classes[] element would
be reused while an RCU reader is accessing it. Since the lockdep
selftests run in a context where sleeping is not allowed and since the
selftests require that lock resetting/zapping works with debug_locks
off, make the behavior of lockdep_free_key_range() and
lockdep_reset_lock() depend on whether or not these are called from
the context of the lockdep selftests.
Thanks to Peter for having shown how to modify get_pending_free()
such that that function does not have to sleep.
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Johannes Berg <johannes@sipsolutions.net>
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: Waiman Long <longman@redhat.com>
Cc: Will Deacon <will.deacon@arm.com>
Cc: johannes.berg@intel.com
Cc: tj@kernel.org
Link: https://lkml.kernel.org/r/20190214230058.196511-12-bvanassche@acm.org
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Diffstat (limited to 'include/linux/lockdep.h')
-rw-r--r-- | include/linux/lockdep.h | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/include/linux/lockdep.h b/include/linux/lockdep.h index 66eee1ba0f2a..619ec3f26cdc 100644 --- a/include/linux/lockdep.h +++ b/include/linux/lockdep.h | |||
@@ -63,7 +63,8 @@ extern struct lock_class_key __lockdep_no_validate__; | |||
63 | #define LOCKSTAT_POINTS 4 | 63 | #define LOCKSTAT_POINTS 4 |
64 | 64 | ||
65 | /* | 65 | /* |
66 | * The lock-class itself: | 66 | * The lock-class itself. The order of the structure members matters. |
67 | * reinit_class() zeroes the key member and all subsequent members. | ||
67 | */ | 68 | */ |
68 | struct lock_class { | 69 | struct lock_class { |
69 | /* | 70 | /* |
@@ -72,7 +73,9 @@ struct lock_class { | |||
72 | struct hlist_node hash_entry; | 73 | struct hlist_node hash_entry; |
73 | 74 | ||
74 | /* | 75 | /* |
75 | * global list of all lock-classes: | 76 | * Entry in all_lock_classes when in use. Entry in free_lock_classes |
77 | * when not in use. Instances that are being freed are on one of the | ||
78 | * zapped_classes lists. | ||
76 | */ | 79 | */ |
77 | struct list_head lock_entry; | 80 | struct list_head lock_entry; |
78 | 81 | ||
@@ -104,7 +107,7 @@ struct lock_class { | |||
104 | unsigned long contention_point[LOCKSTAT_POINTS]; | 107 | unsigned long contention_point[LOCKSTAT_POINTS]; |
105 | unsigned long contending_point[LOCKSTAT_POINTS]; | 108 | unsigned long contending_point[LOCKSTAT_POINTS]; |
106 | #endif | 109 | #endif |
107 | }; | 110 | } __no_randomize_layout; |
108 | 111 | ||
109 | #ifdef CONFIG_LOCK_STAT | 112 | #ifdef CONFIG_LOCK_STAT |
110 | struct lock_time { | 113 | struct lock_time { |