aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthew Wilcox <mawilcox@microsoft.com>2018-01-17 10:14:13 -0500
committerThomas Gleixner <tglx@linutronix.de>2018-01-18 05:56:48 -0500
commit08f36ff642342fb058212099757cb5d40f158c2a (patch)
tree76d1cd26040f49c782799e2d621f80258a33ca2d
parent64f29d1bc9fb8196df3d0f1df694245230e208c0 (diff)
lockdep: Make lockdep checking constant
There are several places in the kernel which would like to pass a const pointer to lockdep_is_held(). Constify the entire path so nobody has to trick the compiler. Signed-off-by: Matthew Wilcox <mawilcox@microsoft.com> Signed-off-by: Thomas Gleixner <tglx@linutronix.de> Acked-by: Peter Zijlstra (Intel) <peterz@infradead.org> Cc: "David S. Miller" <davem@davemloft.net> Link: https://lkml.kernel.org/r/20180117151414.23686-3-willy@infradead.org
-rw-r--r--include/linux/lockdep.h4
-rw-r--r--kernel/locking/lockdep.c13
2 files changed, 9 insertions, 8 deletions
diff --git a/include/linux/lockdep.h b/include/linux/lockdep.h
index 3251d9c0d313..864d6fc60fa6 100644
--- a/include/linux/lockdep.h
+++ b/include/linux/lockdep.h
@@ -337,9 +337,9 @@ extern void lock_release(struct lockdep_map *lock, int nested,
337/* 337/*
338 * Same "read" as for lock_acquire(), except -1 means any. 338 * Same "read" as for lock_acquire(), except -1 means any.
339 */ 339 */
340extern int lock_is_held_type(struct lockdep_map *lock, int read); 340extern int lock_is_held_type(const struct lockdep_map *lock, int read);
341 341
342static inline int lock_is_held(struct lockdep_map *lock) 342static inline int lock_is_held(const struct lockdep_map *lock)
343{ 343{
344 return lock_is_held_type(lock, -1); 344 return lock_is_held_type(lock, -1);
345} 345}
diff --git a/kernel/locking/lockdep.c b/kernel/locking/lockdep.c
index 472547dd45c3..b7a307b53704 100644
--- a/kernel/locking/lockdep.c
+++ b/kernel/locking/lockdep.c
@@ -648,7 +648,7 @@ static int count_matching_names(struct lock_class *new_class)
648} 648}
649 649
650static inline struct lock_class * 650static inline struct lock_class *
651look_up_lock_class(struct lockdep_map *lock, unsigned int subclass) 651look_up_lock_class(const struct lockdep_map *lock, unsigned int subclass)
652{ 652{
653 struct lockdep_subclass_key *key; 653 struct lockdep_subclass_key *key;
654 struct hlist_head *hash_head; 654 struct hlist_head *hash_head;
@@ -3276,7 +3276,7 @@ print_lock_nested_lock_not_held(struct task_struct *curr,
3276 return 0; 3276 return 0;
3277} 3277}
3278 3278
3279static int __lock_is_held(struct lockdep_map *lock, int read); 3279static int __lock_is_held(const struct lockdep_map *lock, int read);
3280 3280
3281/* 3281/*
3282 * This gets called for every mutex_lock*()/spin_lock*() operation. 3282 * This gets called for every mutex_lock*()/spin_lock*() operation.
@@ -3485,13 +3485,14 @@ print_unlock_imbalance_bug(struct task_struct *curr, struct lockdep_map *lock,
3485 return 0; 3485 return 0;
3486} 3486}
3487 3487
3488static int match_held_lock(struct held_lock *hlock, struct lockdep_map *lock) 3488static int match_held_lock(const struct held_lock *hlock,
3489 const struct lockdep_map *lock)
3489{ 3490{
3490 if (hlock->instance == lock) 3491 if (hlock->instance == lock)
3491 return 1; 3492 return 1;
3492 3493
3493 if (hlock->references) { 3494 if (hlock->references) {
3494 struct lock_class *class = lock->class_cache[0]; 3495 const struct lock_class *class = lock->class_cache[0];
3495 3496
3496 if (!class) 3497 if (!class)
3497 class = look_up_lock_class(lock, 0); 3498 class = look_up_lock_class(lock, 0);
@@ -3727,7 +3728,7 @@ __lock_release(struct lockdep_map *lock, int nested, unsigned long ip)
3727 return 1; 3728 return 1;
3728} 3729}
3729 3730
3730static int __lock_is_held(struct lockdep_map *lock, int read) 3731static int __lock_is_held(const struct lockdep_map *lock, int read)
3731{ 3732{
3732 struct task_struct *curr = current; 3733 struct task_struct *curr = current;
3733 int i; 3734 int i;
@@ -3941,7 +3942,7 @@ void lock_release(struct lockdep_map *lock, int nested,
3941} 3942}
3942EXPORT_SYMBOL_GPL(lock_release); 3943EXPORT_SYMBOL_GPL(lock_release);
3943 3944
3944int lock_is_held_type(struct lockdep_map *lock, int read) 3945int lock_is_held_type(const struct lockdep_map *lock, int read)
3945{ 3946{
3946 unsigned long flags; 3947 unsigned long flags;
3947 int ret = 0; 3948 int ret = 0;