* [patch] spinlock_debug: don't recompute (jiffies_per_loop * HZ) in spinloop
@ 2006-07-21 22:30 Chuck Ebbert
0 siblings, 0 replies; only message in thread
From: Chuck Ebbert @ 2006-07-21 22:30 UTC (permalink / raw)
To: linux-kernel; +Cc: Andrew Morton, Ingo Molnar, Linus Torvalds
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>
---
__delay() should really be declared __attribute_pure.
--- 2.6.18-rc2-64-numa.orig/lib/spinlock_debug.c
+++ 2.6.18-rc2-64-numa/lib/spinlock_debug.c
@@ -99,11 +99,12 @@ static inline void debug_spin_unlock(spi
static void __spin_lock_debug(spinlock_t *lock)
{
- int print_once = 1;
u64 i;
+ u64 loops = loops_per_jiffy * HZ;
+ int print_once = 1;
for (;;) {
- for (i = 0; i < loops_per_jiffy * HZ; i++) {
+ for (i = 0; i < loops; i++) {
if (__raw_spin_trylock(&lock->raw_lock))
return;
__delay(1);
@@ -164,11 +165,12 @@ static void rwlock_bug(rwlock_t *lock, c
static void __read_lock_debug(rwlock_t *lock)
{
- int print_once = 1;
u64 i;
+ u64 loops = loops_per_jiffy * HZ;
+ int print_once = 1;
for (;;) {
- for (i = 0; i < loops_per_jiffy * HZ; i++) {
+ for (i = 0; i < loops; i++) {
if (__raw_read_trylock(&lock->raw_lock))
return;
__delay(1);
@@ -237,11 +239,12 @@ static inline void debug_write_unlock(rw
static void __write_lock_debug(rwlock_t *lock)
{
- int print_once = 1;
u64 i;
+ u64 loops = loops_per_jiffy * HZ;
+ int print_once = 1;
for (;;) {
- for (i = 0; i < loops_per_jiffy * HZ; i++) {
+ for (i = 0; i < loops; i++) {
if (__raw_write_trylock(&lock->raw_lock))
return;
__delay(1);
--
Chuck
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2006-07-21 22:36 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-07-21 22:30 [patch] spinlock_debug: don't recompute (jiffies_per_loop * HZ) in spinloop Chuck Ebbert
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®