diff options
| -rw-r--r-- | tools/lib/lockdep/include/liblockdep/common.h | 2 | ||||
| -rw-r--r-- | tools/lib/lockdep/include/liblockdep/mutex.h | 11 | ||||
| -rw-r--r-- | tools/lib/lockdep/tests/ABBA.c | 9 |
3 files changed, 17 insertions, 5 deletions
diff --git a/tools/lib/lockdep/include/liblockdep/common.h b/tools/lib/lockdep/include/liblockdep/common.h index d640a9761f09..a81d91d4fc78 100644 --- a/tools/lib/lockdep/include/liblockdep/common.h +++ b/tools/lib/lockdep/include/liblockdep/common.h | |||
| @@ -45,6 +45,8 @@ void lock_acquire(struct lockdep_map *lock, unsigned int subclass, | |||
| 45 | void lock_release(struct lockdep_map *lock, int nested, | 45 | void lock_release(struct lockdep_map *lock, int nested, |
| 46 | unsigned long ip); | 46 | unsigned long ip); |
| 47 | void lockdep_reset_lock(struct lockdep_map *lock); | 47 | void lockdep_reset_lock(struct lockdep_map *lock); |
| 48 | void lockdep_register_key(struct lock_class_key *key); | ||
| 49 | void lockdep_unregister_key(struct lock_class_key *key); | ||
| 48 | extern void debug_check_no_locks_freed(const void *from, unsigned long len); | 50 | extern void debug_check_no_locks_freed(const void *from, unsigned long len); |
| 49 | 51 | ||
| 50 | #define STATIC_LOCKDEP_MAP_INIT(_name, _key) \ | 52 | #define STATIC_LOCKDEP_MAP_INIT(_name, _key) \ |
diff --git a/tools/lib/lockdep/include/liblockdep/mutex.h b/tools/lib/lockdep/include/liblockdep/mutex.h index 2073d4e1f2f0..783dd0df06f9 100644 --- a/tools/lib/lockdep/include/liblockdep/mutex.h +++ b/tools/lib/lockdep/include/liblockdep/mutex.h | |||
| @@ -7,6 +7,7 @@ | |||
| 7 | 7 | ||
| 8 | struct liblockdep_pthread_mutex { | 8 | struct liblockdep_pthread_mutex { |
| 9 | pthread_mutex_t mutex; | 9 | pthread_mutex_t mutex; |
| 10 | struct lock_class_key key; | ||
| 10 | struct lockdep_map dep_map; | 11 | struct lockdep_map dep_map; |
| 11 | }; | 12 | }; |
| 12 | 13 | ||
| @@ -27,11 +28,10 @@ static inline int __mutex_init(liblockdep_pthread_mutex_t *lock, | |||
| 27 | return pthread_mutex_init(&lock->mutex, __mutexattr); | 28 | return pthread_mutex_init(&lock->mutex, __mutexattr); |
| 28 | } | 29 | } |
| 29 | 30 | ||
| 30 | #define liblockdep_pthread_mutex_init(mutex, mutexattr) \ | 31 | #define liblockdep_pthread_mutex_init(mutex, mutexattr) \ |
| 31 | ({ \ | 32 | ({ \ |
| 32 | static struct lock_class_key __key; \ | 33 | lockdep_register_key(&(mutex)->key); \ |
| 33 | \ | 34 | __mutex_init((mutex), #mutex, &(mutex)->key, (mutexattr)); \ |
| 34 | __mutex_init((mutex), #mutex, &__key, (mutexattr)); \ | ||
| 35 | }) | 35 | }) |
| 36 | 36 | ||
| 37 | static inline int liblockdep_pthread_mutex_lock(liblockdep_pthread_mutex_t *lock) | 37 | static inline int liblockdep_pthread_mutex_lock(liblockdep_pthread_mutex_t *lock) |
| @@ -55,6 +55,7 @@ static inline int liblockdep_pthread_mutex_trylock(liblockdep_pthread_mutex_t *l | |||
| 55 | static inline int liblockdep_pthread_mutex_destroy(liblockdep_pthread_mutex_t *lock) | 55 | static inline int liblockdep_pthread_mutex_destroy(liblockdep_pthread_mutex_t *lock) |
| 56 | { | 56 | { |
| 57 | lockdep_reset_lock(&lock->dep_map); | 57 | lockdep_reset_lock(&lock->dep_map); |
| 58 | lockdep_unregister_key(&lock->key); | ||
| 58 | return pthread_mutex_destroy(&lock->mutex); | 59 | return pthread_mutex_destroy(&lock->mutex); |
| 59 | } | 60 | } |
| 60 | 61 | ||
diff --git a/tools/lib/lockdep/tests/ABBA.c b/tools/lib/lockdep/tests/ABBA.c index 623313f54720..543789bc3e37 100644 --- a/tools/lib/lockdep/tests/ABBA.c +++ b/tools/lib/lockdep/tests/ABBA.c | |||
| @@ -14,4 +14,13 @@ void main(void) | |||
| 14 | 14 | ||
| 15 | pthread_mutex_destroy(&b); | 15 | pthread_mutex_destroy(&b); |
| 16 | pthread_mutex_destroy(&a); | 16 | pthread_mutex_destroy(&a); |
| 17 | |||
| 18 | pthread_mutex_init(&a, NULL); | ||
| 19 | pthread_mutex_init(&b, NULL); | ||
| 20 | |||
| 21 | LOCK_UNLOCK_2(a, b); | ||
| 22 | LOCK_UNLOCK_2(b, a); | ||
| 23 | |||
| 24 | pthread_mutex_destroy(&b); | ||
| 25 | pthread_mutex_destroy(&a); | ||
| 17 | } | 26 | } |
