]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
Merge branch 'upstream/ticketlock-cleanup' into upstream/xen
authorJeremy Fitzhardinge <jeremy.fitzhardinge@citrix.com>
Fri, 26 Aug 2011 21:20:35 +0000 (14:20 -0700)
committerJeremy Fitzhardinge <jeremy.fitzhardinge@citrix.com>
Fri, 26 Aug 2011 21:20:35 +0000 (14:20 -0700)
* upstream/ticketlock-cleanup:
  x86/ticketlock: make __ticket_spin_trylock common
  x86/ticketlock: convert __ticket_spin_lock to use xadd()
  x86/ticketlock: convert spin loop to C
  x86/ticketlock: clean up types and accessors
  x86: use xadd helper more widely
  x86: add xadd helper macro
  x86/cmpxchg: unify cmpxchg into cmpxchg.h
  x86/cmpxchg: move 64-bit set64_bit() to match 32-bit
  x86/cmpxchg: move 32-bit __cmpxchg_wrong_size to match 64 bit.
  x86/cmpxchg: linux/alternative.h has LOCK_PREFIX

1  2 
arch/x86/include/asm/atomic.h
arch/x86/include/asm/atomic64_64.h
arch/x86/include/asm/cmpxchg_32.h
arch/x86/include/asm/cmpxchg_64.h
arch/x86/include/asm/spinlock.h
arch/x86/include/asm/spinlock_types.h
arch/x86/include/asm/uv/uv_bau.h

Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
index 7c7a486fcb6811e68dc140085061e15df8bbd569,72e154eb939d604a0715cdff079d7d88af126843..8ebd5df7451e28b88a8a155bf3ff7dcb081ddb35
@@@ -5,12 -5,34 +5,30 @@@
  # error "please don't include this file directly"
  #endif
  
+ #include <linux/types.h>
+ #if (CONFIG_NR_CPUS < 256)
+ typedef u8  __ticket_t;
+ typedef u16 __ticketpair_t;
+ #else
+ typedef u16 __ticket_t;
+ typedef u32 __ticketpair_t;
+ #endif
+ #define TICKET_SHIFT  (sizeof(__ticket_t) * 8)
+ #define TICKET_MASK   ((__ticket_t)((1 << TICKET_SHIFT) - 1))
  typedef struct arch_spinlock {
-       unsigned int slock;
+       union {
+               __ticketpair_t head_tail;
+               struct __raw_tickets {
+                       __ticket_t head, tail;
+               } tickets;
+       };
  } arch_spinlock_t;
  
- #define __ARCH_SPIN_LOCK_UNLOCKED     { 0 }
+ #define __ARCH_SPIN_LOCK_UNLOCKED     { { 0 } }
  
 -typedef struct {
 -      unsigned int lock;
 -} arch_rwlock_t;
 -
 -#define __ARCH_RW_LOCK_UNLOCKED               { RW_LOCK_BIAS }
 +#include <asm/rwlock.h>
  
  #endif /* _ASM_X86_SPINLOCK_TYPES_H */
index 37d369859c8e54da912475ef3b9fd54132ee0212,ebc9344da98aa97b8a095b1e7a4f0e7ea402b7af..c568ccca6e0ef4c0ec549ce6ba7283a0f03b68c4
@@@ -654,35 -485,9 +654,31 @@@ static inline int atomic_read_short(con
   *
   * Atomically adds @i to @v and returns @i + @v
   */
 -static inline int atomic_add_short_return(short i, struct atomic_short *v)
 +static inline int atom_asr(short i, struct atomic_short *v)
  {
-       short __i = i;
-       asm volatile(LOCK_PREFIX "xaddw %0, %1"
-                       : "+r" (i), "+m" (v->counter)
-                       : : "memory");
-       return i + __i;
+       return i + xadd(&v->counter, i);
  }
  
 +/*
 + * conditionally add 1 to *v, unless *v is >= u
 + * return 0 if we cannot add 1 to *v because it is >= u
 + * return 1 if we can add 1 to *v because it is < u
 + * the add is atomic
 + *
 + * This is close to atomic_add_unless(), but this allows the 'u' value
 + * to be lowered below the current 'v'.  atomic_add_unless can only stop
 + * on equal.
 + */
 +static inline int atomic_inc_unless_ge(spinlock_t *lock, atomic_t *v, int u)
 +{
 +      spin_lock(lock);
 +      if (atomic_read(v) >= u) {
 +              spin_unlock(lock);
 +              return 0;
 +      }
 +      atomic_inc(v);
 +      spin_unlock(lock);
 +      return 1;
 +}
 +
  #endif /* _ASM_X86_UV_UV_BAU_H */