public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
* gcc/asm gurus: This linux kernel spinlock code breaks on 3.0.1
@ 2001-10-14 17:54 Richard Shih-Ping Chan
  2001-10-15  9:37 ` Hartmut Schirmer
  2001-10-16 23:32 ` rth
  0 siblings, 2 replies; 3+ messages in thread
From: Richard Shih-Ping Chan @ 2001-10-14 17:54 UTC (permalink / raw)
  To: gcc

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

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: gcc/asm gurus: This linux kernel spinlock code breaks on 3.0.1
  2001-10-14 17:54 gcc/asm gurus: This linux kernel spinlock code breaks on 3.0.1 Richard Shih-Ping Chan
@ 2001-10-15  9:37 ` Hartmut Schirmer
  2001-10-16 23:32 ` rth
  1 sibling, 0 replies; 3+ messages in thread
From: Hartmut Schirmer @ 2001-10-15  9:37 UTC (permalink / raw)
  To: Richard Shih-Ping Chan; +Cc: gcc

On Mon, 15 Oct 2001, Richard Shih-Ping Chan wrote:
[..]
>#define spin_unlock_string \
>	"xchgb %b0, %1" \
>		:"=q" (oldval), "=m" (lock->lock) \
>		:"0" (1) : "memory"

		:"0" (oldval) : "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
	oldval = 1;
>	__asm__ __volatile__(
>		spin_unlock_string
>	);
>}

may make it work.

Hartmut

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: gcc/asm gurus: This linux kernel spinlock code breaks on 3.0.1
  2001-10-14 17:54 gcc/asm gurus: This linux kernel spinlock code breaks on 3.0.1 Richard Shih-Ping Chan
  2001-10-15  9:37 ` Hartmut Schirmer
@ 2001-10-16 23:32 ` rth
  1 sibling, 0 replies; 3+ messages in thread
From: rth @ 2001-10-16 23:32 UTC (permalink / raw)
  To: Richard Shih-Ping Chan; +Cc: gcc

On Mon, Oct 15, 2001 at 08:56:48AM +0800, Richard Shih-Ping Chan wrote:
> Can anyone see anything fishy here?

I don't see anything fishy.  This example doesn't fail.  You'll
have to isolate the actual kernel failure and send code from that.


r~

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2001-10-16 23:32 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-10-14 17:54 gcc/asm gurus: This linux kernel spinlock code breaks on 3.0.1 Richard Shih-Ping Chan
2001-10-15  9:37 ` Hartmut Schirmer
2001-10-16 23:32 ` rth

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).