Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 113305
b: refs/heads/master
c: 08f5fcb
h: refs/heads/master
i:
  113303: 2bb6501
v: v3
  • Loading branch information
Jan Beulich authored and Ingo Molnar committed Sep 5, 2008
1 parent d1934ef commit b2a9b86
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 27 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: ef1f3413284b9270266cb04a944647e59735f0f1
refs/heads/master: 08f5fcbe6e0ea029c7e9b1b1c338700ab7809daf
42 changes: 16 additions & 26 deletions trunk/include/asm-x86/spinlock.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,19 +54,7 @@
* much between them in performance though, especially as locks are out of line.
*/
#if (NR_CPUS < 256)
static inline int __ticket_spin_is_locked(raw_spinlock_t *lock)
{
int tmp = ACCESS_ONCE(lock->slock);

return (((tmp >> 8) & 0xff) != (tmp & 0xff));
}

static inline int __ticket_spin_is_contended(raw_spinlock_t *lock)
{
int tmp = ACCESS_ONCE(lock->slock);

return (((tmp >> 8) - tmp) & 0xff) > 1;
}
#define TICKET_SHIFT 8

static __always_inline void __ticket_spin_lock(raw_spinlock_t *lock)
{
Expand Down Expand Up @@ -116,19 +104,7 @@ static __always_inline void __ticket_spin_unlock(raw_spinlock_t *lock)
: "memory", "cc");
}
#else
static inline int __ticket_spin_is_locked(raw_spinlock_t *lock)
{
int tmp = ACCESS_ONCE(lock->slock);

return (((tmp >> 16) & 0xffff) != (tmp & 0xffff));
}

static inline int __ticket_spin_is_contended(raw_spinlock_t *lock)
{
int tmp = ACCESS_ONCE(lock->slock);

return (((tmp >> 16) - tmp) & 0xffff) > 1;
}
#define TICKET_SHIFT 16

static __always_inline void __ticket_spin_lock(raw_spinlock_t *lock)
{
Expand Down Expand Up @@ -182,6 +158,20 @@ static __always_inline void __ticket_spin_unlock(raw_spinlock_t *lock)
}
#endif

static inline int __ticket_spin_is_locked(raw_spinlock_t *lock)
{
int tmp = ACCESS_ONCE(lock->slock);

return !!(((tmp >> TICKET_SHIFT) ^ tmp) & ((1 << TICKET_SHIFT) - 1));
}

static inline int __ticket_spin_is_contended(raw_spinlock_t *lock)
{
int tmp = ACCESS_ONCE(lock->slock);

return (((tmp >> TICKET_SHIFT) - tmp) & ((1 << TICKET_SHIFT) - 1)) > 1;
}

#define __raw_spin_lock_flags(lock, flags) __raw_spin_lock(lock)

#ifdef CONFIG_PARAVIRT
Expand Down

0 comments on commit b2a9b86

Please sign in to comment.