|
|
|
|
|
|
|
|
|
|
xen-devel
[Xen-devel] [Patch] don't spin with irq disabled
Attached patch reduces interrupt latency in lock handling.
spin_lock_irq and spin_lock_irqsave used to turn off IRQs and then tried to
get the lock. If the lock was already held, waiting for the lock was done with
IRQs still off.
The patch reenables IRQs during the wait loop.
read/write locks seem to be rarely used, so I didn't change them.
In favor for ia64 I chose not to modify the assembler code :-)
Juergen
--
Juergen Gross Principal Developer
IP SW OS6 Telephone: +49 (0) 89 636 47950
Fujitsu Siemens Computers e-mail: juergen.gross@xxxxxxxxxxxxxxxxxxx
Otto-Hahn-Ring 6 Internet: www.fujitsu-siemens.com
D-81739 Muenchen Company details: www.fujitsu-siemens.com/imprint.html
Signed-off-by: juergen.gross@xxxxxxxxxxxxxxxxxxx
# HG changeset patch
# User juergen.gross@xxxxxxxxxxxxxxxxxxx
# Date 1238057346 -3600
# Node ID b42d379abeb555152c835b1fe065666cb2438c28
# Parent 0b13d9787622d5e1d447a21657394805bb96d26f
don't spin with irq disabled
diff -r 0b13d9787622 -r b42d379abeb5 xen/common/spinlock.c
--- a/xen/common/spinlock.c Tue Mar 24 06:55:29 2009 +0000
+++ b/xen/common/spinlock.c Thu Mar 26 09:49:06 2009 +0100
@@ -2,6 +2,7 @@
#include <xen/irq.h>
#include <xen/smp.h>
#include <xen/spinlock.h>
+#include <asm/processor.h>
#ifndef NDEBUG
@@ -51,7 +52,13 @@
ASSERT(local_irq_is_enabled());
local_irq_disable();
check_lock(&lock->debug);
- _raw_spin_lock(&lock->raw);
+ while ( unlikely(!_raw_spin_trylock(&lock->raw)) )
+ {
+ local_irq_enable();
+ cpu_relax();
+ local_irq_disable();
+ }
+ return;
}
unsigned long _spin_lock_irqsave(spinlock_t *lock)
@@ -59,7 +66,12 @@
unsigned long flags;
local_irq_save(flags);
check_lock(&lock->debug);
- _raw_spin_lock(&lock->raw);
+ while ( unlikely(!_raw_spin_trylock(&lock->raw)) )
+ {
+ local_irq_restore(flags);
+ cpu_relax();
+ local_irq_save(flags);
+ }
return flags;
}
_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel
|
<Prev in Thread] |
Current Thread |
[Next in Thread>
|
- [Xen-devel] [Patch] don't spin with irq disabled,
Juergen Gross <=
|
|
|
|
|