Commit e0a60296 authored by Ingo Molnar's avatar Ingo Molnar Committed by Linus Torvalds

[PATCH] Fix spinlock debugging delays to not time out too early

The spinlock-debug wait-loop was using loops_per_jiffy to detect too long
spinlock waits - but on fast CPUs this led to a way too fast timeout and false
messages.

The fix is to include a __delay(1) call in the loop, to correctly approximate
the intended delay timeout of 1 second.  The code assumes that every
architecture implements __delay(1) to last around 1/(loops_per_jiffy*HZ)
seconds.
Signed-off-by: default avatarIngo Molnar <mingo@elte.hu>
Cc: Andi Kleen <ak@muc.de>
Signed-off-by: default avatarAndrew Morton <akpm@osdl.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent 8519fb30
...@@ -72,9 +72,9 @@ static void __spin_lock_debug(spinlock_t *lock) ...@@ -72,9 +72,9 @@ static void __spin_lock_debug(spinlock_t *lock)
for (;;) { for (;;) {
for (i = 0; i < loops_per_jiffy * HZ; i++) { for (i = 0; i < loops_per_jiffy * HZ; i++) {
cpu_relax();
if (__raw_spin_trylock(&lock->raw_lock)) if (__raw_spin_trylock(&lock->raw_lock))
return; return;
__delay(1);
} }
/* lockup suspected: */ /* lockup suspected: */
if (print_once) { if (print_once) {
...@@ -144,9 +144,9 @@ static void __read_lock_debug(rwlock_t *lock) ...@@ -144,9 +144,9 @@ static void __read_lock_debug(rwlock_t *lock)
for (;;) { for (;;) {
for (i = 0; i < loops_per_jiffy * HZ; i++) { for (i = 0; i < loops_per_jiffy * HZ; i++) {
cpu_relax();
if (__raw_read_trylock(&lock->raw_lock)) if (__raw_read_trylock(&lock->raw_lock))
return; return;
__delay(1);
} }
/* lockup suspected: */ /* lockup suspected: */
if (print_once) { if (print_once) {
...@@ -217,9 +217,9 @@ static void __write_lock_debug(rwlock_t *lock) ...@@ -217,9 +217,9 @@ static void __write_lock_debug(rwlock_t *lock)
for (;;) { for (;;) {
for (i = 0; i < loops_per_jiffy * HZ; i++) { for (i = 0; i < loops_per_jiffy * HZ; i++) {
cpu_relax();
if (__raw_write_trylock(&lock->raw_lock)) if (__raw_write_trylock(&lock->raw_lock))
return; return;
__delay(1);
} }
/* lockup suspected: */ /* lockup suspected: */
if (print_once) { if (print_once) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment