diff --git a/sys/kern/kern_lock.c b/sys/kern/kern_lock.c index 690cbec3fbf6..68944bf9fa07 100644 --- a/sys/kern/kern_lock.c +++ b/sys/kern/kern_lock.c @@ -1,4 +1,4 @@ -/* $NetBSD: kern_lock.c,v 1.33 2000/07/14 07:16:44 thorpej Exp $ */ +/* $NetBSD: kern_lock.c,v 1.34 2000/08/07 21:55:23 thorpej Exp $ */ /*- * Copyright (c) 1999, 2000 The NetBSD Foundation, Inc. @@ -934,4 +934,27 @@ simple_lock_freecheck(void *start, void *end) SLOCK_LIST_UNLOCK(); splx(s); } + +void +simple_lock_switchcheck(void) +{ + struct simplelock *alp; + cpuid_t cpu_id = cpu_number(); + int s; + + s = splhigh(); + SLOCK_LIST_LOCK(); + for (alp = TAILQ_FIRST(&simplelock_list); alp != NULL; + alp = TAILQ_NEXT(alp, list)) { + if (alp->lock_holder == cpu_id) { + lock_printf("switching with held simple_lock %p " + "CPU %lu %s:%s\n", + alp, alp->lock_holder, alp->lock_file, + alp->lock_line); + SLOCK_DEBUGGER(); + } + } + SLOCK_LIST_UNLOCK(); + splx(s); +} #endif /* LOCKDEBUG */ /* } */ diff --git a/sys/kern/kern_synch.c b/sys/kern/kern_synch.c index dc914873087e..4a07612812ab 100644 --- a/sys/kern/kern_synch.c +++ b/sys/kern/kern_synch.c @@ -1,4 +1,4 @@ -/* $NetBSD: kern_synch.c,v 1.80 2000/08/02 20:21:36 nathanw Exp $ */ +/* $NetBSD: kern_synch.c,v 1.81 2000/08/07 21:55:23 thorpej Exp $ */ /*- * Copyright (c) 1999, 2000 The NetBSD Foundation, Inc. @@ -764,15 +764,10 @@ mi_switch(struct proc *p) spc = &p->p_cpu->ci_schedstate; -#ifdef DEBUG - if (p->p_simple_locks) { - printf("p->p_simple_locks %d\n", p->p_simple_locks); #ifdef LOCKDEBUG - simple_lock_dump(); -#endif - panic("sleep: holding simple lock"); - } + simple_lock_switchcheck(); #endif + /* * Compute the amount of time during which the current * process was running, and add that to its total so far. diff --git a/sys/sys/lock.h b/sys/sys/lock.h index 1547037f1316..2ab7b3945a00 100644 --- a/sys/sys/lock.h +++ b/sys/sys/lock.h @@ -1,7 +1,7 @@ -/* $NetBSD: lock.h,v 1.32 2000/07/14 07:16:45 thorpej Exp $ */ +/* $NetBSD: lock.h,v 1.33 2000/08/07 21:55:22 thorpej Exp $ */ /*- - * Copyright (c) 1999 The NetBSD Foundation, Inc. + * Copyright (c) 1999, 2000 The NetBSD Foundation, Inc. * All rights reserved. * * This code is derived from software contributed to The NetBSD Foundation @@ -297,6 +297,7 @@ void _simple_unlock(__volatile struct simplelock *, const char *, int); void simple_lock_init(struct simplelock *); void simple_lock_dump(void); void simple_lock_freecheck(void *, void *); +void simple_lock_switchcheck(void); #elif defined(MULTIPROCESSOR) #define simple_lock_init(alp) __cpu_simple_lock_init(&(alp)->lock_data) #define simple_lock(alp) __cpu_simple_lock(&(alp)->lock_data) diff --git a/sys/sys/proc.h b/sys/sys/proc.h index db016097e7a6..5c4c9c1e650c 100644 --- a/sys/sys/proc.h +++ b/sys/sys/proc.h @@ -1,4 +1,4 @@ -/* $NetBSD: proc.h,v 1.98 2000/06/08 05:50:40 thorpej Exp $ */ +/* $NetBSD: proc.h,v 1.99 2000/08/07 21:55:22 thorpej Exp $ */ /*- * Copyright (c) 1986, 1989, 1991, 1993 @@ -179,8 +179,7 @@ struct proc { struct vnode *p_textvp; /* Vnode of executable. */ - short p_locks; /* DEBUG: lockmgr count of held locks */ - short p_simple_locks; /* DEBUG: count of held simple locks */ + int p_locks; /* DEBUG: lockmgr count of held locks */ int p_holdcnt; /* If non-zero, don't swap. */ struct emul *p_emul; /* Emulation information */