Subject: Re: how to avoid re-ordering?
To: YAMAMOTO Takashi <yamt@mwd.biglobe.ne.jp>
From: Luke Mewburn <lukem@wasabisystems.com>
List: tech-kern
Date: 12/05/2001 15:01:55
On Wed, Dec 05, 2001 at 12:03:37PM +0900, YAMAMOTO Takashi wrote:
> hi.
> 
> I noticed that spl*/splx are inlined and re-orderd
> with "-O3 -march=pentium", and it produce bad codes as a result.
> I actually experienced panics due to this.
> 
> attached patch solve this. although it's very ugly.
> is it acceptable?
> 
> I post to tech-kern instead of port-i386
> since the problem itsself isn't port-specific.

wouldn't it be better to mark the ocpl and ncpl arguments as
`volatile' instead? does that solve the problem?

luke.



> Index: intr.h
> ===================================================================
> RCS file: /cvs/cvsroot/syssrc/sys/arch/i386/include/intr.h,v
> retrieving revision 1.22
> diff -u -p -r1.22 intr.h
> --- intr.h	2001/07/16 16:53:00	1.22
> +++ intr.h	2001/12/05 02:53:15
> @@ -1,4 +1,4 @@
> -/*	$NetBSD: intr.h,v 1.22 2001/07/16 16:53:00 thorpej Exp $	*/
> +/*	$NetBSD: intr.h,v 1.21 2001/05/21 04:47:35 perry Exp $	*/
>  
>  /*-
>   * Copyright (c) 1998, 2001 The NetBSD Foundation, Inc.
> @@ -89,6 +89,7 @@ splraise(ncpl)
>  	register int ocpl = cpl;
>  
>  	cpl = ocpl | ncpl;
> +	__asm __volatile ("");
>  	return (ocpl);
>  }
>  
> @@ -101,6 +102,7 @@ spllower(ncpl)
>  	register int ncpl;
>  {
>  
> +	__asm __volatile ("");
>  	cpl = ncpl;
>  	if (ipending & ~ncpl)
>  		Xspllower();


-- 
Luke Mewburn  <lukem@wasabisystems.com>  http://www.wasabisystems.com
Luke Mewburn     <lukem@netbsd.org>      http://www.netbsd.org
Wasabi Systems - NetBSD hackers for hire
NetBSD - the world's most portable UNIX-like operating system