Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/netbsd-1-5]: src/sys Pullup from trunk:



details:   https://anonhg.NetBSD.org/src/rev/93f016afe9f3
branches:  netbsd-1-5
changeset: 489071:93f016afe9f3
user:      thorpej <thorpej%NetBSD.org@localhost>
date:      Fri Aug 11 23:10:14 2000 +0000

description:
Pullup from trunk:
Add a DIAGNOSTIC or LOCKDEBUG check for held spin locks.

diffstat:

 sys/kern/kern_lock.c  |  27 ++++++++++++++++++++++++++-
 sys/kern/kern_synch.c |   6 +++++-
 sys/sys/lock.h        |   6 +++++-
 3 files changed, 36 insertions(+), 3 deletions(-)

diffs (88 lines):

diff -r 67e02ac636b8 -r 93f016afe9f3 sys/kern/kern_lock.c
--- a/sys/kern/kern_lock.c      Fri Aug 11 23:07:39 2000 +0000
+++ b/sys/kern/kern_lock.c      Fri Aug 11 23:10:14 2000 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: kern_lock.c,v 1.32.2.1 2000/08/11 23:07:39 thorpej Exp $       */
+/*     $NetBSD: kern_lock.c,v 1.32.2.2 2000/08/11 23:10:15 thorpej Exp $       */
 
 /*-
  * Copyright (c) 1999, 2000 The NetBSD Foundation, Inc.
@@ -321,6 +321,31 @@
        return (lock_type);
 }
 
+#if defined(LOCKDEBUG) || defined(DIAGNOSTIC)
+/*
+ * Make sure no spin locks are held by a CPU that is about
+ * to context switch.
+ */
+void
+spinlock_switchcheck(void)
+{
+       u_long cnt;
+       int s;
+
+       s = splhigh();
+#if defined(MULTIPROCESSOR)
+       cnt = curcpu()->ci_spin_locks;
+#else
+       cnt = spin_locks;
+#endif
+       splx(s);
+
+       if (cnt != 0)
+               panic("spinlock_switchcheck: CPU %lu has %lu spin locks",
+                   (u_long) cpu_number(), cnt);
+}
+#endif /* LOCKDEBUG || DIAGNOSTIC */
+
 /*
  * XXX XXX kludge around another kludge..
  *
diff -r 67e02ac636b8 -r 93f016afe9f3 sys/kern/kern_synch.c
--- a/sys/kern/kern_synch.c     Fri Aug 11 23:07:39 2000 +0000
+++ b/sys/kern/kern_synch.c     Fri Aug 11 23:10:14 2000 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: kern_synch.c,v 1.78.2.1 2000/08/11 23:07:39 thorpej Exp $      */
+/*     $NetBSD: kern_synch.c,v 1.78.2.2 2000/08/11 23:10:15 thorpej Exp $      */
 
 /*-
  * Copyright (c) 1999, 2000 The NetBSD Foundation, Inc.
@@ -79,6 +79,7 @@
 
 #include "opt_ddb.h"
 #include "opt_ktrace.h"
+#include "opt_lockdebug.h"
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -765,6 +766,9 @@
 
        spc = &p->p_cpu->ci_schedstate;
 
+#if defined(LOCKDEBUG) || defined(DIAGNOSTIC)
+       spinlock_switchcheck();
+#endif
 #ifdef LOCKDEBUG
        simple_lock_switchcheck();
 #endif
diff -r 67e02ac636b8 -r 93f016afe9f3 sys/sys/lock.h
--- a/sys/sys/lock.h    Fri Aug 11 23:07:39 2000 +0000
+++ b/sys/sys/lock.h    Fri Aug 11 23:10:14 2000 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: lock.h,v 1.31.2.1 2000/08/11 23:07:40 thorpej Exp $    */
+/*     $NetBSD: lock.h,v 1.31.2.2 2000/08/11 23:10:14 thorpej Exp $    */
 
 /*-
  * Copyright (c) 1999, 2000 The NetBSD Foundation, Inc.
@@ -280,6 +280,10 @@
 int    lockstatus __P((struct lock *));
 void   lockmgr_printinfo __P((__volatile struct lock *));
 
+#if defined(LOCKDEBUG) || defined(DIAGNOSTIC)
+void   spinlock_switchcheck __P((void));
+#endif
+
 #define        spinlockinit(lkp, name, flags)                                  \
        lockinit((lkp), 0, (name), 0, (flags) | LK_SPIN)
 



Home | Main Index | Thread Index | Old Index