Subject: Re: WARNING: SPL NOT LOWERED ON SYSCALL 0 0 EXIT
To: None <tech-kern@netbsd.org>
From: Joerg Sonnenberger <joerg@britannica.bec.de>
List: tech-kern
Date: 08/13/2007 18:34:02
--6TrnltStXW4iwmi0
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
On Sun, Aug 12, 2007 at 10:57:24PM -0400, Thor Lancelot Simon wrote:
> The kernel is -current as of today, cross-compiled on macppc for various
> obscure reasons. Any ideas what causes this? I am a bit curious about
> Opteron erratum 106:
>
> http://lists.freebsd.org/pipermail/freebsd-amd64/2005-May/004693.html
Can you try the attached patch? I think it makes condition (3)
impossible and shouldn't hurt for the common case.
Joerg
--6TrnltStXW4iwmi0
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename="lock.h.diff"
Index: lock.h
===================================================================
RCS file: /home/joerg/repo/netbsd/src/sys/arch/x86/include/lock.h,v
retrieving revision 1.14
diff -u -r1.14 lock.h
--- lock.h 10 Feb 2007 16:19:39 -0000 1.14
+++ lock.h 13 Aug 2007 09:08:41 -0000
@@ -49,6 +49,30 @@
#include <machine/cpufunc.h>
+#ifdef _KERNEL
+void mb_read(void);
+void mb_write(void);
+void mb_memory(void);
+#else /* _KERNEL */
+static __inline void
+mb_read(void)
+{
+ x86_lfence();
+}
+
+static __inline void
+mb_write(void)
+{
+ __insn_barrier();
+}
+
+static __inline void
+mb_memory(void)
+{
+ x86_mfence();
+}
+#endif /* _KERNEL */
+
#ifdef LOCKDEBUG
extern void __cpu_simple_lock_init(__cpu_simple_lock_t *);
@@ -80,11 +104,16 @@
static __inline void
__cpu_simple_lock(__cpu_simple_lock_t *lockp)
{
+ int count = 100;
while (x86_atomic_testset_b(lockp, __SIMPLELOCK_LOCKED)
!= __SIMPLELOCK_UNLOCKED) {
do {
x86_pause();
+ if (--count) {
+ mb_memory();
+ count = 100;
+ }
} while (*lockp == __SIMPLELOCK_LOCKED);
}
__insn_barrier();
@@ -166,28 +195,4 @@
#define SPINLOCK_SPIN_HOOK /* nothing */
#define SPINLOCK_BACKOFF_HOOK x86_pause()
-#ifdef _KERNEL
-void mb_read(void);
-void mb_write(void);
-void mb_memory(void);
-#else /* _KERNEL */
-static __inline void
-mb_read(void)
-{
- x86_lfence();
-}
-
-static __inline void
-mb_write(void)
-{
- __insn_barrier();
-}
-
-static __inline void
-mb_memory(void)
-{
- x86_mfence();
-}
-#endif /* _KERNEL */
-
#endif /* _X86_LOCK_H_ */
--6TrnltStXW4iwmi0--