summaryrefslogtreecommitdiffstats
path: root/sys/kern/kern_lock.c
diff options
context:
space:
mode:
authorjeff <jeff@FreeBSD.org>2005-08-03 04:48:22 +0000
committerjeff <jeff@FreeBSD.org>2005-08-03 04:48:22 +0000
commit08fb635b5502e48aa8292e7f376c46f0ba1db8cc (patch)
tree9f832940cb85883a5821c06fb2bfd2f54759028d /sys/kern/kern_lock.c
parent0b6d38e89f73861edc118b9f13efec01813c8e6a (diff)
downloadFreeBSD-src-08fb635b5502e48aa8292e7f376c46f0ba1db8cc.zip
FreeBSD-src-08fb635b5502e48aa8292e7f376c46f0ba1db8cc.tar.gz
- Replace the series of DEBUG_LOCKS hacks which tried to save the vn_lock
caller by saving the stack of the last locker/unlocker in lockmgr. We also put the stack in KTR at the moment. Contributed by: Antoine Brodin <antoine.brodin@laposte.net>
Diffstat (limited to 'sys/kern/kern_lock.c')
-rw-r--r--sys/kern/kern_lock.c49
1 files changed, 15 insertions, 34 deletions
diff --git a/sys/kern/kern_lock.c b/sys/kern/kern_lock.c
index 55acab6..375015f 100644
--- a/sys/kern/kern_lock.c
+++ b/sys/kern/kern_lock.c
@@ -51,6 +51,10 @@ __FBSDID("$FreeBSD$");
#include <sys/mutex.h>
#include <sys/proc.h>
#include <sys/systm.h>
+#ifdef DEBUG_LOCKS
+#include <sys/stack.h>
+#include <sys/sysctl.h>
+#endif
/*
* Locking primitives implementation.
@@ -138,20 +142,11 @@ acquire(struct lock **lkpp, int extflags, int wanted)
* accepted shared locks and shared-to-exclusive upgrades to go away.
*/
int
-#ifndef DEBUG_LOCKS
lockmgr(lkp, flags, interlkp, td)
-#else
-debuglockmgr(lkp, flags, interlkp, td, name, file, line)
-#endif
struct lock *lkp;
u_int flags;
struct mtx *interlkp;
struct thread *td;
-#ifdef DEBUG_LOCKS
- const char *name; /* Name of lock function */
- const char *file; /* Name of file call is from */
- int line; /* Line number in file */
-#endif
{
int error;
struct thread *thr;
@@ -165,15 +160,16 @@ debuglockmgr(lkp, flags, interlkp, td, name, file, line)
if ((flags & LK_INTERNAL) == 0)
mtx_lock(lkp->lk_interlock);
-#ifdef DEBUG_LOCKS
- CTR6(KTR_LOCK,
- "lockmgr(): lkp == %p (lk_wmesg == \"%s\"), flags == 0x%x, "
- "td == %p %s:%d", lkp, lkp->lk_wmesg, flags, td, file, line);
-#else
CTR6(KTR_LOCK,
"lockmgr(): lkp == %p (lk_wmesg == \"%s\"), owner == %p, exclusivecount == %d, flags == 0x%x, "
"td == %p", lkp, lkp->lk_wmesg, lkp->lk_lockholder,
lkp->lk_exclusivecount, flags, td);
+#ifdef DEBUG_LOCKS
+ {
+ struct stack stack; /* XXX */
+ stack_save(&stack);
+ CTRSTACK(KTR_LOCK, &stack, 1);
+ }
#endif
if (flags & LK_INTERLOCK) {
@@ -218,10 +214,7 @@ debuglockmgr(lkp, flags, interlkp, td, name, file, line)
break;
sharelock(td, lkp, 1);
#if defined(DEBUG_LOCKS)
- lkp->lk_slockholder = thr;
- lkp->lk_sfilename = file;
- lkp->lk_slineno = line;
- lkp->lk_slockername = name;
+ stack_save(&lkp->stack);
#endif
break;
}
@@ -304,9 +297,7 @@ debuglockmgr(lkp, flags, interlkp, td, name, file, line)
lkp->lk_exclusivecount = 1;
COUNT(td, 1);
#if defined(DEBUG_LOCKS)
- lkp->lk_filename = file;
- lkp->lk_lineno = line;
- lkp->lk_lockername = name;
+ stack_save(&lkp->stack);
#endif
break;
}
@@ -365,9 +356,7 @@ debuglockmgr(lkp, flags, interlkp, td, name, file, line)
lkp->lk_exclusivecount = 1;
COUNT(td, 1);
#if defined(DEBUG_LOCKS)
- lkp->lk_filename = file;
- lkp->lk_lineno = line;
- lkp->lk_lockername = name;
+ stack_save(&lkp->stack);
#endif
break;
@@ -412,9 +401,7 @@ debuglockmgr(lkp, flags, interlkp, td, name, file, line)
lkp->lk_exclusivecount = 1;
COUNT(td, 1);
#if defined(DEBUG_LOCKS)
- lkp->lk_filename = file;
- lkp->lk_lineno = line;
- lkp->lk_lockername = name;
+ stack_save(&lkp->stack);
#endif
break;
@@ -508,13 +495,7 @@ lockinit(lkp, prio, wmesg, timo, flags)
lkp->lk_lockholder = LK_NOPROC;
lkp->lk_newlock = NULL;
#ifdef DEBUG_LOCKS
- lkp->lk_filename = "none";
- lkp->lk_lockername = "never exclusive locked";
- lkp->lk_lineno = 0;
- lkp->lk_slockholder = LK_NOPROC;
- lkp->lk_sfilename = "none";
- lkp->lk_slockername = "never share locked";
- lkp->lk_slineno = 0;
+ stack_zero(&lkp->stack);
#endif
}
OpenPOWER on IntegriCloud