OSDN Git Service

tools/lib/lockdep/tests: Test the lockdep_reset_lock() implementation
authorBart Van Assche <bvanassche@acm.org>
Fri, 7 Dec 2018 01:11:31 +0000 (17:11 -0800)
committerIngo Molnar <mingo@kernel.org>
Tue, 11 Dec 2018 13:54:51 +0000 (14:54 +0100)
This patch makes sure that the lockdep_reset_lock() function gets
tested.

Signed-off-by: Bart Van Assche <bvanassche@acm.org>
Signed-off-by: Peter 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-8-bvanassche@acm.org
Signed-off-by: Ingo Molnar <mingo@kernel.org>
tools/lib/lockdep/include/liblockdep/common.h
tools/lib/lockdep/include/liblockdep/mutex.h
tools/lib/lockdep/tests/ABBA.c
tools/lib/lockdep/tests/ABBCCA.c
tools/lib/lockdep/tests/ABBCCDDA.c
tools/lib/lockdep/tests/ABCABC.c
tools/lib/lockdep/tests/ABCDBCDA.c
tools/lib/lockdep/tests/ABCDBDDA.c
tools/lib/lockdep/tests/unlock_balance.c

index 8862da8..d640a97 100644 (file)
@@ -44,6 +44,7 @@ void lock_acquire(struct lockdep_map *lock, unsigned int subclass,
                        struct lockdep_map *nest_lock, unsigned long ip);
 void lock_release(struct lockdep_map *lock, int nested,
                        unsigned long ip);
+void lockdep_reset_lock(struct lockdep_map *lock);
 extern void debug_check_no_locks_freed(const void *from, unsigned long len);
 
 #define STATIC_LOCKDEP_MAP_INIT(_name, _key) \
index a80ac39..2073d4e 100644 (file)
@@ -54,6 +54,7 @@ static inline int liblockdep_pthread_mutex_trylock(liblockdep_pthread_mutex_t *l
 
 static inline int liblockdep_pthread_mutex_destroy(liblockdep_pthread_mutex_t *lock)
 {
+       lockdep_reset_lock(&lock->dep_map);
        return pthread_mutex_destroy(&lock->mutex);
 }
 
index 1460afd..623313f 100644 (file)
@@ -11,4 +11,7 @@ void main(void)
 
        LOCK_UNLOCK_2(a, b);
        LOCK_UNLOCK_2(b, a);
+
+       pthread_mutex_destroy(&b);
+       pthread_mutex_destroy(&a);
 }
index a54c1b2..4844612 100644 (file)
@@ -13,4 +13,8 @@ void main(void)
        LOCK_UNLOCK_2(a, b);
        LOCK_UNLOCK_2(b, c);
        LOCK_UNLOCK_2(c, a);
+
+       pthread_mutex_destroy(&c);
+       pthread_mutex_destroy(&b);
+       pthread_mutex_destroy(&a);
 }
index aa5d194..3570bf7 100644 (file)
@@ -15,4 +15,9 @@ void main(void)
        LOCK_UNLOCK_2(b, c);
        LOCK_UNLOCK_2(c, d);
        LOCK_UNLOCK_2(d, a);
+
+       pthread_mutex_destroy(&d);
+       pthread_mutex_destroy(&c);
+       pthread_mutex_destroy(&b);
+       pthread_mutex_destroy(&a);
 }
index b54a08e..a1c4659 100644 (file)
@@ -13,4 +13,8 @@ void main(void)
        LOCK_UNLOCK_2(a, b);
        LOCK_UNLOCK_2(c, a);
        LOCK_UNLOCK_2(b, c);
+
+       pthread_mutex_destroy(&c);
+       pthread_mutex_destroy(&b);
+       pthread_mutex_destroy(&a);
 }
index a567422..335af1c 100644 (file)
@@ -15,4 +15,9 @@ void main(void)
        LOCK_UNLOCK_2(c, d);
        LOCK_UNLOCK_2(b, c);
        LOCK_UNLOCK_2(d, a);
+
+       pthread_mutex_destroy(&d);
+       pthread_mutex_destroy(&c);
+       pthread_mutex_destroy(&b);
+       pthread_mutex_destroy(&a);
 }
index 238a335..3c59728 100644 (file)
@@ -15,4 +15,9 @@ void main(void)
        LOCK_UNLOCK_2(c, d);
        LOCK_UNLOCK_2(b, d);
        LOCK_UNLOCK_2(d, a);
+
+       pthread_mutex_destroy(&d);
+       pthread_mutex_destroy(&c);
+       pthread_mutex_destroy(&b);
+       pthread_mutex_destroy(&a);
 }
index 34cf32f..dba2506 100644 (file)
@@ -10,4 +10,6 @@ void main(void)
        pthread_mutex_lock(&a);
        pthread_mutex_unlock(&a);
        pthread_mutex_unlock(&a);
+
+       pthread_mutex_destroy(&a);
 }