From a81f564a7bf1655bc6a6a03bac31a641aeb75754 Mon Sep 17 00:00:00 2001 From: Vikram Mulukutla Date: Thu, 4 Oct 2012 17:13:22 -0700 Subject: [PATCH] --- yaml --- r: 330091 b: refs/heads/master c: 214f766ea0909e743122966c4617b3a112e405d7 h: refs/heads/master i: 330089: 1a410405b4f0b9a9376d2ecd10d8f35f3e50fdb8 330087: 4bf0252c80923bb34195b59b818bf339c30af828 v: v3 --- [refs] | 2 +- trunk/lib/spinlock_debug.c | 32 ++++++++++++++++++-------------- 2 files changed, 19 insertions(+), 15 deletions(-) diff --git a/[refs] b/[refs] index 937eefbc2cfd..bc26ca3072a5 100644 --- a/[refs] +++ b/[refs] @@ -1,2 +1,2 @@ --- -refs/heads/master: ca279cf1065fb689abea1dc7d8c11787729bb185 +refs/heads/master: 214f766ea0909e743122966c4617b3a112e405d7 diff --git a/trunk/lib/spinlock_debug.c b/trunk/lib/spinlock_debug.c index eb10578ae055..0374a596cffa 100644 --- a/trunk/lib/spinlock_debug.c +++ b/trunk/lib/spinlock_debug.c @@ -107,23 +107,27 @@ static void __spin_lock_debug(raw_spinlock_t *lock) { u64 i; u64 loops = loops_per_jiffy * HZ; - int print_once = 1; - for (;;) { - for (i = 0; i < loops; i++) { - if (arch_spin_trylock(&lock->raw_lock)) - return; - __delay(1); - } - /* lockup suspected: */ - if (print_once) { - print_once = 0; - spin_dump(lock, "lockup suspected"); + for (i = 0; i < loops; i++) { + if (arch_spin_trylock(&lock->raw_lock)) + return; + __delay(1); + } + /* lockup suspected: */ + spin_dump(lock, "lockup suspected"); #ifdef CONFIG_SMP - trigger_all_cpu_backtrace(); + trigger_all_cpu_backtrace(); #endif - } - } + + /* + * The trylock above was causing a livelock. Give the lower level arch + * specific lock code a chance to acquire the lock. We have already + * printed a warning/backtrace at this point. The non-debug arch + * specific code might actually succeed in acquiring the lock. If it is + * not successful, the end-result is the same - there is no forward + * progress. + */ + arch_spin_lock(&lock->raw_lock); } void do_raw_spin_lock(raw_spinlock_t *lock)