while ( tickets.tail != observe_head(&lock->tickets) )
{
LOCK_PROFILE_BLOCK;
- cpu_relax();
+ arch_lock_relax();
}
LOCK_PROFILE_GOT;
preempt_disable();
preempt_enable();
LOCK_PROFILE_REL;
add_sized(&lock->tickets.head, 1);
+ arch_lock_signal();
}
void _spin_unlock_irq(spinlock_t *lock)
if ( sample.head != sample.tail )
{
while ( observe_head(&lock->tickets) == sample.head )
- cpu_relax();
+ arch_lock_relax();
#ifdef LOCK_PROFILE
if ( lock->profile )
{
#ifndef __ASM_SPINLOCK_H
#define __ASM_SPINLOCK_H
-/* Nothing ARM specific. */
+#define arch_lock_acquire_barrier() smp_mb()
+#define arch_lock_release_barrier() smp_mb()
+
+#define arch_lock_relax() wfe()
+#define arch_lock_signal() do { \
+ dsb(ishst); \
+ sev(); \
+} while(0)
#endif /* __ASM_SPINLOCK_H */
#define arch_fetch_and_add(x, v) __sync_fetch_and_add(x, v)
-#define arch_lock_acquire_barrier() smp_mb()
-#define arch_lock_release_barrier() smp_mb()
-
extern struct vcpu *__context_switch(struct vcpu *prev, struct vcpu *next);
#endif
#define _raw_read_unlock(l) \
asm volatile ( "lock; dec%z0 %0" : "+m" ((l)->lock) :: "memory" )
+/*
+ * On x86 the only reordering is of reads with older writes. In the
+ * lock case, the read in observe_head() can only be reordered with
+ * writes that precede it, and moving a write _into_ a locked section
+ * is OK. In the release case, the write in add_sized() can only be
+ * reordered with reads that follow it, and hoisting a read _into_ a
+ * locked region is OK.
+ */
+#define arch_lock_acquire_barrier() barrier()
+#define arch_lock_release_barrier() barrier()
+
+#define arch_lock_relax() cpu_relax()
+#define arch_lock_signal()
+
#endif /* __ASM_SPINLOCK_H */
#define set_mb(var, value) do { xchg(&var, value); } while (0)
#define set_wmb(var, value) do { var = value; wmb(); } while (0)
-/*
- * On x86 the only reordering is of reads with older writes. In the
- * lock case, the read in observe_head() can only be reordered with
- * writes that precede it, and moving a write _into_ a locked section
- * is OK. In the release case, the write in add_sized() can only be
- * reordered with reads that follow it, and hoisting a read _into_ a
- * locked region is OK.
- */
-#define arch_lock_acquire_barrier() barrier()
-#define arch_lock_release_barrier() barrier()
-
#define local_irq_disable() asm volatile ( "cli" : : : "memory" )
#define local_irq_enable() asm volatile ( "sti" : : : "memory" )