Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 269551
b: refs/heads/master
c: c576a3e
h: refs/heads/master
i:
  269549: f9c7946
  269547: cbb22be
  269543: c42d758
  269535: d4e78d3
v: v3
  • Loading branch information
Jeremy Fitzhardinge authored and H. Peter Anvin committed Aug 29, 2011
1 parent fb203f0 commit 807e712
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 31 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 84eb950db13ca40a0572ce9957e14723500943d6
refs/heads/master: c576a3ea905c25d50339503e0e5c7fef724e0147
60 changes: 30 additions & 30 deletions trunk/arch/x86/include/asm/spinlock.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,21 +57,21 @@
#if (NR_CPUS < 256)
static __always_inline void __ticket_spin_lock(arch_spinlock_t *lock)
{
unsigned short inc = 1 << TICKET_SHIFT;

asm volatile (
LOCK_PREFIX "xaddw %w0, %1\n"
"1:\t"
"cmpb %h0, %b0\n\t"
"je 2f\n\t"
"rep ; nop\n\t"
"movb %1, %b0\n\t"
/* don't need lfence here, because loads are in-order */
"jmp 1b\n"
"2:"
: "+Q" (inc), "+m" (lock->slock)
:
: "memory", "cc");
register union {
struct __raw_tickets tickets;
unsigned short slock;
} inc = { .slock = 1 << TICKET_SHIFT };

asm volatile (LOCK_PREFIX "xaddw %w0, %1\n"
: "+Q" (inc), "+m" (lock->slock) : : "memory", "cc");

for (;;) {
if (inc.tickets.head == inc.tickets.tail)
break;
cpu_relax();
inc.tickets.head = ACCESS_ONCE(lock->tickets.head);
}
barrier(); /* make sure nothing creeps before the lock is taken */
}

static __always_inline int __ticket_spin_trylock(arch_spinlock_t *lock)
Expand Down Expand Up @@ -104,22 +104,22 @@ static __always_inline void __ticket_spin_unlock(arch_spinlock_t *lock)
static __always_inline void __ticket_spin_lock(arch_spinlock_t *lock)
{
unsigned inc = 1 << TICKET_SHIFT;
unsigned tmp;
__ticket_t tmp;

asm volatile(LOCK_PREFIX "xaddl %0, %1\n"
"movzwl %w0, %2\n\t"
"shrl $16, %0\n\t"
"1:\t"
"cmpl %0, %2\n\t"
"je 2f\n\t"
"rep ; nop\n\t"
"movzwl %1, %2\n\t"
/* don't need lfence here, because loads are in-order */
"jmp 1b\n"
"2:"
: "+r" (inc), "+m" (lock->slock), "=&r" (tmp)
:
: "memory", "cc");
asm volatile(LOCK_PREFIX "xaddl %0, %1\n\t"
: "+r" (inc), "+m" (lock->slock)
: : "memory", "cc");

tmp = inc;
inc >>= TICKET_SHIFT;

for (;;) {
if ((__ticket_t)inc == tmp)
break;
cpu_relax();
tmp = ACCESS_ONCE(lock->tickets.head);
}
barrier(); /* make sure nothing creeps before the lock is taken */
}

static __always_inline int __ticket_spin_trylock(arch_spinlock_t *lock)
Expand Down

0 comments on commit 807e712

Please sign in to comment.