public inbox for linux-arch@vger.kernel.org
 help / color / mirror / Atom feed
From: akpm@osdl.org
To: linux-arch@vger.kernel.org
Cc: akpm@osdl.org, mingo@elte.hu, ak@muc.de
Subject: [patch 1/1] Fix spinlock debugging delays to not time out too early
Date: Tue, 07 Feb 2006 09:41:32 -0800	[thread overview]
Message-ID: <200602071741.k17Hftck007109@shell0.pdx.osdl.net> (raw)


From: Ingo Molnar <mingo@elte.hu>

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

 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) {
_

             reply	other threads:[~2006-02-07 17:42 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-02-07 17:41 akpm [this message]
  -- strict thread matches above, loose matches on Subject: below --
2006-02-07 18:20 [patch 1/1] Fix spinlock debugging delays to not time out too early Luck, Tony
2006-02-07 18:29 ` Andi Kleen
2006-02-07 18:44   ` Luck, Tony
2006-02-07 19:14     ` Ingo Molnar
2006-02-07 19:37       ` Andi Kleen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=200602071741.k17Hftck007109@shell0.pdx.osdl.net \
    --to=akpm@osdl.org \
    --cc=ak@muc.de \
    --cc=linux-arch@vger.kernel.org \
    --cc=mingo@elte.hu \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox