Subject: Re: how to avoid re-ordering?
To: None <tech-kern@netbsd.org>
From: YAMAMOTO Takashi <yamt@mwd.biglobe.ne.jp>
List: tech-kern
Date: 12/17/2001 03:42:54
----Next_Part(Mon_Dec_17_03:42:54_2001_455)--
Content-Type: Text/Plain; charset=us-ascii
Content-Transfer-Encoding: 7bit

From: YAMAMOTO Takashi <yamt@mwd.biglobe.ne.jp>
> 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.

I'll commit attached patch some days later if no objection.
thanks.

---
YAMAMOTO Takashi<yamt@mwd.biglobe.ne.jp>


----Next_Part(Mon_Dec_17_03:42:54_2001_455)--
Content-Type: Text/Plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
Content-Disposition: inline; filename="intr.h.reorderbarrier.diff"

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/07 07:58:40
@@ -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.
@@ -70,6 +70,9 @@
 
 #ifndef _LOCORE
 
+/* hack to prevent the compiler re-ordering */
+#define REORDER_BARRIER __asm __volatile ("")
+
 volatile int cpl, ipending, astpending;
 int imask[NIPL];
 
@@ -89,6 +92,7 @@ splraise(ncpl)
 	register int ocpl = cpl;
 
 	cpl = ocpl | ncpl;
+	REORDER_BARRIER;
 	return (ocpl);
 }
 
@@ -101,6 +105,7 @@ spllower(ncpl)
 	register int ncpl;
 {
 
+	REORDER_BARRIER;
 	cpl = ncpl;
 	if (ipending & ~ncpl)
 		Xspllower();

----Next_Part(Mon_Dec_17_03:42:54_2001_455)----