diff options
Diffstat (limited to 'tools')
23 files changed, 87 insertions, 15 deletions
diff --git a/tools/lib/lockdep/include/liblockdep/common.h b/tools/lib/lockdep/include/liblockdep/common.h index 8862da80995a..d640a9761f09 100644 --- a/tools/lib/lockdep/include/liblockdep/common.h +++ b/tools/lib/lockdep/include/liblockdep/common.h | |||
@@ -44,6 +44,7 @@ void lock_acquire(struct lockdep_map *lock, unsigned int subclass, | |||
44 | struct lockdep_map *nest_lock, unsigned long ip); | 44 | struct lockdep_map *nest_lock, unsigned long ip); |
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 | extern void debug_check_no_locks_freed(const void *from, unsigned long len); | 48 | extern void debug_check_no_locks_freed(const void *from, unsigned long len); |
48 | 49 | ||
49 | #define STATIC_LOCKDEP_MAP_INIT(_name, _key) \ | 50 | #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 a80ac39f966e..2073d4e1f2f0 100644 --- a/tools/lib/lockdep/include/liblockdep/mutex.h +++ b/tools/lib/lockdep/include/liblockdep/mutex.h | |||
@@ -54,6 +54,7 @@ static inline int liblockdep_pthread_mutex_trylock(liblockdep_pthread_mutex_t *l | |||
54 | 54 | ||
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 | return pthread_mutex_destroy(&lock->mutex); | 58 | return pthread_mutex_destroy(&lock->mutex); |
58 | } | 59 | } |
59 | 60 | ||
diff --git a/tools/lib/lockdep/include/liblockdep/rwlock.h b/tools/lib/lockdep/include/liblockdep/rwlock.h index a96c3bf0fef1..365762e3a1ea 100644 --- a/tools/lib/lockdep/include/liblockdep/rwlock.h +++ b/tools/lib/lockdep/include/liblockdep/rwlock.h | |||
@@ -60,10 +60,10 @@ static inline int liblockdep_pthread_rwlock_tryrdlock(liblockdep_pthread_rwlock_ | |||
60 | return pthread_rwlock_tryrdlock(&lock->rwlock) == 0 ? 1 : 0; | 60 | return pthread_rwlock_tryrdlock(&lock->rwlock) == 0 ? 1 : 0; |
61 | } | 61 | } |
62 | 62 | ||
63 | static inline int liblockdep_pthread_rwlock_trywlock(liblockdep_pthread_rwlock_t *lock) | 63 | static inline int liblockdep_pthread_rwlock_trywrlock(liblockdep_pthread_rwlock_t *lock) |
64 | { | 64 | { |
65 | lock_acquire(&lock->dep_map, 0, 1, 0, 1, NULL, (unsigned long)_RET_IP_); | 65 | lock_acquire(&lock->dep_map, 0, 1, 0, 1, NULL, (unsigned long)_RET_IP_); |
66 | return pthread_rwlock_trywlock(&lock->rwlock) == 0 ? 1 : 0; | 66 | return pthread_rwlock_trywrlock(&lock->rwlock) == 0 ? 1 : 0; |
67 | } | 67 | } |
68 | 68 | ||
69 | static inline int liblockdep_rwlock_destroy(liblockdep_pthread_rwlock_t *lock) | 69 | static inline int liblockdep_rwlock_destroy(liblockdep_pthread_rwlock_t *lock) |
@@ -79,7 +79,7 @@ static inline int liblockdep_rwlock_destroy(liblockdep_pthread_rwlock_t *lock) | |||
79 | #define pthread_rwlock_unlock liblockdep_pthread_rwlock_unlock | 79 | #define pthread_rwlock_unlock liblockdep_pthread_rwlock_unlock |
80 | #define pthread_rwlock_wrlock liblockdep_pthread_rwlock_wrlock | 80 | #define pthread_rwlock_wrlock liblockdep_pthread_rwlock_wrlock |
81 | #define pthread_rwlock_tryrdlock liblockdep_pthread_rwlock_tryrdlock | 81 | #define pthread_rwlock_tryrdlock liblockdep_pthread_rwlock_tryrdlock |
82 | #define pthread_rwlock_trywlock liblockdep_pthread_rwlock_trywlock | 82 | #define pthread_rwlock_trywrlock liblockdep_pthread_rwlock_trywrlock |
83 | #define pthread_rwlock_destroy liblockdep_rwlock_destroy | 83 | #define pthread_rwlock_destroy liblockdep_rwlock_destroy |
84 | 84 | ||
85 | #endif | 85 | #endif |
diff --git a/tools/lib/lockdep/lockdep.c b/tools/lib/lockdep/lockdep.c index 6002fcf2f9bc..348a9d0fb766 100644 --- a/tools/lib/lockdep/lockdep.c +++ b/tools/lib/lockdep/lockdep.c | |||
@@ -15,6 +15,11 @@ u32 prandom_u32(void) | |||
15 | abort(); | 15 | abort(); |
16 | } | 16 | } |
17 | 17 | ||
18 | void print_irqtrace_events(struct task_struct *curr) | ||
19 | { | ||
20 | abort(); | ||
21 | } | ||
22 | |||
18 | static struct new_utsname *init_utsname(void) | 23 | static struct new_utsname *init_utsname(void) |
19 | { | 24 | { |
20 | static struct new_utsname n = (struct new_utsname) { | 25 | static struct new_utsname n = (struct new_utsname) { |
diff --git a/tools/lib/lockdep/run_tests.sh b/tools/lib/lockdep/run_tests.sh index 2e570a188f16..c8fbd0306960 100755 --- a/tools/lib/lockdep/run_tests.sh +++ b/tools/lib/lockdep/run_tests.sh | |||
@@ -1,32 +1,47 @@ | |||
1 | #! /bin/bash | 1 | #! /bin/bash |
2 | # SPDX-License-Identifier: GPL-2.0 | 2 | # SPDX-License-Identifier: GPL-2.0 |
3 | 3 | ||
4 | make &> /dev/null | 4 | if ! make >/dev/null; then |
5 | echo "Building liblockdep failed." | ||
6 | echo "FAILED!" | ||
7 | exit 1 | ||
8 | fi | ||
5 | 9 | ||
6 | for i in `ls tests/*.c`; do | 10 | find tests -name '*.c' | sort | while read -r i; do |
7 | testname=$(basename "$i" .c) | 11 | testname=$(basename "$i" .c) |
8 | gcc -o tests/$testname -pthread $i liblockdep.a -Iinclude -D__USE_LIBLOCKDEP &> /dev/null | ||
9 | echo -ne "$testname... " | 12 | echo -ne "$testname... " |
10 | if [ $(timeout 1 ./tests/$testname 2>&1 | wc -l) -gt 0 ]; then | 13 | if gcc -o "tests/$testname" -pthread "$i" liblockdep.a -Iinclude -D__USE_LIBLOCKDEP && |
14 | timeout 1 "tests/$testname" 2>&1 | "tests/${testname}.sh"; then | ||
11 | echo "PASSED!" | 15 | echo "PASSED!" |
12 | else | 16 | else |
13 | echo "FAILED!" | 17 | echo "FAILED!" |
14 | fi | 18 | fi |
15 | if [ -f "tests/$testname" ]; then | 19 | rm -f "tests/$testname" |
16 | rm tests/$testname | ||
17 | fi | ||
18 | done | 20 | done |
19 | 21 | ||
20 | for i in `ls tests/*.c`; do | 22 | find tests -name '*.c' | sort | while read -r i; do |
21 | testname=$(basename "$i" .c) | 23 | testname=$(basename "$i" .c) |
22 | gcc -o tests/$testname -pthread -Iinclude $i &> /dev/null | ||
23 | echo -ne "(PRELOAD) $testname... " | 24 | echo -ne "(PRELOAD) $testname... " |
24 | if [ $(timeout 1 ./lockdep ./tests/$testname 2>&1 | wc -l) -gt 0 ]; then | 25 | if gcc -o "tests/$testname" -pthread -Iinclude "$i" && |
26 | timeout 1 ./lockdep "tests/$testname" 2>&1 | | ||
27 | "tests/${testname}.sh"; then | ||
25 | echo "PASSED!" | 28 | echo "PASSED!" |
26 | else | 29 | else |
27 | echo "FAILED!" | 30 | echo "FAILED!" |
28 | fi | 31 | fi |
29 | if [ -f "tests/$testname" ]; then | 32 | rm -f "tests/$testname" |
30 | rm tests/$testname | 33 | done |
34 | |||
35 | find tests -name '*.c' | sort | while read -r i; do | ||
36 | testname=$(basename "$i" .c) | ||
37 | echo -ne "(PRELOAD + Valgrind) $testname... " | ||
38 | if gcc -o "tests/$testname" -pthread -Iinclude "$i" && | ||
39 | { timeout 10 valgrind --read-var-info=yes ./lockdep "./tests/$testname" >& "tests/${testname}.vg.out"; true; } && | ||
40 | "tests/${testname}.sh" < "tests/${testname}.vg.out" && | ||
41 | ! grep -Eq '(^==[0-9]*== (Invalid |Uninitialised ))|Mismatched free|Source and destination overlap| UME ' "tests/${testname}.vg.out"; then | ||
42 | echo "PASSED!" | ||
43 | else | ||
44 | echo "FAILED!" | ||
31 | fi | 45 | fi |
46 | rm -f "tests/$testname" | ||
32 | done | 47 | done |
diff --git a/tools/lib/lockdep/tests/AA.sh b/tools/lib/lockdep/tests/AA.sh new file mode 100644 index 000000000000..f39b32865074 --- /dev/null +++ b/tools/lib/lockdep/tests/AA.sh | |||
@@ -0,0 +1,2 @@ | |||
1 | #!/bin/bash | ||
2 | grep -q 'WARNING: possible recursive locking detected' | ||
diff --git a/tools/lib/lockdep/tests/ABA.sh b/tools/lib/lockdep/tests/ABA.sh new file mode 100644 index 000000000000..f39b32865074 --- /dev/null +++ b/tools/lib/lockdep/tests/ABA.sh | |||
@@ -0,0 +1,2 @@ | |||
1 | #!/bin/bash | ||
2 | grep -q 'WARNING: possible recursive locking detected' | ||
diff --git a/tools/lib/lockdep/tests/ABBA.c b/tools/lib/lockdep/tests/ABBA.c index 1460afd33d71..623313f54720 100644 --- a/tools/lib/lockdep/tests/ABBA.c +++ b/tools/lib/lockdep/tests/ABBA.c | |||
@@ -11,4 +11,7 @@ void main(void) | |||
11 | 11 | ||
12 | LOCK_UNLOCK_2(a, b); | 12 | LOCK_UNLOCK_2(a, b); |
13 | LOCK_UNLOCK_2(b, a); | 13 | LOCK_UNLOCK_2(b, a); |
14 | |||
15 | pthread_mutex_destroy(&b); | ||
16 | pthread_mutex_destroy(&a); | ||
14 | } | 17 | } |
diff --git a/tools/lib/lockdep/tests/ABBA.sh b/tools/lib/lockdep/tests/ABBA.sh new file mode 100644 index 000000000000..fc31c607a5a8 --- /dev/null +++ b/tools/lib/lockdep/tests/ABBA.sh | |||
@@ -0,0 +1,2 @@ | |||
1 | #!/bin/bash | ||
2 | grep -q 'WARNING: possible circular locking dependency detected' | ||
diff --git a/tools/lib/lockdep/tests/ABBA_2threads.sh b/tools/lib/lockdep/tests/ABBA_2threads.sh new file mode 100644 index 000000000000..fc31c607a5a8 --- /dev/null +++ b/tools/lib/lockdep/tests/ABBA_2threads.sh | |||
@@ -0,0 +1,2 @@ | |||
1 | #!/bin/bash | ||
2 | grep -q 'WARNING: possible circular locking dependency detected' | ||
diff --git a/tools/lib/lockdep/tests/ABBCCA.c b/tools/lib/lockdep/tests/ABBCCA.c index a54c1b2af118..48446129d496 100644 --- a/tools/lib/lockdep/tests/ABBCCA.c +++ b/tools/lib/lockdep/tests/ABBCCA.c | |||
@@ -13,4 +13,8 @@ void main(void) | |||
13 | LOCK_UNLOCK_2(a, b); | 13 | LOCK_UNLOCK_2(a, b); |
14 | LOCK_UNLOCK_2(b, c); | 14 | LOCK_UNLOCK_2(b, c); |
15 | LOCK_UNLOCK_2(c, a); | 15 | LOCK_UNLOCK_2(c, a); |
16 | |||
17 | pthread_mutex_destroy(&c); | ||
18 | pthread_mutex_destroy(&b); | ||
19 | pthread_mutex_destroy(&a); | ||
16 | } | 20 | } |
diff --git a/tools/lib/lockdep/tests/ABBCCA.sh b/tools/lib/lockdep/tests/ABBCCA.sh new file mode 100644 index 000000000000..fc31c607a5a8 --- /dev/null +++ b/tools/lib/lockdep/tests/ABBCCA.sh | |||
@@ -0,0 +1,2 @@ | |||
1 | #!/bin/bash | ||
2 | grep -q 'WARNING: possible circular locking dependency detected' | ||
diff --git a/tools/lib/lockdep/tests/ABBCCDDA.c b/tools/lib/lockdep/tests/ABBCCDDA.c index aa5d194e8869..3570bf7b3804 100644 --- a/tools/lib/lockdep/tests/ABBCCDDA.c +++ b/tools/lib/lockdep/tests/ABBCCDDA.c | |||
@@ -15,4 +15,9 @@ void main(void) | |||
15 | LOCK_UNLOCK_2(b, c); | 15 | LOCK_UNLOCK_2(b, c); |
16 | LOCK_UNLOCK_2(c, d); | 16 | LOCK_UNLOCK_2(c, d); |
17 | LOCK_UNLOCK_2(d, a); | 17 | LOCK_UNLOCK_2(d, a); |
18 | |||
19 | pthread_mutex_destroy(&d); | ||
20 | pthread_mutex_destroy(&c); | ||
21 | pthread_mutex_destroy(&b); | ||
22 | pthread_mutex_destroy(&a); | ||
18 | } | 23 | } |
diff --git a/tools/lib/lockdep/tests/ABBCCDDA.sh b/tools/lib/lockdep/tests/ABBCCDDA.sh new file mode 100644 index 000000000000..fc31c607a5a8 --- /dev/null +++ b/tools/lib/lockdep/tests/ABBCCDDA.sh | |||
@@ -0,0 +1,2 @@ | |||
1 | #!/bin/bash | ||
2 | grep -q 'WARNING: possible circular locking dependency detected' | ||
diff --git a/tools/lib/lockdep/tests/ABCABC.c b/tools/lib/lockdep/tests/ABCABC.c index b54a08e60416..a1c4659894cd 100644 --- a/tools/lib/lockdep/tests/ABCABC.c +++ b/tools/lib/lockdep/tests/ABCABC.c | |||
@@ -13,4 +13,8 @@ void main(void) | |||
13 | LOCK_UNLOCK_2(a, b); | 13 | LOCK_UNLOCK_2(a, b); |
14 | LOCK_UNLOCK_2(c, a); | 14 | LOCK_UNLOCK_2(c, a); |
15 | LOCK_UNLOCK_2(b, c); | 15 | LOCK_UNLOCK_2(b, c); |
16 | |||
17 | pthread_mutex_destroy(&c); | ||
18 | pthread_mutex_destroy(&b); | ||
19 | pthread_mutex_destroy(&a); | ||
16 | } | 20 | } |
diff --git a/tools/lib/lockdep/tests/ABCABC.sh b/tools/lib/lockdep/tests/ABCABC.sh new file mode 100644 index 000000000000..fc31c607a5a8 --- /dev/null +++ b/tools/lib/lockdep/tests/ABCABC.sh | |||
@@ -0,0 +1,2 @@ | |||
1 | #!/bin/bash | ||
2 | grep -q 'WARNING: possible circular locking dependency detected' | ||
diff --git a/tools/lib/lockdep/tests/ABCDBCDA.c b/tools/lib/lockdep/tests/ABCDBCDA.c index a56742250d86..335af1c90ab5 100644 --- a/tools/lib/lockdep/tests/ABCDBCDA.c +++ b/tools/lib/lockdep/tests/ABCDBCDA.c | |||
@@ -15,4 +15,9 @@ void main(void) | |||
15 | LOCK_UNLOCK_2(c, d); | 15 | LOCK_UNLOCK_2(c, d); |
16 | LOCK_UNLOCK_2(b, c); | 16 | LOCK_UNLOCK_2(b, c); |
17 | LOCK_UNLOCK_2(d, a); | 17 | LOCK_UNLOCK_2(d, a); |
18 | |||
19 | pthread_mutex_destroy(&d); | ||
20 | pthread_mutex_destroy(&c); | ||
21 | pthread_mutex_destroy(&b); | ||
22 | pthread_mutex_destroy(&a); | ||
18 | } | 23 | } |
diff --git a/tools/lib/lockdep/tests/ABCDBCDA.sh b/tools/lib/lockdep/tests/ABCDBCDA.sh new file mode 100644 index 000000000000..fc31c607a5a8 --- /dev/null +++ b/tools/lib/lockdep/tests/ABCDBCDA.sh | |||
@@ -0,0 +1,2 @@ | |||
1 | #!/bin/bash | ||
2 | grep -q 'WARNING: possible circular locking dependency detected' | ||
diff --git a/tools/lib/lockdep/tests/ABCDBDDA.c b/tools/lib/lockdep/tests/ABCDBDDA.c index 238a3353f3c3..3c5972863049 100644 --- a/tools/lib/lockdep/tests/ABCDBDDA.c +++ b/tools/lib/lockdep/tests/ABCDBDDA.c | |||
@@ -15,4 +15,9 @@ void main(void) | |||
15 | LOCK_UNLOCK_2(c, d); | 15 | LOCK_UNLOCK_2(c, d); |
16 | LOCK_UNLOCK_2(b, d); | 16 | LOCK_UNLOCK_2(b, d); |
17 | LOCK_UNLOCK_2(d, a); | 17 | LOCK_UNLOCK_2(d, a); |
18 | |||
19 | pthread_mutex_destroy(&d); | ||
20 | pthread_mutex_destroy(&c); | ||
21 | pthread_mutex_destroy(&b); | ||
22 | pthread_mutex_destroy(&a); | ||
18 | } | 23 | } |
diff --git a/tools/lib/lockdep/tests/ABCDBDDA.sh b/tools/lib/lockdep/tests/ABCDBDDA.sh new file mode 100644 index 000000000000..fc31c607a5a8 --- /dev/null +++ b/tools/lib/lockdep/tests/ABCDBDDA.sh | |||
@@ -0,0 +1,2 @@ | |||
1 | #!/bin/bash | ||
2 | grep -q 'WARNING: possible circular locking dependency detected' | ||
diff --git a/tools/lib/lockdep/tests/WW.sh b/tools/lib/lockdep/tests/WW.sh new file mode 100644 index 000000000000..f39b32865074 --- /dev/null +++ b/tools/lib/lockdep/tests/WW.sh | |||
@@ -0,0 +1,2 @@ | |||
1 | #!/bin/bash | ||
2 | grep -q 'WARNING: possible recursive locking detected' | ||
diff --git a/tools/lib/lockdep/tests/unlock_balance.c b/tools/lib/lockdep/tests/unlock_balance.c index 34cf32f689de..dba25064b50a 100644 --- a/tools/lib/lockdep/tests/unlock_balance.c +++ b/tools/lib/lockdep/tests/unlock_balance.c | |||
@@ -10,4 +10,6 @@ void main(void) | |||
10 | pthread_mutex_lock(&a); | 10 | pthread_mutex_lock(&a); |
11 | pthread_mutex_unlock(&a); | 11 | pthread_mutex_unlock(&a); |
12 | pthread_mutex_unlock(&a); | 12 | pthread_mutex_unlock(&a); |
13 | |||
14 | pthread_mutex_destroy(&a); | ||
13 | } | 15 | } |
diff --git a/tools/lib/lockdep/tests/unlock_balance.sh b/tools/lib/lockdep/tests/unlock_balance.sh new file mode 100644 index 000000000000..c6e3952303fe --- /dev/null +++ b/tools/lib/lockdep/tests/unlock_balance.sh | |||
@@ -0,0 +1,2 @@ | |||
1 | #!/bin/bash | ||
2 | grep -q 'WARNING: bad unlock balance detected' | ||