Skip to content

Commit

Permalink
[PATCH] Fix spinlock debugging delays to not time out too early
Browse files Browse the repository at this point in the history
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: Ingo Molnar <[email protected]>
Cc: Andi Kleen <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
  • Loading branch information
Ingo Molnar authored and Linus Torvalds committed Feb 8, 2006
1 parent 8519fb3 commit e0a6029
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions lib/spinlock_debug.c
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,9 @@ static void __spin_lock_debug(spinlock_t *lock)

for (;;) {
for (i = 0; i < loops_per_jiffy * HZ; i++) {
cpu_relax();
if (__raw_spin_trylock(&lock->raw_lock))
return;
__delay(1);
}
/* lockup suspected: */
if (print_once) {
Expand Down Expand Up @@ -144,9 +144,9 @@ static void __read_lock_debug(rwlock_t *lock)

for (;;) {
for (i = 0; i < loops_per_jiffy * HZ; i++) {
cpu_relax();
if (__raw_read_trylock(&lock->raw_lock))
return;
__delay(1);
}
/* lockup suspected: */
if (print_once) {
Expand Down Expand Up @@ -217,9 +217,9 @@ static void __write_lock_debug(rwlock_t *lock)

for (;;) {
for (i = 0; i < loops_per_jiffy * HZ; i++) {
cpu_relax();
if (__raw_write_trylock(&lock->raw_lock))
return;
__delay(1);
}
/* lockup suspected: */
if (print_once) {
Expand Down

0 comments on commit e0a6029

Please sign in to comment.