diff options
author | Ingo Molnar <mingo@elte.hu> | 2006-02-07 15:58:54 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@g5.osdl.org> | 2006-02-07 19:12:33 -0500 |
commit | e0a602963485a2f109ae1521c0c55507304c63ed (patch) | |
tree | 38900590f1d4f129cfd8748949ff62f7d3296aee | |
parent | 8519fb30e438f8088b71a94a7d5a660a814d3872 (diff) |
[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: Ingo Molnar <mingo@elte.hu>
Cc: Andi Kleen <ak@muc.de>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
-rw-r--r-- | lib/spinlock_debug.c | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/lib/spinlock_debug.c b/lib/spinlock_debug.c index c8bb8cc899d7..d8b6bb419d49 100644 --- a/lib/spinlock_debug.c +++ b/lib/spinlock_debug.c | |||
@@ -72,9 +72,9 @@ static void __spin_lock_debug(spinlock_t *lock) | |||
72 | 72 | ||
73 | for (;;) { | 73 | for (;;) { |
74 | for (i = 0; i < loops_per_jiffy * HZ; i++) { | 74 | for (i = 0; i < loops_per_jiffy * HZ; i++) { |
75 | cpu_relax(); | ||
76 | if (__raw_spin_trylock(&lock->raw_lock)) | 75 | if (__raw_spin_trylock(&lock->raw_lock)) |
77 | return; | 76 | return; |
77 | __delay(1); | ||
78 | } | 78 | } |
79 | /* lockup suspected: */ | 79 | /* lockup suspected: */ |
80 | if (print_once) { | 80 | if (print_once) { |
@@ -144,9 +144,9 @@ static void __read_lock_debug(rwlock_t *lock) | |||
144 | 144 | ||
145 | for (;;) { | 145 | for (;;) { |
146 | for (i = 0; i < loops_per_jiffy * HZ; i++) { | 146 | for (i = 0; i < loops_per_jiffy * HZ; i++) { |
147 | cpu_relax(); | ||
148 | if (__raw_read_trylock(&lock->raw_lock)) | 147 | if (__raw_read_trylock(&lock->raw_lock)) |
149 | return; | 148 | return; |
149 | __delay(1); | ||
150 | } | 150 | } |
151 | /* lockup suspected: */ | 151 | /* lockup suspected: */ |
152 | if (print_once) { | 152 | if (print_once) { |
@@ -217,9 +217,9 @@ static void __write_lock_debug(rwlock_t *lock) | |||
217 | 217 | ||
218 | for (;;) { | 218 | for (;;) { |
219 | for (i = 0; i < loops_per_jiffy * HZ; i++) { | 219 | for (i = 0; i < loops_per_jiffy * HZ; i++) { |
220 | cpu_relax(); | ||
221 | if (__raw_write_trylock(&lock->raw_lock)) | 220 | if (__raw_write_trylock(&lock->raw_lock)) |
222 | return; | 221 | return; |
222 | __delay(1); | ||
223 | } | 223 | } |
224 | /* lockup suspected: */ | 224 | /* lockup suspected: */ |
225 | if (print_once) { | 225 | if (print_once) { |