It doesn't make sense to charge simple locks to proc's, because

simple locks are held by CPUs.  Remove p_simple_locks (which was
unused anyway, really), and add a LOCKDEBUG check for held simple
locks in mi_switch().  Grow p_locks to an int to take up the space
previously used by p_simple_locks so that the proc structure doens't
change size.
This commit is contained in:
thorpej 2000-08-07 21:55:22 +00:00
parent 0b7e5ad5a0
commit b24441d4d1
4 changed files with 32 additions and 14 deletions

View File

@ -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 */ /* } */

View File

@ -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.

View File

@ -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)

View File

@ -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 */