All of lore.kernel.org
 help / color / mirror / Atom feed
* [Patch] don't spin with irq disabled
@ 2009-03-26  9:00 Juergen Gross
  2009-03-26 12:23 ` Jan Beulich
  2009-03-26 14:27 ` [Patch] don't spin with irq disabled Keir Fraser
  0 siblings, 2 replies; 19+ messages in thread
From: Juergen Gross @ 2009-03-26  9:00 UTC (permalink / raw)
  To: xen-devel@lists.xensource.com

[-- Attachment #1: Type: text/plain, Size: 769 bytes --]

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@fujitsu-siemens.com
Otto-Hahn-Ring 6                Internet: www.fujitsu-siemens.com
D-81739 Muenchen         Company details: www.fujitsu-siemens.com/imprint.html

[-- Attachment #2: spinirq.patch --]
[-- Type: text/x-patch, Size: 1267 bytes --]

Signed-off-by: juergen.gross@fujitsu-siemens.com

# HG changeset patch
# User juergen.gross@fujitsu-siemens.com
# 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;
 }
 

[-- Attachment #3: Type: text/plain, Size: 138 bytes --]

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xensource.com
http://lists.xensource.com/xen-devel

^ permalink raw reply	[flat|nested] 19+ messages in thread

end of thread, other threads:[~2009-04-03  7:17 UTC | newest]

Thread overview: 19+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-03-26  9:00 [Patch] don't spin with irq disabled Juergen Gross
2009-03-26 12:23 ` Jan Beulich
2009-03-26 12:36   ` Juergen Gross
2009-03-27  7:41     ` Jan Beulich
2009-03-27  9:09       ` Keir Fraser
2009-03-27 17:00         ` spinlock requests (was RE: [Patch] don't spin with irq disabled) Dan Magenheimer
2009-03-27 17:46           ` Keir Fraser
2009-03-27 18:00             ` Dan Magenheimer
2009-03-27 18:12               ` Keir Fraser
2009-04-02 23:08                 ` Dan Magenheimer
2009-04-03  7:17                   ` Keir Fraser
2009-03-30  6:11           ` Juergen Gross
2009-03-31 13:12             ` Dan Magenheimer
2009-03-31 13:40               ` Juergen Gross
2009-03-31 13:48                 ` Keir Fraser
2009-03-31 19:00                   ` Jeremy Fitzhardinge
2009-03-31 20:57                     ` Keir Fraser
2009-03-31 21:16                       ` Jeremy Fitzhardinge
2009-03-26 14:27 ` [Patch] don't spin with irq disabled Keir Fraser

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.