diff options
author | Keir Fraser <keir.fraser@citrix.com> | 2008-10-20 17:16:45 +0100 |
---|---|---|
committer | Keir Fraser <keir.fraser@citrix.com> | 2008-10-20 17:16:45 +0100 |
commit | fe5e1a6aad56ca585e092eeb965f58b1e09c2c4f (patch) | |
tree | b40ecb6b75d2ea1cb5f0cc4aa864f3ad9cf6dbc4 /xen/common/spinlock.c | |
parent | e7f7c7b12b045bbc5f37649e285c286e04cd1aa3 (diff) | |
download | xen-fe5e1a6aad56ca585e092eeb965f58b1e09c2c4f.tar.gz xen-fe5e1a6aad56ca585e092eeb965f58b1e09c2c4f.tar.bz2 xen-fe5e1a6aad56ca585e092eeb965f58b1e09c2c4f.zip |
spinlock: Modify recursive spinlock definitions to support up to 4095 CPUs.
Signed-off-by: Keir Fraser <keir.fraser@citrix.com>
Diffstat (limited to 'xen/common/spinlock.c')
-rw-r--r-- | xen/common/spinlock.c | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/xen/common/spinlock.c b/xen/common/spinlock.c index 9e9369a432..15420ebfe7 100644 --- a/xen/common/spinlock.c +++ b/xen/common/spinlock.c @@ -57,11 +57,18 @@ void _spin_barrier(spinlock_t *lock) 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 *lock) { if ( likely(--lock->recurse_cnt == 0) ) { - lock->recurse_cpu = -1; + lock->recurse_cpu = 0xfffu; spin_unlock(lock); } } |