diff options
author | Chuck Ebbert <76306.1226@compuserve.com> | 2006-09-29 04:59:14 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@g5.osdl.org> | 2006-09-29 12:18:06 -0400 |
commit | c22f008ba226e2ff25ee1a56abd9c5fd355828fc (patch) | |
tree | ffa01da1cf0dec73de897889a1aa5f354f521df1 | |
parent | 92a0f861fe1790dad55ea249169d94f2dc88d696 (diff) |
[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: Chuck Ebbert <76306.1226@compuserve.com>
Cc: Ingo Molnar <mingo@elte.hu>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
-rw-r--r-- | lib/spinlock_debug.c | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/lib/spinlock_debug.c b/lib/spinlock_debug.c index 58c577dd82e5..dafaf1de2491 100644 --- a/lib/spinlock_debug.c +++ b/lib/spinlock_debug.c | |||
@@ -99,11 +99,12 @@ static inline void debug_spin_unlock(spinlock_t *lock) | |||
99 | 99 | ||
100 | static void __spin_lock_debug(spinlock_t *lock) | 100 | static void __spin_lock_debug(spinlock_t *lock) |
101 | { | 101 | { |
102 | int print_once = 1; | ||
103 | u64 i; | 102 | u64 i; |
103 | u64 loops = loops_per_jiffy * HZ; | ||
104 | int print_once = 1; | ||
104 | 105 | ||
105 | for (;;) { | 106 | for (;;) { |
106 | for (i = 0; i < loops_per_jiffy * HZ; i++) { | 107 | for (i = 0; i < loops; i++) { |
107 | if (__raw_spin_trylock(&lock->raw_lock)) | 108 | if (__raw_spin_trylock(&lock->raw_lock)) |
108 | return; | 109 | return; |
109 | __delay(1); | 110 | __delay(1); |
@@ -165,11 +166,12 @@ static void rwlock_bug(rwlock_t *lock, const char *msg) | |||
165 | #if 0 /* __write_lock_debug() can lock up - maybe this can too? */ | 166 | #if 0 /* __write_lock_debug() can lock up - maybe this can too? */ |
166 | static void __read_lock_debug(rwlock_t *lock) | 167 | static void __read_lock_debug(rwlock_t *lock) |
167 | { | 168 | { |
168 | int print_once = 1; | ||
169 | u64 i; | 169 | u64 i; |
170 | u64 loops = loops_per_jiffy * HZ; | ||
171 | int print_once = 1; | ||
170 | 172 | ||
171 | for (;;) { | 173 | for (;;) { |
172 | for (i = 0; i < loops_per_jiffy * HZ; i++) { | 174 | for (i = 0; i < loops; i++) { |
173 | if (__raw_read_trylock(&lock->raw_lock)) | 175 | if (__raw_read_trylock(&lock->raw_lock)) |
174 | return; | 176 | return; |
175 | __delay(1); | 177 | __delay(1); |
@@ -239,11 +241,12 @@ static inline void debug_write_unlock(rwlock_t *lock) | |||
239 | #if 0 /* This can cause lockups */ | 241 | #if 0 /* This can cause lockups */ |
240 | static void __write_lock_debug(rwlock_t *lock) | 242 | static void __write_lock_debug(rwlock_t *lock) |
241 | { | 243 | { |
242 | int print_once = 1; | ||
243 | u64 i; | 244 | u64 i; |
245 | u64 loops = loops_per_jiffy * HZ; | ||
246 | int print_once = 1; | ||
244 | 247 | ||
245 | for (;;) { | 248 | for (;;) { |
246 | for (i = 0; i < loops_per_jiffy * HZ; i++) { | 249 | for (i = 0; i < loops; i++) { |
247 | if (__raw_write_trylock(&lock->raw_lock)) | 250 | if (__raw_write_trylock(&lock->raw_lock)) |
248 | return; | 251 | return; |
249 | __delay(1); | 252 | __delay(1); |