diff options
Diffstat (limited to 'sys/kern/kern_lock.c')
-rw-r--r-- | sys/kern/kern_lock.c | 49 |
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 } |