summaryrefslogtreecommitdiffstats
path: root/sys/kern/kern_lock.c
diff options
context:
space:
mode:
authorattilio <attilio@FreeBSD.org>2007-12-27 22:56:57 +0000
committerattilio <attilio@FreeBSD.org>2007-12-27 22:56:57 +0000
commitbd42361fd1ee5c24ad94b47a250371d0944e6311 (patch)
tree864827637835381b82a08d4fb02140a628f2f208 /sys/kern/kern_lock.c
parent010adfaab6719b6321767381d578b9b8e6dfaf1f (diff)
downloadFreeBSD-src-bd42361fd1ee5c24ad94b47a250371d0944e6311.zip
FreeBSD-src-bd42361fd1ee5c24ad94b47a250371d0944e6311.tar.gz
In order to avoid a huge class of deadlocks (in particular in interactions
with the interlock), owner of the lock should be only curthread or at least, for its limited usage, NULL which identifies LK_KERNPROC. The thread "extra argument" for the lockmgr interface is going to be removed in the near future, but for the moment, just let kernel run for some days with this check on in order to find potential deadlocking places around the kernel and fix them.
Diffstat (limited to 'sys/kern/kern_lock.c')
-rw-r--r--sys/kern/kern_lock.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/sys/kern/kern_lock.c b/sys/kern/kern_lock.c
index 3e1d78f..d4413de 100644
--- a/sys/kern/kern_lock.c
+++ b/sys/kern/kern_lock.c
@@ -198,7 +198,15 @@ _lockmgr(struct lock *lkp, u_int flags, struct mtx *interlkp,
int extflags, lockflags;
int contested = 0;
uint64_t waitstart = 0;
-
+
+ /*
+ * Lock owner can only be curthread or, at least, NULL in order to
+ * have a deadlock free implementation of the primitive.
+ */
+ KASSERT(td == NULL || td == curthread,
+ ("lockmgr: owner thread (%p) cannot differ from curthread or NULL",
+ td));
+
error = 0;
if (td == NULL)
thr = LK_KERNPROC;
OpenPOWER on IntegriCloud