ia64/xen-unstable

changeset 7619:5ffe3f16aa52

Make SMP alternatives work under xenolinux rather than just native,
since part of it seems to have gotten lost.

Signed-off-by: Steven Smith, sos22@cam.ac.uk
author sos22@douglas.cl.cam.ac.uk
date Tue Nov 01 13:38:20 2005 +0100 (2005-11-01)
parents ea6d9f29dff5
children 9cdfcecf4968
files linux-2.6-xen-sparse/include/asm-xen/asm-i386/spinlock.h
line diff
     1.1 --- a/linux-2.6-xen-sparse/include/asm-xen/asm-i386/spinlock.h	Mon Oct 31 17:07:14 2005 +0100
     1.2 +++ b/linux-2.6-xen-sparse/include/asm-xen/asm-i386/spinlock.h	Tue Nov 01 13:38:20 2005 +0100
     1.3 @@ -6,6 +6,7 @@
     1.4  #include <asm/page.h>
     1.5  #include <linux/config.h>
     1.6  #include <linux/compiler.h>
     1.7 +#include <asm/smp_alt.h>
     1.8  
     1.9  asmlinkage int printk(const char * fmt, ...)
    1.10  	__attribute__ ((format (printf, 1, 2)));
    1.11 @@ -47,8 +48,9 @@ typedef struct {
    1.12  #define spin_unlock_wait(x)	do { barrier(); } while(spin_is_locked(x))
    1.13  
    1.14  #define spin_lock_string \
    1.15 -	"\n1:\t" \
    1.16 -	"lock ; decb %0\n\t" \
    1.17 +        "1:\n" \
    1.18 +	LOCK \
    1.19 +	"decb %0\n\t" \
    1.20  	"jns 3f\n" \
    1.21  	"2:\t" \
    1.22  	"rep;nop\n\t" \
    1.23 @@ -58,8 +60,9 @@ typedef struct {
    1.24  	"3:\n\t"
    1.25  
    1.26  #define spin_lock_string_flags \
    1.27 -	"\n1:\t" \
    1.28 -	"lock ; decb %0\n\t" \
    1.29 +        "1:\n" \
    1.30 +	LOCK \
    1.31 +	"decb %0\n\t" \
    1.32  	"jns 4f\n\t" \
    1.33  	"2:\t" \
    1.34  	"testl $0x200, %1\n\t" \
    1.35 @@ -121,10 +124,34 @@ static inline void _raw_spin_unlock(spin
    1.36  static inline int _raw_spin_trylock(spinlock_t *lock)
    1.37  {
    1.38  	char oldval;
    1.39 +#ifdef CONFIG_SMP_ALTERNATIVES
    1.40  	__asm__ __volatile__(
    1.41 -		"xchgb %b0,%1"
    1.42 +		"1:movb %1,%b0\n"
    1.43 +		"movb $0,%1\n"
    1.44 +		"2:"
    1.45 +		".section __smp_alternatives,\"a\"\n"
    1.46 +		".long 1b\n"
    1.47 +		".long 3f\n"
    1.48 +		".previous\n"
    1.49 +		".section __smp_replacements,\"a\"\n"
    1.50 +		"3: .byte 2b - 1b\n"
    1.51 +		".byte 5f-4f\n"
    1.52 +		".byte 0\n"
    1.53 +		".byte 6f-5f\n"
    1.54 +		".byte -1\n"
    1.55 +		"4: xchgb %b0,%1\n"
    1.56 +		"5: movb %1,%b0\n"
    1.57 +		"movb $0,%1\n"
    1.58 +		"6:\n"
    1.59 +		".previous\n"
    1.60  		:"=q" (oldval), "=m" (lock->slock)
    1.61  		:"0" (0) : "memory");
    1.62 +#else
    1.63 +	__asm__ __volatile__(
    1.64 +		"xchgb %b0,%1\n"
    1.65 +		:"=q" (oldval), "=m" (lock->slock)
    1.66 +		:"0" (0) : "memory");
    1.67 +#endif
    1.68  	return oldval > 0;
    1.69  }
    1.70  
    1.71 @@ -225,8 +252,8 @@ static inline void _raw_write_lock(rwloc
    1.72  	__build_write_lock(rw, "__write_lock_failed");
    1.73  }
    1.74  
    1.75 -#define _raw_read_unlock(rw)		asm volatile("lock ; incl %0" :"=m" ((rw)->lock) : : "memory")
    1.76 -#define _raw_write_unlock(rw)	asm volatile("lock ; addl $" RW_LOCK_BIAS_STR ",%0":"=m" ((rw)->lock) : : "memory")
    1.77 +#define _raw_read_unlock(rw)	asm volatile(LOCK "incl %0" :"=m" ((rw)->lock) : : "memory")
    1.78 +#define _raw_write_unlock(rw)	asm volatile(LOCK "addl $" RW_LOCK_BIAS_STR ",%0":"=m" ((rw)->lock) : : "memory")
    1.79  
    1.80  static inline int _raw_read_trylock(rwlock_t *lock)
    1.81  {