diff options
author | Attilio Rao <attilio@FreeBSD.org> | 2007-12-27 22:56:57 +0000 |
---|---|---|
committer | Attilio Rao <attilio@FreeBSD.org> | 2007-12-27 22:56:57 +0000 |
commit | 7a1d78fa3fdb41351a3fd279db86039886db232e (patch) | |
tree | 864827637835381b82a08d4fb02140a628f2f208 /sys/kern/kern_lock.c | |
parent | 0417fe5421be43b36463a294f8cd62d4fcf799d1 (diff) | |
download | src-7a1d78fa3fdb41351a3fd279db86039886db232e.tar.gz src-7a1d78fa3fdb41351a3fd279db86039886db232e.zip |
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.
Notes
Notes:
svn path=/head/; revision=174948
Diffstat (limited to 'sys/kern/kern_lock.c')
-rw-r--r-- | sys/kern/kern_lock.c | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/sys/kern/kern_lock.c b/sys/kern/kern_lock.c index 3e1d78fe4887..d4413def1baf 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; |