From: Ingo Molnar <[EMAIL PROTECTED]>

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]>
---

 lib/spinlock_debug.c |    6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)

diff -puN 
lib/spinlock_debug.c~fix-spinlock-debugging-delays-to-not-time-out-too-early 
lib/spinlock_debug.c
--- 
devel/lib/spinlock_debug.c~fix-spinlock-debugging-delays-to-not-time-out-too-early
  2006-02-07 09:40:57.000000000 -0800
+++ devel-akpm/lib/spinlock_debug.c     2006-02-07 09:40:57.000000000 -0800
@@ -72,9 +72,9 @@ static void __spin_lock_debug(spinlock_t
 
        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) {
@@ -144,9 +144,9 @@ static void __read_lock_debug(rwlock_t *
 
        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) {
@@ -217,9 +217,9 @@ static void __write_lock_debug(rwlock_t 
 
        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) {
_
-
To unsubscribe from this list: send the line "unsubscribe linux-arch" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to