x86/spinlock changes for v3.2
Linus,
Please pull the latest x86-spinlocks-for-linus git tree from:
git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.git x86-spinlocks-for-linus
Thanks,
Ingo
------------------>
Jeremy Fitzhardinge (12):
x86, cmpxchg: <linux/alternative.h> has LOCK_PREFIX
x86, cmpxchg: Move 32-bit __cmpxchg_wrong_size to match 64 bit. x86, cmpxchg: Move 64-bit set64_bit() to match 32-bit
x86, cmpxchg: Unify cmpxchg into cmpxchg.h
x86: Add xadd helper macro
x86: Use xadd helper more widely
x86, ticketlock: Clean up types and accessors
x86, ticketlock: Convert spin loop to C
x86, ticketlock: Convert __ticket_spin_lock to use xadd() x86, ticketlock: Make __ticket_spin_trylock common
x86, cmpxchg: Use __compiletime_error() to make usage messages a bit nicer x86, ticketlock: remove obsolete comment
arch/x86/include/asm/atomic.h | 8 +- arch/x86/include/asm/atomic64_64.h | 6 +- arch/x86/include/asm/cmpxchg.h | 205 +++++++++++++++++++++++++++++++++ arch/x86/include/asm/cmpxchg_32.h | 114 ------------------ arch/x86/include/asm/cmpxchg_64.h | 131 --------------------- arch/x86/include/asm/rwsem.h | 8 +- arch/x86/include/asm/spinlock.h | 114 +++++-------------- arch/x86/include/asm/spinlock_types.h | 22 +++- arch/x86/include/asm/uv/uv_bau.h | 6 +- 9 files changed, 257 insertions(+), 357 deletions(-)
arch/x86/include/asm/atomic.h +2 -6
@@ -172,18 +172,14 @@ static inline int atomic_add_negative(int i, atomic_t *v)*/ static inline int atomic_add_return (int i,atomic_t *v) { -int __i;#ifdef CONFIG_M386 +int __i;unsigned long flags;if (unlikely (boot_cpu_data.x86 <=3 )) goto no_xadd;#endif /* Modern 486+ processor */ - __i = i; - asmvolatile (LOCK_PREFIX "xaddl %0, %1" - :"+r" (i),"+m" (v->counter) - : :"memory" ); -return i + __i; +return i +xadd (&v->counter, i);#ifdef CONFIG_M386 no_xadd:/* Legacy 386 processor */
arch/x86/include/asm/atomic64_64.h +1 -5
@@ -170,11 +170,7 @@ static inline int atomic64_add_negative(long i, atomic64_t *v)*/ static inline long atomic64_add_return (long i,atomic64_t *v) { -long __i = i; - asmvolatile (LOCK_PREFIX "xaddq %0, %1;" - :"+r" (i),"+m" (v->counter) - : :"memory" ); -return i + __i; +return i +xadd (&v->counter, i); }static inline long atomic64_sub_return (long i,atomic64_t *v)
arch/x86/include/asm/cmpxchg.h +205 -0
210 lines not on this page · raw message
arch/x86/include/asm/cmpxchg_32.h +0 -114
133 lines not on this page · raw message
arch/x86/include/asm/cmpxchg_64.h +0 -131
144 lines not on this page · raw message
arch/x86/include/asm/rwsem.h +1 -7
@@ -204,13 +204,7 @@ static inline void rwsem_atomic_add(long delta, struct rw_semaphore *sem)*/ static inline long rwsem_atomic_update (long delta,struct rw_semaphore *sem) { -long tmp = delta; - - asmvolatile (LOCK_PREFIX "xadd %0,%1" - :"+r" (tmp),"+m" (sem->count) - : :"memory" ); - -return tmp + delta; +return delta +xadd (&sem->count, delta); }#endif /* __KERNEL__ */
arch/x86/include/asm/spinlock.h +27 -87
152 lines not on this page · raw message
arch/x86/include/asm/spinlock_types.h +20 -2
@@ -5,11 +5,29 @@# 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 } }#include <asm/rwlock.h>
arch/x86/include/asm/uv/uv_bau.h +1 -5
@@ -656,11 +656,7 @@ static inline int atomic_read_short(const struct atomic_short *v)*/ static inline int atom_asr (short i,struct atomic_short *v) { -short __i = i; - asmvolatile (LOCK_PREFIX "xaddw %0, %1" - :"+r" (i),"+m" (v->counter) - : :"memory" ); -return i + __i; +return i +xadd (&v->counter, i); }/*