ia64/xen-unstable

changeset 18668:54d74fc0037c

spinlock: Modify recursive spinlock definitions to support up to 4095 CPUs.
Signed-off-by: Keir Fraser <keir.fraser@citrix.com>
author Keir Fraser <keir.fraser@citrix.com>
date Mon Oct 20 17:16:45 2008 +0100 (2008-10-20)
parents f4dab783b58b
children 7989e3999e83
files xen/common/spinlock.c xen/include/xen/spinlock.h
line diff
     1.1 --- a/xen/common/spinlock.c	Mon Oct 20 16:49:25 2008 +0100
     1.2 +++ b/xen/common/spinlock.c	Mon Oct 20 17:16:45 2008 +0100
     1.3 @@ -57,11 +57,18 @@ void _spin_barrier(spinlock_t *lock)
     1.4  void _spin_lock_recursive(spinlock_t *lock)
     1.5  {
     1.6      int cpu = smp_processor_id();
     1.7 +
     1.8 +    /* Don't allow overflow of recurse_cpu field. */
     1.9 +    BUILD_BUG_ON(NR_CPUS > 0xfffu);
    1.10 +
    1.11      if ( likely(lock->recurse_cpu != cpu) )
    1.12      {
    1.13          spin_lock(lock);
    1.14          lock->recurse_cpu = cpu;
    1.15      }
    1.16 +
    1.17 +    /* We support only fairly shallow recursion, else the counter overflows. */
    1.18 +    ASSERT(lock->recurse_cnt < 0xfu);
    1.19      lock->recurse_cnt++;
    1.20  }
    1.21  
    1.22 @@ -69,7 +76,7 @@ void _spin_unlock_recursive(spinlock_t *
    1.23  {
    1.24      if ( likely(--lock->recurse_cnt == 0) )
    1.25      {
    1.26 -        lock->recurse_cpu = -1;
    1.27 +        lock->recurse_cpu = 0xfffu;
    1.28          spin_unlock(lock);
    1.29      }
    1.30  }
     2.1 --- a/xen/include/xen/spinlock.h	Mon Oct 20 16:49:25 2008 +0100
     2.2 +++ b/xen/include/xen/spinlock.h	Mon Oct 20 17:16:45 2008 +0100
     2.3 @@ -7,11 +7,11 @@
     2.4  
     2.5  typedef struct {
     2.6      raw_spinlock_t raw;
     2.7 -    s8 recurse_cpu;
     2.8 -    u8 recurse_cnt;
     2.9 +    u16 recurse_cpu:12;
    2.10 +    u16 recurse_cnt:4;
    2.11  } spinlock_t;
    2.12  
    2.13 -#define SPIN_LOCK_UNLOCKED { _RAW_SPIN_LOCK_UNLOCKED, -1, 0 }
    2.14 +#define SPIN_LOCK_UNLOCKED { _RAW_SPIN_LOCK_UNLOCKED, 0xfffu, 0 }
    2.15  #define DEFINE_SPINLOCK(l) spinlock_t l = SPIN_LOCK_UNLOCKED
    2.16  #define spin_lock_init(l) (*(l) = (spinlock_t)SPIN_LOCK_UNLOCKED)
    2.17