1
0

Merge branch 'locking-core-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip

Pull locking updates from Ingo Molnar:
 "The main change in this cycle are initial preparatory bits of dynamic
  lockdep keys support from Bart Van Assche.

  There are also misc changes, a comment cleanup and a data structure
  cleanup"

* 'locking-core-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip:
  sched/fair: Clean up comment in nohz_idle_balance()
  locking/lockdep: Stop using RCU primitives to access 'all_lock_classes'
  locking/lockdep: Make concurrent lockdep_reset_lock() calls safe
  locking/lockdep: Remove a superfluous INIT_LIST_HEAD() statement
  locking/lockdep: Introduce lock_class_cache_is_registered()
  locking/lockdep: Inline __lockdep_init_map()
  locking/lockdep: Declare local symbols static
  tools/lib/lockdep/tests: Test the lockdep_reset_lock() implementation
  tools/lib/lockdep: Add dummy print_irqtrace_events() implementation
  tools/lib/lockdep: Rename "trywlock" into "trywrlock"
  tools/lib/lockdep/tests: Run lockdep tests a second time under Valgrind
  tools/lib/lockdep/tests: Improve testing accuracy
  tools/lib/lockdep/tests: Fix shellcheck warnings
  tools/lib/lockdep/tests: Display compiler warning and error messages
  locking/lockdep: Remove ::version from lock_class structure
This commit is contained in:
Linus Torvalds
2018-12-26 14:25:52 -08:00
26 changed files with 132 additions and 54 deletions

View 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) \

View 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);
}

View File

@@ -60,10 +60,10 @@ static inline int liblockdep_pthread_rwlock_tryrdlock(liblockdep_pthread_rwlock_
return pthread_rwlock_tryrdlock(&lock->rwlock) == 0 ? 1 : 0;
}
static inline int liblockdep_pthread_rwlock_trywlock(liblockdep_pthread_rwlock_t *lock)
static inline int liblockdep_pthread_rwlock_trywrlock(liblockdep_pthread_rwlock_t *lock)
{
lock_acquire(&lock->dep_map, 0, 1, 0, 1, NULL, (unsigned long)_RET_IP_);
return pthread_rwlock_trywlock(&lock->rwlock) == 0 ? 1 : 0;
return pthread_rwlock_trywrlock(&lock->rwlock) == 0 ? 1 : 0;
}
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)
#define pthread_rwlock_unlock liblockdep_pthread_rwlock_unlock
#define pthread_rwlock_wrlock liblockdep_pthread_rwlock_wrlock
#define pthread_rwlock_tryrdlock liblockdep_pthread_rwlock_tryrdlock
#define pthread_rwlock_trywlock liblockdep_pthread_rwlock_trywlock
#define pthread_rwlock_trywrlock liblockdep_pthread_rwlock_trywrlock
#define pthread_rwlock_destroy liblockdep_rwlock_destroy
#endif

View File

@@ -15,6 +15,11 @@ u32 prandom_u32(void)
abort();
}
void print_irqtrace_events(struct task_struct *curr)
{
abort();
}
static struct new_utsname *init_utsname(void)
{
static struct new_utsname n = (struct new_utsname) {

View File

@@ -1,32 +1,47 @@
#! /bin/bash
# SPDX-License-Identifier: GPL-2.0
make &> /dev/null
if ! make >/dev/null; then
echo "Building liblockdep failed."
echo "FAILED!"
exit 1
fi
for i in `ls tests/*.c`; do
find tests -name '*.c' | sort | while read -r i; do
testname=$(basename "$i" .c)
gcc -o tests/$testname -pthread $i liblockdep.a -Iinclude -D__USE_LIBLOCKDEP &> /dev/null
echo -ne "$testname... "
if [ $(timeout 1 ./tests/$testname 2>&1 | wc -l) -gt 0 ]; then
if gcc -o "tests/$testname" -pthread "$i" liblockdep.a -Iinclude -D__USE_LIBLOCKDEP &&
timeout 1 "tests/$testname" 2>&1 | "tests/${testname}.sh"; then
echo "PASSED!"
else
echo "FAILED!"
fi
if [ -f "tests/$testname" ]; then
rm tests/$testname
fi
rm -f "tests/$testname"
done
for i in `ls tests/*.c`; do
find tests -name '*.c' | sort | while read -r i; do
testname=$(basename "$i" .c)
gcc -o tests/$testname -pthread -Iinclude $i &> /dev/null
echo -ne "(PRELOAD) $testname... "
if [ $(timeout 1 ./lockdep ./tests/$testname 2>&1 | wc -l) -gt 0 ]; then
if gcc -o "tests/$testname" -pthread -Iinclude "$i" &&
timeout 1 ./lockdep "tests/$testname" 2>&1 |
"tests/${testname}.sh"; then
echo "PASSED!"
else
echo "FAILED!"
fi
if [ -f "tests/$testname" ]; then
rm tests/$testname
fi
rm -f "tests/$testname"
done
find tests -name '*.c' | sort | while read -r i; do
testname=$(basename "$i" .c)
echo -ne "(PRELOAD + Valgrind) $testname... "
if gcc -o "tests/$testname" -pthread -Iinclude "$i" &&
{ timeout 10 valgrind --read-var-info=yes ./lockdep "./tests/$testname" >& "tests/${testname}.vg.out"; true; } &&
"tests/${testname}.sh" < "tests/${testname}.vg.out" &&
! grep -Eq '(^==[0-9]*== (Invalid |Uninitialised ))|Mismatched free|Source and destination overlap| UME ' "tests/${testname}.vg.out"; then
echo "PASSED!"
else
echo "FAILED!"
fi
rm -f "tests/$testname"
done

View File

@@ -0,0 +1,2 @@
#!/bin/bash
grep -q 'WARNING: possible recursive locking detected'

View File

@@ -0,0 +1,2 @@
#!/bin/bash
grep -q 'WARNING: possible recursive locking detected'

View 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);
}

View File

@@ -0,0 +1,2 @@
#!/bin/bash
grep -q 'WARNING: possible circular locking dependency detected'

View File

@@ -0,0 +1,2 @@
#!/bin/bash
grep -q 'WARNING: possible circular locking dependency detected'

View 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);
}

View File

@@ -0,0 +1,2 @@
#!/bin/bash
grep -q 'WARNING: possible circular locking dependency detected'

View 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);
}

View File

@@ -0,0 +1,2 @@
#!/bin/bash
grep -q 'WARNING: possible circular locking dependency detected'

View 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);
}

View File

@@ -0,0 +1,2 @@
#!/bin/bash
grep -q 'WARNING: possible circular locking dependency detected'

View 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);
}

View File

@@ -0,0 +1,2 @@
#!/bin/bash
grep -q 'WARNING: possible circular locking dependency detected'

View 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);
}

View File

@@ -0,0 +1,2 @@
#!/bin/bash
grep -q 'WARNING: possible circular locking dependency detected'

View File

@@ -0,0 +1,2 @@
#!/bin/bash
grep -q 'WARNING: possible recursive locking detected'

View File

@@ -10,4 +10,6 @@ void main(void)
pthread_mutex_lock(&a);
pthread_mutex_unlock(&a);
pthread_mutex_unlock(&a);
pthread_mutex_destroy(&a);
}

View File

@@ -0,0 +1,2 @@
#!/bin/bash
grep -q 'WARNING: bad unlock balance detected'