From: Andi Kleen <ak@suse.de>
To: torvalds@osdl.org
Cc: mingo@elte.hu, akpm@osdl.org, linux-kernel@vger.kernel.org
Subject: [PATCH] Prevent spinlock debug from timing out too early
Date: Mon, 6 Feb 2006 22:16:28 +0100 [thread overview]
Message-ID: <200602062216.28943.ak@suse.de> (raw)
In modern Linux loops_per_jiffie doesn't have much relationship to how
fast the CPU can really execute loops because delay works in a different way.
Unfortunately the spinlock debugging code used it for that, which
caused it it time timeout much earlier that a second.
A second is quite a long time for a spinlock, but there are situations
that can hold them quite long (debug output over slow serial
line, SCSI driver in recovery etc.), so it's better to not time out
too early.
This patch changes it to use jiffies to check for the timeout.
It has the small drawback over the previous case that if jiffies
doesn't tick anymore you won't get any timed out spinlocks, but
normally NMI watchdog should catch that anyways.
Signed-off-by: Andi Kleen <ak@suse.de>
Index: linux-2.6.15/lib/spinlock_debug.c
===================================================================
--- linux-2.6.15.orig/lib/spinlock_debug.c
+++ linux-2.6.15/lib/spinlock_debug.c
@@ -68,13 +68,13 @@ static inline void debug_spin_unlock(spi
static void __spin_lock_debug(spinlock_t *lock)
{
int print_once = 1;
- u64 i;
for (;;) {
- for (i = 0; i < loops_per_jiffy * HZ; i++) {
- cpu_relax();
+ unsigned long timeout = jiffies + HZ;
+ while (time_before(jiffies, timeout)) {
if (__raw_spin_trylock(&lock->raw_lock))
return;
+ cpu_relax();
}
/* lockup suspected: */
if (print_once) {
next reply other threads:[~2006-02-06 21:22 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-02-06 21:16 Andi Kleen [this message]
2006-02-06 21:36 ` [PATCH] Prevent spinlock debug from timing out too early Ingo Molnar
2006-02-06 21:42 ` Andi Kleen
2006-02-06 23:22 ` Ingo Molnar
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=200602062216.28943.ak@suse.de \
--to=ak@suse.de \
--cc=akpm@osdl.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@elte.hu \
--cc=torvalds@osdl.org \
/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