aboutsummaryrefslogtreecommitdiffstats
path: root/xen/common/spinlock.c
diff options
context:
space:
mode:
authorKeir Fraser <keir.fraser@citrix.com>2010-05-14 17:07:52 +0100
committerKeir Fraser <keir.fraser@citrix.com>2010-05-14 17:07:52 +0100
commit27c31d386746bea3daa5b3733c9f986a9c3cccc3 (patch)
tree64ef675ed9b4c0836ab9076b7280e88a64f5bb16 /xen/common/spinlock.c
parent2e4146ddc277d2ddd861646b8b1ba83182eb84bb (diff)
downloadxen-27c31d386746bea3daa5b3733c9f986a9c3cccc3.tar.gz
xen-27c31d386746bea3daa5b3733c9f986a9c3cccc3.tar.bz2
xen-27c31d386746bea3daa5b3733c9f986a9c3cccc3.zip
Move cpu hotplug routines into common cpu.c file.
Also simplify the locking (reverting to use if spin_trylock, as returning EBUSY/EAGAIN seems unavoidable after all). In particular this should continue to ensure that stop_machine_run() does not have cpu_online_map change under its feet. Signed-off-by: Keir Fraser <keir.fraser@citrix.com>
Diffstat (limited to 'xen/common/spinlock.c')
-rw-r--r--xen/common/spinlock.c13
1 files changed, 11 insertions, 2 deletions
diff --git a/xen/common/spinlock.c b/xen/common/spinlock.c
index caca8d5c87..b3d4b3ba91 100644
--- a/xen/common/spinlock.c
+++ b/xen/common/spinlock.c
@@ -186,7 +186,7 @@ void _spin_barrier_irq(spinlock_t *lock)
local_irq_restore(flags);
}
-void _spin_lock_recursive(spinlock_t *lock)
+int _spin_trylock_recursive(spinlock_t *lock)
{
int cpu = smp_processor_id();
@@ -197,13 +197,22 @@ void _spin_lock_recursive(spinlock_t *lock)
if ( likely(lock->recurse_cpu != cpu) )
{
- spin_lock(lock);
+ if ( !spin_trylock(lock) )
+ return 0;
lock->recurse_cpu = cpu;
}
/* We support only fairly shallow recursion, else the counter overflows. */
ASSERT(lock->recurse_cnt < 0xfu);
lock->recurse_cnt++;
+
+ return 1;
+}
+
+void _spin_lock_recursive(spinlock_t *lock)
+{
+ while ( !spin_trylock_recursive(lock) )
+ cpu_relax();
}
void _spin_unlock_recursive(spinlock_t *lock)