Commit c22f008b authored by Chuck Ebbert's avatar Chuck Ebbert Committed by Linus Torvalds

[PATCH] spinlock_debug: don't recompute (jiffies_per_loop * HZ) in spinloop

In spinlock_debug.c, the spinloops call __delay() on every iteration.
Because that is an external function, (jiffies_per_loop * HZ), the loop's
iteration limit, gets recomputed every time.  Caching it explicitly
prevents that.
Signed-off-by: default avatarChuck Ebbert <76306.1226@compuserve.com>
Cc: Ingo Molnar <mingo@elte.hu>
Signed-off-by: default avatarAndrew Morton <akpm@osdl.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent 92a0f861
...@@ -99,11 +99,12 @@ static inline void debug_spin_unlock(spinlock_t *lock) ...@@ -99,11 +99,12 @@ static inline void debug_spin_unlock(spinlock_t *lock)
static void __spin_lock_debug(spinlock_t *lock) static void __spin_lock_debug(spinlock_t *lock)
{ {
int print_once = 1;
u64 i; u64 i;
u64 loops = loops_per_jiffy * HZ;
int print_once = 1;
for (;;) { for (;;) {
for (i = 0; i < loops_per_jiffy * HZ; i++) { for (i = 0; i < loops; i++) {
if (__raw_spin_trylock(&lock->raw_lock)) if (__raw_spin_trylock(&lock->raw_lock))
return; return;
__delay(1); __delay(1);
...@@ -165,11 +166,12 @@ static void rwlock_bug(rwlock_t *lock, const char *msg) ...@@ -165,11 +166,12 @@ static void rwlock_bug(rwlock_t *lock, const char *msg)
#if 0 /* __write_lock_debug() can lock up - maybe this can too? */ #if 0 /* __write_lock_debug() can lock up - maybe this can too? */
static void __read_lock_debug(rwlock_t *lock) static void __read_lock_debug(rwlock_t *lock)
{ {
int print_once = 1;
u64 i; u64 i;
u64 loops = loops_per_jiffy * HZ;
int print_once = 1;
for (;;) { for (;;) {
for (i = 0; i < loops_per_jiffy * HZ; i++) { for (i = 0; i < loops; i++) {
if (__raw_read_trylock(&lock->raw_lock)) if (__raw_read_trylock(&lock->raw_lock))
return; return;
__delay(1); __delay(1);
...@@ -239,11 +241,12 @@ static inline void debug_write_unlock(rwlock_t *lock) ...@@ -239,11 +241,12 @@ static inline void debug_write_unlock(rwlock_t *lock)
#if 0 /* This can cause lockups */ #if 0 /* This can cause lockups */
static void __write_lock_debug(rwlock_t *lock) static void __write_lock_debug(rwlock_t *lock)
{ {
int print_once = 1;
u64 i; u64 i;
u64 loops = loops_per_jiffy * HZ;
int print_once = 1;
for (;;) { for (;;) {
for (i = 0; i < loops_per_jiffy * HZ; i++) { for (i = 0; i < loops; i++) {
if (__raw_write_trylock(&lock->raw_lock)) if (__raw_write_trylock(&lock->raw_lock))
return; return;
__delay(1); __delay(1);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment