This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

gcc/asm gurus: This linux kernel spinlock code breaks on 3.0.1



Hello GCC/asm gurus: the following asm code for x86, introduced into a recent Linux
kernel (-ac series) breaks when compiled using 3.0.1. The resulting kernel
hangs on boot and the reason has been isolated to the code change.
Working kernels were compiled using RedHat's 2.96.

Can anyone see anything fishy here? Alan's comments were
*       This tree doesn't compile for SMP with gcc 3.*. The problem
*       appears to be the P6 safe spin_unlock code. Right now I don't
*       see why so if you wnt to build with 3.* you have to figure that
*       out too 8)

===Working code here======================================

#define spin_unlock_string \
	"movb $1,%0" \
		:"=m" (lock->lock) : : "memory"


static inline void spin_unlock(spinlock_t *lock)
{
#if SPINLOCK_DEBUG
	if (lock->magic != SPINLOCK_MAGIC)
		BUG();
	if (!spin_is_locked(lock))
		BUG();
#endif
	__asm__ __volatile__(
		spin_unlock_string
	);
}

===New asm code - changed to work around a PPRO errata by Alan Cox==

#define spin_unlock_string \
	"xchgb %b0, %1" \
		:"=q" (oldval), "=m" (lock->lock) \
		:"0" (1) : "memory"

static inline void spin_unlock(spinlock_t *lock)
{
	char oldval;
#if SPINLOCK_DEBUG
	if (lock->magic != SPINLOCK_MAGIC)
		BUG();
	if (!spin_is_locked(lock))
		BUG();
#endif
	__asm__ __volatile__(
		spin_unlock_string
	);
}




-- 
Richard Chan <cshihpin@dso.org.sg>
DSO National Laboratories
20 Science Park Drive
Singapore 118230
Tel: 7727045
Fax: 7766476


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]