diff options
Diffstat (limited to 'sys/kern')
-rw-r--r-- | sys/kern/kern_lock.c | 49 | ||||
-rw-r--r-- | sys/kern/vfs_default.c | 5 | ||||
-rw-r--r-- | sys/kern/vfs_vnops.c | 12 |
3 files changed, 15 insertions, 51 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 } diff --git a/sys/kern/vfs_default.c b/sys/kern/vfs_default.c index e338863..8369fc5 100644 --- a/sys/kern/vfs_default.c +++ b/sys/kern/vfs_default.c @@ -254,12 +254,7 @@ vop_stdlock(ap) { struct vnode *vp = ap->a_vp; -#ifndef DEBUG_LOCKS return (lockmgr(vp->v_vnlock, ap->a_flags, VI_MTX(vp), ap->a_td)); -#else - return (debuglockmgr(vp->v_vnlock, ap->a_flags, VI_MTX(vp), - ap->a_td, "vop_stdlock", vp->filename, vp->line)); -#endif } /* See above. */ diff --git a/sys/kern/vfs_vnops.c b/sys/kern/vfs_vnops.c index 3337e10..d8c00fd 100644 --- a/sys/kern/vfs_vnops.c +++ b/sys/kern/vfs_vnops.c @@ -779,18 +779,10 @@ vn_poll(fp, events, active_cred, td) * acquire requested lock. */ int -#ifndef DEBUG_LOCKS vn_lock(vp, flags, td) -#else -debug_vn_lock(vp, flags, td, filename, line) -#endif struct vnode *vp; int flags; struct thread *td; -#ifdef DEBUG_LOCKS - const char *filename; - int line; -#endif { int error; @@ -809,10 +801,6 @@ debug_vn_lock(vp, flags, td, filename, line) VI_UNLOCK(vp); return (0); } -#ifdef DEBUG_LOCKS - vp->filename = filename; - vp->line = line; -#endif /* * lockmgr drops interlock before it will return for * any reason. So force the code above to relock it. |