lockuninit()
Aggelos Economopoulos
aoiko at cc.ece.ntua.gr
Sun Aug 19 11:06:59 PDT 2007
It appears we don't have an uninit function for lockmgr locks. This means we
don't ever uninit the embedded spinlock (which does have a dummy
spin_uninit()) and this defeats the idea of providing spin_uninit(). There is
no purpose in having a dummy function that isn't used consistently; anybody
who wants to add debugging/verification code will be forced to go through
the source to add the missing calls or, worse yet, not even notice they are
missing.
I'm attaching a trivial (completely untested) lockuninit() implementation.
There are (grep tells me) 17 non-static uses of struct lock to check, so this
is only a first step, but I can't go through the tree changing things right
now.
Aggelos
Index: kern/kern_lock.c
===================================================================
RCS file: /home/aggelos/imports/vcs/dcvs/src/sys/kern/kern_lock.c,v
retrieving revision 1.25
diff -u -u -r1.25 kern_lock.c
--- kern/kern_lock.c 23 Dec 2006 00:35:04 -0000 1.25
+++ kern/kern_lock.c 19 Aug 2007 17:54:28 -0000
@@ -39,7 +39,7 @@
*
* @(#)kern_lock.c 8.18 (Berkeley) 5/21/95
* $FreeBSD: src/sys/kern/kern_lock.c,v 1.31.2.3 2001/12/25 01:44:44 dillon Exp $
- * $DragonFly: src/sys/kern/kern_lock.c,v 1.25 2006-12-23 00:35:04 swildner Exp $
+ * $DragonFly: src/sys/kern/kern_lock.c,v 1.25 2006/12/23 00:35:04 swildner Exp $
*/
#include "opt_lint.h"
@@ -518,6 +518,15 @@
spin_unlock_wr(&lkp->lk_spinlock);
}
+void
+lockuninit(struct lock *l)
+{
+ spin_lock_wr(&l->lk_spinlock);
+ KKASSERT(l->lk_waitcount == 0);
+ l->lk_wmesg = "BUG";
+ spin_uninit(&l->lk_spinlock);
+}
+
/*
* Determine the status of a lock.
*/
Index: sys/lock.h
===================================================================
RCS file: /home/aggelos/imports/vcs/dcvs/src/sys/sys/lock.h,v
retrieving revision 1.18
diff -u -u -r1.18 lock.h
--- sys/lock.h 11 Aug 2006 01:55:00 -0000 1.18
+++ sys/lock.h 19 Aug 2007 17:55:43 -0000
@@ -36,7 +36,7 @@
*
* @(#)lock.h 8.12 (Berkeley) 5/19/95
* $FreeBSD: src/sys/sys/lock.h,v 1.17.2.3 2001/12/25 01:44:44 dillon Exp $
- * $DragonFly: src/sys/sys/lock.h,v 1.18 2006-08-11 01:55:00 dillon Exp $
+ * $DragonFly: src/sys/sys/lock.h,v 1.18 2006/08/11 01:55:00 dillon Exp $
*/
#ifndef _SYS_LOCK_H_
@@ -190,6 +190,7 @@
void lockinit (struct lock *, char *wmesg, int timo, int flags);
void lockreinit (struct lock *, char *wmesg, int timo, int flags);
+void lockuninit(struct lock *);
#ifdef DEBUG_LOCKS
int debuglockmgr (struct lock *, u_int flags,
const char *,
More information about the Submit
mailing list