From: Juergen Gross Subject: [Patch] don't spin with irq disabled Date: Thu, 26 Mar 2009 10:00:14 +0100 Message-ID: <49CB441E.9030006@fujitsu-siemens.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="------------060105030706090303090904" Return-path: List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xensource.com Errors-To: xen-devel-bounces@lists.xensource.com To: "xen-devel@lists.xensource.com" List-Id: xen-devel@lists.xenproject.org This is a multi-part message in MIME format. --------------060105030706090303090904 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit 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 --------------060105030706090303090904 Content-Type: text/x-patch; name="spinirq.patch" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="spinirq.patch" 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 #include #include +#include #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; } --------------060105030706090303090904 Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel --------------060105030706090303090904--