summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--sys/kern/kern_lock.c49
-rw-r--r--sys/kern/vfs_default.c5
-rw-r--r--sys/kern/vfs_vnops.c12
-rw-r--r--sys/sys/lockmgr.h24
-rw-r--r--sys/sys/vnode.h9
5 files changed, 20 insertions, 79 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.
diff --git a/sys/sys/lockmgr.h b/sys/sys/lockmgr.h
index 248ac71..52061ab 100644
--- a/sys/sys/lockmgr.h
+++ b/sys/sys/lockmgr.h
@@ -37,6 +37,10 @@
#ifndef _SYS_LOCKMGR_H_
#define _SYS_LOCKMGR_H_
+#ifdef DEBUG_LOCKS
+#include <sys/stack.h> /* XXX */
+#endif
+
struct mtx;
/*
@@ -56,14 +60,7 @@ struct lock {
struct thread *lk_lockholder; /* thread of exclusive lock holder */
struct lock *lk_newlock; /* lock taking over this lock */
#ifdef DEBUG_LOCKS
- const char *lk_filename;
- const char *lk_lockername;
- int lk_lineno;
-
- struct thread *lk_slockholder;
- const char *lk_sfilename;
- const char *lk_slockername;
- int lk_slineno;
+ struct stack stack;
#endif
};
/*
@@ -200,19 +197,8 @@ void lockinit(struct lock *, int prio, const char *wmesg,
int timo, int flags);
void lockdestroy(struct lock *);
-#ifdef DEBUG_LOCKS
-int debuglockmgr(struct lock *, u_int flags,
- struct mtx *, struct thread *p,
- const char *,
- const char *,
- int);
-#define lockmgr(lockp, flags, slockp, proc) \
- debuglockmgr((lockp), (flags), (slockp), (proc), \
- "lockmgr", __FILE__, __LINE__)
-#else
int lockmgr(struct lock *, u_int flags,
struct mtx *, struct thread *p);
-#endif
void transferlockers(struct lock *, struct lock *);
void lockmgr_printinfo(struct lock *);
int lockstatus(struct lock *, struct thread *);
diff --git a/sys/sys/vnode.h b/sys/sys/vnode.h
index 05b5da7..f27be24 100644
--- a/sys/sys/vnode.h
+++ b/sys/sys/vnode.h
@@ -159,10 +159,6 @@ struct vnode {
struct lock v_lock; /* u (if fs don't have one) */
struct mtx v_interlock; /* lock for "i" things */
struct lock *v_vnlock; /* u pointer to vnode lock */
-#ifdef DEBUG_LOCKS
- const char *filename; /* Source file doing locking */
- int line; /* Line number doing locking */
-#endif
int v_holdcnt; /* i prevents recycling. */
int v_usecount; /* i ref count of users */
u_long v_iflag; /* i vnode flags (see below) */
@@ -613,11 +609,6 @@ int vn_close(struct vnode *vp,
void vn_finished_write(struct mount *mp);
int vn_isdisk(struct vnode *vp, int *errp);
int vn_lock(struct vnode *vp, int flags, struct thread *td);
-#ifdef DEBUG_LOCKS
-int debug_vn_lock(struct vnode *vp, int flags, struct thread *p,
- const char *filename, int line);
-#define vn_lock(vp,flags,p) debug_vn_lock(vp,flags,p,__FILE__,__LINE__)
-#endif
int vn_open(struct nameidata *ndp, int *flagp, int cmode, int fdidx);
int vn_open_cred(struct nameidata *ndp, int *flagp, int cmode,
struct ucred *cred, int fdidx);
OpenPOWER on IntegriCloud