lkml.org 
[lkml]   [2014]   [Apr]   [29]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Subject[PATCH] lib/spinlock_debug: avoid one thread can not obtain the spinlock for a long time.
From
Date
loops_per_jiffy is larger than expectation that possible
causes one thread can not obtain the spin lock for a long time.
So use cpu_clock() to reach timeout in one second which can
avoid HARD LOCKUP.

Signed-off-by: Chuansheng Liu <chuansheng.liu@intel.com>
Signed-off-by: xiaoming wang <xiaoming.wang@intel.com>
---
kernel/locking/spinlock_debug.c | 8 +++++++-
1 files changed, 7 insertions(+), 1 deletions(-)

diff --git a/kernel/locking/spinlock_debug.c b/kernel/locking/spinlock_debug.c
index 0374a59..5d3c4f3 100644
--- a/kernel/locking/spinlock_debug.c
+++ b/kernel/locking/spinlock_debug.c
@@ -105,13 +105,19 @@ static inline void debug_spin_unlock(raw_spinlock_t *lock)

static void __spin_lock_debug(raw_spinlock_t *lock)
{
- u64 i;
+ u64 i, t;
u64 loops = loops_per_jiffy * HZ;
+ u64 one_second = 1000000000;
+ u32 this_cpu = raw_smp_processor_id();
+
+ t = cpu_clock(this_cpu);

for (i = 0; i < loops; i++) {
if (arch_spin_trylock(&lock->raw_lock))
return;
__delay(1);
+ if (cpu_clock(this_cpu) - t > one_second)
+ break;
}
/* lockup suspected: */
spin_dump(lock, "lockup suspected");
--
1.7.1



\
 
 \ /
  Last update: 2014-04-30 05:21    [W:0.040 / U:0.604 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site