WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-changelog

[Xen-changelog] [xen-unstable] spinlock: Modify recursive spinlock defin

To: xen-changelog@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-changelog] [xen-unstable] spinlock: Modify recursive spinlock definitions to support up to 4095 CPUs.
From: Xen patchbot-unstable <patchbot-unstable@xxxxxxxxxxxxxxxxxxx>
Date: Wed, 22 Oct 2008 07:50:46 -0700
Delivery-date: Wed, 22 Oct 2008 07:52:45 -0700
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-changelog-request@lists.xensource.com?subject=help>
List-id: BK change log <xen-changelog.lists.xensource.com>
List-post: <mailto:xen-changelog@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=unsubscribe>
Reply-to: xen-devel@xxxxxxxxxxxxxxxxxxx
Sender: xen-changelog-bounces@xxxxxxxxxxxxxxxxxxx
# HG changeset patch
# User Keir Fraser <keir.fraser@xxxxxxxxxx>
# Date 1224519405 -3600
# Node ID 54d74fc0037ce688e79759ca632d3918f7aaa399
# Parent  f4dab783b58b41f2c67a66d6d095887faec3c296
spinlock: Modify recursive spinlock definitions to support up to 4095 CPUs.
Signed-off-by: Keir Fraser <keir.fraser@xxxxxxxxxx>
---
 xen/common/spinlock.c      |    9 ++++++++-
 xen/include/xen/spinlock.h |    6 +++---
 2 files changed, 11 insertions(+), 4 deletions(-)

diff -r f4dab783b58b -r 54d74fc0037c xen/common/spinlock.c
--- a/xen/common/spinlock.c     Mon Oct 20 16:49:25 2008 +0100
+++ b/xen/common/spinlock.c     Mon Oct 20 17:16:45 2008 +0100
@@ -57,11 +57,18 @@ void _spin_lock_recursive(spinlock_t *lo
 void _spin_lock_recursive(spinlock_t *lock)
 {
     int cpu = smp_processor_id();
+
+    /* Don't allow overflow of recurse_cpu field. */
+    BUILD_BUG_ON(NR_CPUS > 0xfffu);
+
     if ( likely(lock->recurse_cpu != cpu) )
     {
         spin_lock(lock);
         lock->recurse_cpu = cpu;
     }
+
+    /* We support only fairly shallow recursion, else the counter overflows. */
+    ASSERT(lock->recurse_cnt < 0xfu);
     lock->recurse_cnt++;
 }
 
@@ -69,7 +76,7 @@ void _spin_unlock_recursive(spinlock_t *
 {
     if ( likely(--lock->recurse_cnt == 0) )
     {
-        lock->recurse_cpu = -1;
+        lock->recurse_cpu = 0xfffu;
         spin_unlock(lock);
     }
 }
diff -r f4dab783b58b -r 54d74fc0037c xen/include/xen/spinlock.h
--- a/xen/include/xen/spinlock.h        Mon Oct 20 16:49:25 2008 +0100
+++ b/xen/include/xen/spinlock.h        Mon Oct 20 17:16:45 2008 +0100
@@ -7,11 +7,11 @@
 
 typedef struct {
     raw_spinlock_t raw;
-    s8 recurse_cpu;
-    u8 recurse_cnt;
+    u16 recurse_cpu:12;
+    u16 recurse_cnt:4;
 } spinlock_t;
 
-#define SPIN_LOCK_UNLOCKED { _RAW_SPIN_LOCK_UNLOCKED, -1, 0 }
+#define SPIN_LOCK_UNLOCKED { _RAW_SPIN_LOCK_UNLOCKED, 0xfffu, 0 }
 #define DEFINE_SPINLOCK(l) spinlock_t l = SPIN_LOCK_UNLOCKED
 #define spin_lock_init(l) (*(l) = (spinlock_t)SPIN_LOCK_UNLOCKED)
 

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

<Prev in Thread] Current Thread [Next in Thread>
  • [Xen-changelog] [xen-unstable] spinlock: Modify recursive spinlock definitions to support up to 4095 CPUs., Xen patchbot-unstable <=