svn commit: r285703 - in head/sys: amd64/conf arm/conf cddl/dev/lockstat cddl/dev/sdt conf i386/conf kern modules/dtrace modules/dtrace/dtraceall modules/dtrace/lockstat powerpc/conf sys
Mark Johnston
markj at FreeBSD.org
Sun Jul 19 22:14:17 UTC 2015
Author: markj
Date: Sun Jul 19 22:14:09 2015
New Revision: 285703
URL: https://svnweb.freebsd.org/changeset/base/285703
Log:
Implement the lockstat provider using SDT(9) instead of the custom provider
in lockstat.ko. This means that lockstat probes now have typed arguments and
will utilize SDT probe hot-patching support when it arrives.
Reviewed by: gnn
Differential Revision: https://reviews.freebsd.org/D2993
Deleted:
head/sys/cddl/dev/lockstat/
head/sys/modules/dtrace/lockstat/
Modified:
head/sys/amd64/conf/NOTES
head/sys/arm/conf/BEAGLEBONE
head/sys/arm/conf/NOTES
head/sys/cddl/dev/sdt/sdt.c
head/sys/conf/files
head/sys/i386/conf/NOTES
head/sys/kern/kern_lockstat.c
head/sys/kern/kern_mutex.c
head/sys/kern/kern_rwlock.c
head/sys/kern/kern_sx.c
head/sys/modules/dtrace/Makefile
head/sys/modules/dtrace/Makefile.inc
head/sys/modules/dtrace/dtraceall/dtraceall.c
head/sys/powerpc/conf/NOTES
head/sys/sys/lockstat.h
head/sys/sys/mutex.h
head/sys/sys/rwlock.h
head/sys/sys/sx.h
Modified: head/sys/amd64/conf/NOTES
==============================================================================
--- head/sys/amd64/conf/NOTES Sun Jul 19 21:31:52 2015 (r285702)
+++ head/sys/amd64/conf/NOTES Sun Jul 19 22:14:09 2015 (r285703)
@@ -22,7 +22,6 @@ options KDTRACE_HOOKS
#device dtrace
# DTrace modules
-#device dtrace_lockstat
#device dtrace_profile
#device dtrace_sdt
#device dtrace_fbt
Modified: head/sys/arm/conf/BEAGLEBONE
==============================================================================
--- head/sys/arm/conf/BEAGLEBONE Sun Jul 19 21:31:52 2015 (r285702)
+++ head/sys/arm/conf/BEAGLEBONE Sun Jul 19 22:14:09 2015 (r285703)
@@ -32,7 +32,7 @@ makeoptions MODULES_EXTRA="dtb/am335x"
options KDTRACE_HOOKS # Kernel DTrace hooks
options DDB_CTF # all architectures - kernel ELF linker loads CTF data
makeoptions WITH_CTF=1
-makeoptions MODULES_EXTRA+="opensolaris dtrace dtrace/lockstat dtrace/profile dtrace/fbt"
+makeoptions MODULES_EXTRA+="opensolaris dtrace dtrace/profile dtrace/fbt"
options HZ=100
options SCHED_4BSD # 4BSD scheduler
Modified: head/sys/arm/conf/NOTES
==============================================================================
--- head/sys/arm/conf/NOTES Sun Jul 19 21:31:52 2015 (r285702)
+++ head/sys/arm/conf/NOTES Sun Jul 19 22:14:09 2015 (r285703)
@@ -98,7 +98,6 @@ options KDTRACE_HOOKS
#device dtrace
# DTrace modules
-#device dtrace_lockstat
#device dtrace_profile
#device dtrace_sdt
#device dtrace_fbt
Modified: head/sys/cddl/dev/sdt/sdt.c
==============================================================================
--- head/sys/cddl/dev/sdt/sdt.c Sun Jul 19 21:31:52 2015 (r285702)
+++ head/sys/cddl/dev/sdt/sdt.c Sun Jul 19 22:14:09 2015 (r285703)
@@ -50,6 +50,7 @@
#include <sys/linker.h>
#include <sys/linker_set.h>
#include <sys/lock.h>
+#include <sys/lockstat.h>
#include <sys/malloc.h>
#include <sys/module.h>
#include <sys/mutex.h>
@@ -197,6 +198,8 @@ sdt_enable(void *arg __unused, dtrace_id
probe->id = id;
probe->sdtp_lf->nenabled++;
+ if (strcmp(probe->prov->name, "lockstat") == 0)
+ lockstat_enabled++;
}
static void
@@ -206,6 +209,8 @@ sdt_disable(void *arg __unused, dtrace_i
KASSERT(probe->sdtp_lf->nenabled > 0, ("no probes enabled"));
+ if (strcmp(probe->prov->name, "lockstat") == 0)
+ lockstat_enabled--;
probe->id = 0;
probe->sdtp_lf->nenabled--;
}
Modified: head/sys/conf/files
==============================================================================
--- head/sys/conf/files Sun Jul 19 21:31:52 2015 (r285702)
+++ head/sys/conf/files Sun Jul 19 22:14:09 2015 (r285703)
@@ -246,7 +246,6 @@ cddl/contrib/opensolaris/uts/common/zmod
cddl/contrib/opensolaris/uts/common/dtrace/dtrace.c optional dtrace compile-with "${DTRACE_C}" \
warning "kernel contains CDDL licensed DTRACE"
cddl/dev/dtmalloc/dtmalloc.c optional dtmalloc | dtraceall compile-with "${CDDL_C}"
-cddl/dev/lockstat/lockstat.c optional dtrace_lockstat | dtraceall compile-with "${CDDL_C}"
cddl/dev/profile/profile.c optional dtrace_profile | dtraceall compile-with "${CDDL_C}"
cddl/dev/sdt/sdt.c optional dtrace_sdt | dtraceall compile-with "${CDDL_C}"
cddl/dev/fbt/fbt.c optional dtrace_fbt | dtraceall compile-with "${FBT_C}"
Modified: head/sys/i386/conf/NOTES
==============================================================================
--- head/sys/i386/conf/NOTES Sun Jul 19 21:31:52 2015 (r285702)
+++ head/sys/i386/conf/NOTES Sun Jul 19 22:14:09 2015 (r285703)
@@ -22,7 +22,6 @@ options KDTRACE_HOOKS
#device dtrace
# DTrace modules
-#device dtrace_lockstat
#device dtrace_profile
#device dtrace_sdt
#device dtrace_fbt
Modified: head/sys/kern/kern_lockstat.c
==============================================================================
--- head/sys/kern/kern_lockstat.c Sun Jul 19 21:31:52 2015 (r285702)
+++ head/sys/kern/kern_lockstat.c Sun Jul 19 22:14:09 2015 (r285703)
@@ -21,31 +21,46 @@
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
- *
- * $FreeBSD$
*/
-/*
- * Backend for the lock tracing (lockstat) kernel support. This is required
- * to allow a module to load even though DTrace kernel support may not be
- * present.
- *
- */
-
-#ifdef KDTRACE_HOOKS
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
-#include <sys/types.h>
+#include <sys/param.h>
#include <sys/lock.h>
#include <sys/lockstat.h>
+#include <sys/sdt.h>
#include <sys/time.h>
-/*
- * The following must match the type definition of dtrace_probe. It is
- * defined this way to avoid having to rely on CDDL code.
- */
-uint32_t lockstat_probemap[LS_NPROBES];
-void (*lockstat_probe_func)(uint32_t, uintptr_t, uintptr_t,
- uintptr_t, uintptr_t, uintptr_t);
+SDT_PROVIDER_DEFINE(lockstat);
+
+SDT_PROBE_DEFINE1(lockstat, , , adaptive__acquire, "struct mtx *");
+SDT_PROBE_DEFINE1(lockstat, , , adaptive__release, "struct mtx *");
+SDT_PROBE_DEFINE2(lockstat, , , adaptive__spin, "struct mtx *", "uint64_t");
+SDT_PROBE_DEFINE2(lockstat, , , adaptive__block, "struct mtx *", "uint64_t");
+
+SDT_PROBE_DEFINE1(lockstat, , , spin__acquire, "struct mtx *");
+SDT_PROBE_DEFINE1(lockstat, , , spin__release, "struct mtx *");
+SDT_PROBE_DEFINE2(lockstat, , , spin__spin, "struct mtx *", "uint64_t");
+
+SDT_PROBE_DEFINE1(lockstat, , , rw__acquire, "struct rwlock *");
+SDT_PROBE_DEFINE1(lockstat, , , rw__release, "struct rwlock *");
+SDT_PROBE_DEFINE5(lockstat, , , rw__block, "struct rwlock *", "uint64_t", "int",
+ "int", "int");
+SDT_PROBE_DEFINE2(lockstat, , , rw__spin, "struct rwlock *", "uint64_t");
+SDT_PROBE_DEFINE1(lockstat, , , rw__upgrade, "struct rwlock *");
+SDT_PROBE_DEFINE1(lockstat, , , rw__downgrade, "struct rwlock *");
+
+SDT_PROBE_DEFINE1(lockstat, , , sx__acquire, "struct sx *");
+SDT_PROBE_DEFINE1(lockstat, , , sx__release, "struct sx *");
+SDT_PROBE_DEFINE5(lockstat, , , sx__block, "struct sx *", "uint64_t", "int",
+ "int", "int");
+SDT_PROBE_DEFINE2(lockstat, , , sx__spin, "struct sx *", "uint64_t");
+SDT_PROBE_DEFINE1(lockstat, , , sx__upgrade, "struct sx *");
+SDT_PROBE_DEFINE1(lockstat, , , sx__downgrade, "struct sx *");
+
+SDT_PROBE_DEFINE2(lockstat, , , thread__spin, "struct mtx *", "uint64_t");
+
int lockstat_enabled = 0;
uint64_t
@@ -64,5 +79,3 @@ lockstat_nsecs(struct lock_object *lo)
ns += ((uint64_t)1000000000 * (uint32_t)(bt.frac >> 32)) >> 32;
return (ns);
}
-
-#endif /* KDTRACE_HOOKS */
Modified: head/sys/kern/kern_mutex.c
==============================================================================
--- head/sys/kern/kern_mutex.c Sun Jul 19 21:31:52 2015 (r285702)
+++ head/sys/kern/kern_mutex.c Sun Jul 19 22:14:09 2015 (r285703)
@@ -349,7 +349,7 @@ _mtx_trylock_flags_(volatile uintptr_t *
file, line);
curthread->td_locks++;
if (m->mtx_recurse == 0)
- LOCKSTAT_PROFILE_OBTAIN_LOCK_SUCCESS(LS_MTX_LOCK_ACQUIRE,
+ LOCKSTAT_PROFILE_OBTAIN_LOCK_SUCCESS(adaptive__acquire,
m, contested, waittime, file, line);
}
@@ -531,17 +531,17 @@ __mtx_lock_sleep(volatile uintptr_t *c,
m->lock_object.lo_name, (void *)tid, file, line);
}
#endif
- LOCKSTAT_PROFILE_OBTAIN_LOCK_SUCCESS(LS_MTX_LOCK_ACQUIRE, m, contested,
+ LOCKSTAT_PROFILE_OBTAIN_LOCK_SUCCESS(adaptive__acquire, m, contested,
waittime, file, line);
#ifdef KDTRACE_HOOKS
if (sleep_time)
- LOCKSTAT_RECORD1(LS_MTX_LOCK_BLOCK, m, sleep_time);
+ LOCKSTAT_RECORD1(adaptive__block, m, sleep_time);
/*
* Only record the loops spinning and not sleeping.
*/
if (spin_cnt > sleep_cnt)
- LOCKSTAT_RECORD1(LS_MTX_LOCK_SPIN, m, (all_time - sleep_time));
+ LOCKSTAT_RECORD1(adaptive__spin, m, all_time - sleep_time);
#endif
}
@@ -628,11 +628,11 @@ _mtx_lock_spin_cookie(volatile uintptr_t
KTR_STATE0(KTR_SCHED, "thread", sched_tdname((struct thread *)tid),
"running");
- LOCKSTAT_PROFILE_OBTAIN_LOCK_SUCCESS(LS_MTX_SPIN_LOCK_ACQUIRE, m,
- contested, waittime, (file), (line));
#ifdef KDTRACE_HOOKS
+ LOCKSTAT_PROFILE_OBTAIN_LOCK_SUCCESS(spin__acquire, m,
+ contested, waittime, file, line);
if (spin_time != 0)
- LOCKSTAT_RECORD1(LS_MTX_SPIN_LOCK_SPIN, m, spin_time);
+ LOCKSTAT_RECORD1(spin__spin, m, spin_time);
#endif
}
#endif /* SMP */
@@ -709,12 +709,12 @@ retry:
spin_time += lockstat_nsecs(&m->lock_object);
#endif
if (m->mtx_recurse == 0)
- LOCKSTAT_PROFILE_OBTAIN_LOCK_SUCCESS(LS_MTX_SPIN_LOCK_ACQUIRE,
- m, contested, waittime, (file), (line));
+ LOCKSTAT_PROFILE_OBTAIN_LOCK_SUCCESS(spin__acquire, m,
+ contested, waittime, file, line);
LOCK_LOG_LOCK("LOCK", &m->lock_object, opts, m->mtx_recurse, file,
line);
WITNESS_LOCK(&m->lock_object, opts | LOP_EXCLUSIVE, file, line);
- LOCKSTAT_RECORD1(LS_THREAD_LOCK_SPIN, m, spin_time);
+ LOCKSTAT_RECORD1(thread__spin, m, spin_time);
}
struct mtx *
Modified: head/sys/kern/kern_rwlock.c
==============================================================================
--- head/sys/kern/kern_rwlock.c Sun Jul 19 21:31:52 2015 (r285702)
+++ head/sys/kern/kern_rwlock.c Sun Jul 19 22:14:09 2015 (r285703)
@@ -301,7 +301,7 @@ __rw_try_wlock(volatile uintptr_t *c, co
WITNESS_LOCK(&rw->lock_object, LOP_EXCLUSIVE | LOP_TRYLOCK,
file, line);
if (!rw_recursed(rw))
- LOCKSTAT_PROFILE_OBTAIN_LOCK_SUCCESS(LS_RW_WLOCK_ACQUIRE,
+ LOCKSTAT_PROFILE_OBTAIN_LOCK_SUCCESS(rw__acquire,
rw, 0, 0, file, line);
curthread->td_locks++;
}
@@ -546,13 +546,13 @@ __rw_rlock(volatile uintptr_t *c, const
#ifdef KDTRACE_HOOKS
all_time += lockstat_nsecs(&rw->lock_object);
if (sleep_time)
- LOCKSTAT_RECORD4(LS_RW_RLOCK_BLOCK, rw, sleep_time,
+ LOCKSTAT_RECORD4(rw__block, rw, sleep_time,
LOCKSTAT_READER, (state & RW_LOCK_READ) == 0,
(state & RW_LOCK_READ) == 0 ? 0 : RW_READERS(state));
/* Record only the loops spinning and not sleeping. */
if (spin_cnt > sleep_cnt)
- LOCKSTAT_RECORD4(LS_RW_RLOCK_SPIN, rw, all_time - sleep_time,
+ LOCKSTAT_RECORD4(rw__spin, rw, all_time - sleep_time,
LOCKSTAT_READER, (state & RW_LOCK_READ) == 0,
(state & RW_LOCK_READ) == 0 ? 0 : RW_READERS(state));
#endif
@@ -561,7 +561,7 @@ __rw_rlock(volatile uintptr_t *c, const
* however. turnstiles don't like owners changing between calls to
* turnstile_wait() currently.
*/
- LOCKSTAT_PROFILE_OBTAIN_LOCK_SUCCESS(LS_RW_RLOCK_ACQUIRE, rw, contested,
+ LOCKSTAT_PROFILE_OBTAIN_LOCK_SUCCESS(rw__acquire, rw, contested,
waittime, file, line);
LOCK_LOG_LOCK("RLOCK", &rw->lock_object, 0, 0, file, line);
WITNESS_LOCK(&rw->lock_object, 0, file, line);
@@ -594,7 +594,7 @@ __rw_try_rlock(volatile uintptr_t *c, co
LOCK_LOG_TRY("RLOCK", &rw->lock_object, 0, 1, file,
line);
WITNESS_LOCK(&rw->lock_object, LOP_TRYLOCK, file, line);
- LOCKSTAT_PROFILE_OBTAIN_LOCK_SUCCESS(LS_RW_RLOCK_ACQUIRE,
+ LOCKSTAT_PROFILE_OBTAIN_LOCK_SUCCESS(rw__acquire,
rw, 0, 0, file, line);
curthread->td_locks++;
curthread->td_rw_rlocks++;
@@ -713,7 +713,7 @@ _rw_runlock_cookie(volatile uintptr_t *c
turnstile_chain_unlock(&rw->lock_object);
break;
}
- LOCKSTAT_PROFILE_RELEASE_LOCK(LS_RW_RUNLOCK_RELEASE, rw);
+ LOCKSTAT_PROFILE_RELEASE_LOCK(rw__release, rw);
curthread->td_locks--;
curthread->td_rw_rlocks--;
}
@@ -910,17 +910,17 @@ __rw_wlock_hard(volatile uintptr_t *c, u
#ifdef KDTRACE_HOOKS
all_time += lockstat_nsecs(&rw->lock_object);
if (sleep_time)
- LOCKSTAT_RECORD4(LS_RW_WLOCK_BLOCK, rw, sleep_time,
+ LOCKSTAT_RECORD4(rw__block, rw, sleep_time,
LOCKSTAT_WRITER, (state & RW_LOCK_READ) == 0,
(state & RW_LOCK_READ) == 0 ? 0 : RW_READERS(state));
/* Record only the loops spinning and not sleeping. */
if (spin_cnt > sleep_cnt)
- LOCKSTAT_RECORD4(LS_RW_WLOCK_SPIN, rw, all_time - sleep_time,
+ LOCKSTAT_RECORD4(rw__spin, rw, all_time - sleep_time,
LOCKSTAT_READER, (state & RW_LOCK_READ) == 0,
(state & RW_LOCK_READ) == 0 ? 0 : RW_READERS(state));
#endif
- LOCKSTAT_PROFILE_OBTAIN_LOCK_SUCCESS(LS_RW_WLOCK_ACQUIRE, rw, contested,
+ LOCKSTAT_PROFILE_OBTAIN_LOCK_SUCCESS(rw__acquire, rw, contested,
waittime, file, line);
}
@@ -1066,7 +1066,7 @@ __rw_try_upgrade(volatile uintptr_t *c,
curthread->td_rw_rlocks--;
WITNESS_UPGRADE(&rw->lock_object, LOP_EXCLUSIVE | LOP_TRYLOCK,
file, line);
- LOCKSTAT_RECORD0(LS_RW_TRYUPGRADE_UPGRADE, rw);
+ LOCKSTAT_RECORD0(rw__upgrade, rw);
}
return (success);
}
@@ -1138,7 +1138,7 @@ __rw_downgrade(volatile uintptr_t *c, co
out:
curthread->td_rw_rlocks++;
LOCK_LOG_LOCK("WDOWNGRADE", &rw->lock_object, 0, 0, file, line);
- LOCKSTAT_RECORD0(LS_RW_DOWNGRADE_DOWNGRADE, rw);
+ LOCKSTAT_RECORD0(rw__downgrade, rw);
}
#ifdef INVARIANT_SUPPORT
Modified: head/sys/kern/kern_sx.c
==============================================================================
--- head/sys/kern/kern_sx.c Sun Jul 19 21:31:52 2015 (r285702)
+++ head/sys/kern/kern_sx.c Sun Jul 19 22:14:09 2015 (r285703)
@@ -288,7 +288,7 @@ sx_try_slock_(struct sx *sx, const char
if (atomic_cmpset_acq_ptr(&sx->sx_lock, x, x + SX_ONE_SHARER)) {
LOCK_LOG_TRY("SLOCK", &sx->lock_object, 0, 1, file, line);
WITNESS_LOCK(&sx->lock_object, LOP_TRYLOCK, file, line);
- LOCKSTAT_PROFILE_OBTAIN_LOCK_SUCCESS(LS_SX_SLOCK_ACQUIRE,
+ LOCKSTAT_PROFILE_OBTAIN_LOCK_SUCCESS(sx__acquire,
sx, 0, 0, file, line);
curthread->td_locks++;
return (1);
@@ -351,7 +351,7 @@ sx_try_xlock_(struct sx *sx, const char
WITNESS_LOCK(&sx->lock_object, LOP_EXCLUSIVE | LOP_TRYLOCK,
file, line);
if (!sx_recursed(sx))
- LOCKSTAT_PROFILE_OBTAIN_LOCK_SUCCESS(LS_SX_XLOCK_ACQUIRE,
+ LOCKSTAT_PROFILE_OBTAIN_LOCK_SUCCESS(sx__acquire,
sx, 0, 0, file, line);
curthread->td_locks++;
}
@@ -420,7 +420,7 @@ sx_try_upgrade_(struct sx *sx, const cha
if (success) {
WITNESS_UPGRADE(&sx->lock_object, LOP_EXCLUSIVE | LOP_TRYLOCK,
file, line);
- LOCKSTAT_RECORD0(LS_SX_TRYUPGRADE_UPGRADE, sx);
+ LOCKSTAT_RECORD0(sx__upgrade, sx);
}
return (success);
}
@@ -486,7 +486,7 @@ sx_downgrade_(struct sx *sx, const char
sleepq_release(&sx->lock_object);
LOCK_LOG_LOCK("XDOWNGRADE", &sx->lock_object, 0, 0, file, line);
- LOCKSTAT_RECORD0(LS_SX_DOWNGRADE_DOWNGRADE, sx);
+ LOCKSTAT_RECORD0(sx__downgrade, sx);
if (wakeup_swapper)
kick_proc0();
@@ -719,16 +719,16 @@ _sx_xlock_hard(struct sx *sx, uintptr_t
#ifdef KDTRACE_HOOKS
all_time += lockstat_nsecs(&sx->lock_object);
if (sleep_time)
- LOCKSTAT_RECORD4(LS_SX_XLOCK_BLOCK, sx, sleep_time,
+ LOCKSTAT_RECORD4(sx__block, sx, sleep_time,
LOCKSTAT_WRITER, (state & SX_LOCK_SHARED) == 0,
(state & SX_LOCK_SHARED) == 0 ? 0 : SX_SHARERS(state));
if (spin_cnt > sleep_cnt)
- LOCKSTAT_RECORD4(LS_SX_XLOCK_SPIN, sx, all_time - sleep_time,
+ LOCKSTAT_RECORD4(sx__spin, sx, all_time - sleep_time,
LOCKSTAT_WRITER, (state & SX_LOCK_SHARED) == 0,
(state & SX_LOCK_SHARED) == 0 ? 0 : SX_SHARERS(state));
#endif
if (!error)
- LOCKSTAT_PROFILE_OBTAIN_LOCK_SUCCESS(LS_SX_XLOCK_ACQUIRE, sx,
+ LOCKSTAT_PROFILE_OBTAIN_LOCK_SUCCESS(sx__acquire, sx,
contested, waittime, file, line);
GIANT_RESTORE();
return (error);
@@ -983,17 +983,17 @@ _sx_slock_hard(struct sx *sx, int opts,
#ifdef KDTRACE_HOOKS
all_time += lockstat_nsecs(&sx->lock_object);
if (sleep_time)
- LOCKSTAT_RECORD4(LS_SX_SLOCK_BLOCK, sx, sleep_time,
+ LOCKSTAT_RECORD4(sx__block, sx, sleep_time,
LOCKSTAT_READER, (state & SX_LOCK_SHARED) == 0,
(state & SX_LOCK_SHARED) == 0 ? 0 : SX_SHARERS(state));
if (spin_cnt > sleep_cnt)
- LOCKSTAT_RECORD4(LS_SX_SLOCK_SPIN, sx, all_time - sleep_time,
+ LOCKSTAT_RECORD4(sx__spin, sx, all_time - sleep_time,
LOCKSTAT_READER, (state & SX_LOCK_SHARED) == 0,
(state & SX_LOCK_SHARED) == 0 ? 0 : SX_SHARERS(state));
#endif
if (error == 0)
- LOCKSTAT_PROFILE_OBTAIN_LOCK_SUCCESS(LS_SX_SLOCK_ACQUIRE, sx,
- contested, waittime, file, line);
+ LOCKSTAT_PROFILE_OBTAIN_LOCK_SUCCESS(sx__acquire, sx, contested,
+ waittime, file, line);
GIANT_RESTORE();
return (error);
}
Modified: head/sys/modules/dtrace/Makefile
==============================================================================
--- head/sys/modules/dtrace/Makefile Sun Jul 19 21:31:52 2015 (r285702)
+++ head/sys/modules/dtrace/Makefile Sun Jul 19 22:14:09 2015 (r285703)
@@ -7,7 +7,6 @@ SUBDIR= dtmalloc \
dtrace \
dtraceall \
dtrace_test \
- lockstat \
profile \
prototype \
sdt \
Modified: head/sys/modules/dtrace/Makefile.inc
==============================================================================
--- head/sys/modules/dtrace/Makefile.inc Sun Jul 19 21:31:52 2015 (r285702)
+++ head/sys/modules/dtrace/Makefile.inc Sun Jul 19 22:14:09 2015 (r285703)
@@ -6,7 +6,6 @@ load :
-kldload dtrace
.if ${MACHINE_CPUARCH} == "i386"
-kldload sdt
- -kldload lockstat
-kldload fbt
-kldload prototype
.endif
@@ -20,7 +19,6 @@ unload :
.if ${MACHINE_CPUARCH} == "i386"
-kldunload prototype
-kldunload fbt
- -kldunload lockstat
-kldunload sdt
.endif
-kldunload dtrace
Modified: head/sys/modules/dtrace/dtraceall/dtraceall.c
==============================================================================
--- head/sys/modules/dtrace/dtraceall/dtraceall.c Sun Jul 19 21:31:52 2015 (r285702)
+++ head/sys/modules/dtrace/dtraceall/dtraceall.c Sun Jul 19 22:14:09 2015 (r285703)
@@ -76,7 +76,6 @@ MODULE_DEPEND(dtraceall, fbt, 1, 1, 1);
#if defined(__amd64__) || defined(__i386__)
MODULE_DEPEND(dtraceall, fasttrap, 1, 1, 1);
#endif
-MODULE_DEPEND(dtraceall, lockstat, 1, 1, 1);
MODULE_DEPEND(dtraceall, sdt, 1, 1, 1);
MODULE_DEPEND(dtraceall, systrace, 1, 1, 1);
#if defined(COMPAT_FREEBSD32)
Modified: head/sys/powerpc/conf/NOTES
==============================================================================
--- head/sys/powerpc/conf/NOTES Sun Jul 19 21:31:52 2015 (r285702)
+++ head/sys/powerpc/conf/NOTES Sun Jul 19 22:14:09 2015 (r285703)
@@ -14,7 +14,6 @@ options KDTRACE_HOOKS
#device dtrace
# DTrace modules
-#device dtrace_lockstat
#device dtrace_profile
#device dtrace_sdt
#device dtrace_fbt
Modified: head/sys/sys/lockstat.h
==============================================================================
--- head/sys/sys/lockstat.h Sun Jul 19 21:31:52 2015 (r285702)
+++ head/sys/sys/lockstat.h Sun Jul 19 22:14:09 2015 (r285703)
@@ -27,185 +27,81 @@
/*
* DTrace lockstat provider definitions
- *
*/
-#ifndef _SYS_LOCKSTAT_H
+#ifndef _SYS_LOCKSTAT_H
#define _SYS_LOCKSTAT_H
-#ifdef _KERNEL
+#ifdef _KERNEL
-/*
- * Spin Locks
- */
-#define LS_MTX_SPIN_LOCK_ACQUIRE 0
-#define LS_MTX_SPIN_UNLOCK_RELEASE 1
-#define LS_MTX_SPIN_LOCK_SPIN 2
+#include <sys/param.h>
+#include <sys/queue.h>
+#include <sys/sdt.h>
+
+SDT_PROVIDER_DECLARE(lockstat);
+
+SDT_PROBE_DECLARE(lockstat, , , adaptive__acquire);
+SDT_PROBE_DECLARE(lockstat, , , adaptive__release);
+SDT_PROBE_DECLARE(lockstat, , , adaptive__spin);
+SDT_PROBE_DECLARE(lockstat, , , adaptive__block);
+
+SDT_PROBE_DECLARE(lockstat, , , spin__acquire);
+SDT_PROBE_DECLARE(lockstat, , , spin__release);
+SDT_PROBE_DECLARE(lockstat, , , spin__spin);
+
+SDT_PROBE_DECLARE(lockstat, , , rw__acquire);
+SDT_PROBE_DECLARE(lockstat, , , rw__release);
+SDT_PROBE_DECLARE(lockstat, , , rw__block);
+SDT_PROBE_DECLARE(lockstat, , , rw__spin);
+SDT_PROBE_DECLARE(lockstat, , , rw__upgrade);
+SDT_PROBE_DECLARE(lockstat, , , rw__downgrade);
+
+SDT_PROBE_DECLARE(lockstat, , , sx__acquire);
+SDT_PROBE_DECLARE(lockstat, , , sx__release);
+SDT_PROBE_DECLARE(lockstat, , , sx__block);
+SDT_PROBE_DECLARE(lockstat, , , sx__spin);
+SDT_PROBE_DECLARE(lockstat, , , sx__upgrade);
+SDT_PROBE_DECLARE(lockstat, , , sx__downgrade);
-/*
- * Adaptive Locks
- */
-#define LS_MTX_LOCK_ACQUIRE 3
-#define LS_MTX_UNLOCK_RELEASE 4
-#define LS_MTX_LOCK_SPIN 5
-#define LS_MTX_LOCK_BLOCK 6
-#define LS_MTX_TRYLOCK_ACQUIRE 7
+SDT_PROBE_DECLARE(lockstat, , , thread__spin);
-/*
- * Reader/Writer Locks
- */
-#define LS_RW_RLOCK_ACQUIRE 8
-#define LS_RW_RUNLOCK_RELEASE 9
-#define LS_RW_WLOCK_ACQUIRE 10
-#define LS_RW_WUNLOCK_RELEASE 11
-#define LS_RW_RLOCK_SPIN 12
-#define LS_RW_RLOCK_BLOCK 13
-#define LS_RW_WLOCK_SPIN 14
-#define LS_RW_WLOCK_BLOCK 15
-#define LS_RW_TRYUPGRADE_UPGRADE 16
-#define LS_RW_DOWNGRADE_DOWNGRADE 17
+#define LOCKSTAT_WRITER 0
+#define LOCKSTAT_READER 1
-/*
- * Shared/Exclusive Locks
- */
-#define LS_SX_SLOCK_ACQUIRE 18
-#define LS_SX_SUNLOCK_RELEASE 19
-#define LS_SX_XLOCK_ACQUIRE 20
-#define LS_SX_XUNLOCK_RELEASE 21
-#define LS_SX_SLOCK_SPIN 22
-#define LS_SX_SLOCK_BLOCK 23
-#define LS_SX_XLOCK_SPIN 24
-#define LS_SX_XLOCK_BLOCK 25
-#define LS_SX_TRYUPGRADE_UPGRADE 26
-#define LS_SX_DOWNGRADE_DOWNGRADE 27
+#ifdef KDTRACE_HOOKS
-/*
- * Thread Locks
- */
-#define LS_THREAD_LOCK_SPIN 28
+#define LOCKSTAT_RECORD0(probe, lp) \
+ SDT_PROBE1(lockstat, , , probe, lp)
-/*
- * Lockmanager Locks
- * According to locking(9) Lockmgr locks are "Largely deprecated"
- * so no support for these have been added in the lockstat provider.
- */
+#define LOCKSTAT_RECORD1(probe, lp, arg1) \
+ SDT_PROBE2(lockstat, , , probe, lp, arg1)
-#define LS_NPROBES 29
+#define LOCKSTAT_RECORD2(probe, lp, arg1, arg2) \
+ SDT_PROBE3(lockstat, , , probe, lp, arg1, arg2)
-#define LS_MTX_LOCK "mtx_lock"
-#define LS_MTX_UNLOCK "mtx_unlock"
-#define LS_MTX_SPIN_LOCK "mtx_lock_spin"
-#define LS_MTX_SPIN_UNLOCK "mtx_unlock_spin"
-#define LS_MTX_TRYLOCK "mtx_trylock"
-#define LS_RW_RLOCK "rw_rlock"
-#define LS_RW_WLOCK "rw_wlock"
-#define LS_RW_RUNLOCK "rw_runlock"
-#define LS_RW_WUNLOCK "rw_wunlock"
-#define LS_RW_TRYUPGRADE "rw_try_upgrade"
-#define LS_RW_DOWNGRADE "rw_downgrade"
-#define LS_SX_SLOCK "sx_slock"
-#define LS_SX_XLOCK "sx_xlock"
-#define LS_SX_SUNLOCK "sx_sunlock"
-#define LS_SX_XUNLOCK "sx_xunlock"
-#define LS_SX_TRYUPGRADE "sx_try_upgrade"
-#define LS_SX_DOWNGRADE "sx_downgrade"
-#define LS_THREAD_LOCK "thread_lock"
-
-#define LS_ACQUIRE "acquire"
-#define LS_RELEASE "release"
-#define LS_SPIN "spin"
-#define LS_BLOCK "block"
-#define LS_UPGRADE "upgrade"
-#define LS_DOWNGRADE "downgrade"
-
-#define LS_TYPE_ADAPTIVE "adaptive"
-#define LS_TYPE_SPIN "spin"
-#define LS_TYPE_THREAD "thread"
-#define LS_TYPE_RW "rw"
-#define LS_TYPE_SX "sx"
-
-#define LSA_ACQUIRE (LS_TYPE_ADAPTIVE "-" LS_ACQUIRE)
-#define LSA_RELEASE (LS_TYPE_ADAPTIVE "-" LS_RELEASE)
-#define LSA_SPIN (LS_TYPE_ADAPTIVE "-" LS_SPIN)
-#define LSA_BLOCK (LS_TYPE_ADAPTIVE "-" LS_BLOCK)
-#define LSS_ACQUIRE (LS_TYPE_SPIN "-" LS_ACQUIRE)
-#define LSS_RELEASE (LS_TYPE_SPIN "-" LS_RELEASE)
-#define LSS_SPIN (LS_TYPE_SPIN "-" LS_SPIN)
-#define LSR_ACQUIRE (LS_TYPE_RW "-" LS_ACQUIRE)
-#define LSR_RELEASE (LS_TYPE_RW "-" LS_RELEASE)
-#define LSR_BLOCK (LS_TYPE_RW "-" LS_BLOCK)
-#define LSR_SPIN (LS_TYPE_RW "-" LS_SPIN)
-#define LSR_UPGRADE (LS_TYPE_RW "-" LS_UPGRADE)
-#define LSR_DOWNGRADE (LS_TYPE_RW "-" LS_DOWNGRADE)
-#define LSX_ACQUIRE (LS_TYPE_SX "-" LS_ACQUIRE)
-#define LSX_RELEASE (LS_TYPE_SX "-" LS_RELEASE)
-#define LSX_BLOCK (LS_TYPE_SX "-" LS_BLOCK)
-#define LSX_SPIN (LS_TYPE_SX "-" LS_SPIN)
-#define LSX_UPGRADE (LS_TYPE_SX "-" LS_UPGRADE)
-#define LSX_DOWNGRADE (LS_TYPE_SX "-" LS_DOWNGRADE)
-#define LST_SPIN (LS_TYPE_THREAD "-" LS_SPIN)
+#define LOCKSTAT_RECORD3(probe, lp, arg1, arg2, arg3) \
+ SDT_PROBE4(lockstat, , , probe, lp, arg1, arg2, arg3)
-/*
- * The following must match the type definition of dtrace_probe. It is
- * defined this way to avoid having to rely on CDDL code.
- */
-struct lock_object;
-extern uint32_t lockstat_probemap[LS_NPROBES];
-typedef void (*lockstat_probe_func_t)(uint32_t, uintptr_t arg0, uintptr_t arg1,
- uintptr_t arg2, uintptr_t arg3, uintptr_t arg4);
-extern lockstat_probe_func_t lockstat_probe_func;
-extern uint64_t lockstat_nsecs(struct lock_object *);
-extern int lockstat_enabled;
+#define LOCKSTAT_RECORD4(probe, lp, arg1, arg2, arg3, arg4) \
+ SDT_PROBE5(lockstat, , , probe, lp, arg1, arg2, arg3, arg4)
-#ifdef KDTRACE_HOOKS
-/*
- * Macros to record lockstat probes.
- */
-#define LOCKSTAT_RECORD4(probe, lp, arg1, arg2, arg3, arg4) do { \
- uint32_t id; \
- \
- if ((id = lockstat_probemap[(probe)])) \
- (*lockstat_probe_func)(id, (uintptr_t)(lp), (arg1), (arg2), \
- (arg3), (arg4)); \
+#define LOCKSTAT_PROFILE_OBTAIN_LOCK_SUCCESS(probe, lp, c, wt, f, l) do { \
+ lock_profile_obtain_lock_success(&(lp)->lock_object, c, wt, f, l); \
+ LOCKSTAT_RECORD0(probe, lp); \
} while (0)
-#define LOCKSTAT_RECORD(probe, lp, arg1) \
- LOCKSTAT_RECORD4(probe, lp, arg1, 0, 0, 0)
-
-#define LOCKSTAT_RECORD0(probe, lp) \
- LOCKSTAT_RECORD4(probe, lp, 0, 0, 0, 0)
-
-#define LOCKSTAT_RECORD1(probe, lp, arg1) \
- LOCKSTAT_RECORD4(probe, lp, arg1, 0, 0, 0)
-
-#define LOCKSTAT_RECORD2(probe, lp, arg1, arg2) \
- LOCKSTAT_RECORD4(probe, lp, arg1, arg2, 0, 0)
-
-#define LOCKSTAT_RECORD3(probe, lp, arg1, arg2, arg3) \
- LOCKSTAT_RECORD4(probe, lp, arg1, arg2, arg3, 0)
-
-#define LOCKSTAT_PROFILE_OBTAIN_LOCK_SUCCESS(probe, lp, c, wt, f, l) do { \
- uint32_t id; \
- \
- lock_profile_obtain_lock_success(&(lp)->lock_object, c, wt, f, l); \
- if ((id = lockstat_probemap[(probe)])) \
- (*lockstat_probe_func)(id, (uintptr_t)(lp), 0, 0, 0, 0); \
+#define LOCKSTAT_PROFILE_RELEASE_LOCK(probe, lp) do { \
+ lock_profile_release_lock(&(lp)->lock_object); \
+ LOCKSTAT_RECORD0(probe, lp); \
} while (0)
-#define LOCKSTAT_PROFILE_RELEASE_LOCK(probe, lp) do { \
- uint32_t id; \
- \
- lock_profile_release_lock(&(lp)->lock_object); \
- if ((id = lockstat_probemap[(probe)])) \
- (*lockstat_probe_func)(id, (uintptr_t)(lp), 0, 0, 0, 0); \
-} while (0)
+extern int lockstat_enabled;
-#define LOCKSTAT_WRITER 0
-#define LOCKSTAT_READER 1
+struct lock_object;
+extern uint64_t lockstat_nsecs(struct lock_object *);
-#else /* !KDTRACE_HOOKS */
+#else /* !KDTRACE_HOOKS */
-#define LOCKSTAT_RECORD(probe, lp, arg1)
#define LOCKSTAT_RECORD0(probe, lp)
#define LOCKSTAT_RECORD1(probe, lp, arg1)
#define LOCKSTAT_RECORD2(probe, lp, arg1, arg2)
@@ -218,8 +114,6 @@ extern int lockstat_enabled;
#define LOCKSTAT_PROFILE_RELEASE_LOCK(probe, lp) \
lock_profile_release_lock(&(lp)->lock_object)
-#endif /* !KDTRACE_HOOKS */
-
-#endif /* _KERNEL */
-
-#endif /* _SYS_LOCKSTAT_H */
+#endif /* !KDTRACE_HOOKS */
+#endif /* _KERNEL */
+#endif /* _SYS_LOCKSTAT_H */
Modified: head/sys/sys/mutex.h
==============================================================================
--- head/sys/sys/mutex.h Sun Jul 19 21:31:52 2015 (r285702)
+++ head/sys/sys/mutex.h Sun Jul 19 22:14:09 2015 (r285703)
@@ -188,8 +188,8 @@ void thread_lock_flags_(struct thread *,
if (!_mtx_obtain_lock((mp), _tid)) \
_mtx_lock_sleep((mp), _tid, (opts), (file), (line)); \
else \
- LOCKSTAT_PROFILE_OBTAIN_LOCK_SUCCESS(LS_MTX_LOCK_ACQUIRE, \
- mp, 0, 0, (file), (line)); \
+ LOCKSTAT_PROFILE_OBTAIN_LOCK_SUCCESS(adaptive__acquire, \
+ mp, 0, 0, file, line); \
} while (0)
/*
@@ -209,8 +209,8 @@ void thread_lock_flags_(struct thread *,
else \
_mtx_lock_spin((mp), _tid, (opts), (file), (line)); \
} else \
- LOCKSTAT_PROFILE_OBTAIN_LOCK_SUCCESS(LS_MTX_SPIN_LOCK_ACQUIRE, \
- mp, 0, 0, (file), (line)); \
+ LOCKSTAT_PROFILE_OBTAIN_LOCK_SUCCESS(spin__acquire, \
+ mp, 0, 0, file, line); \
} while (0)
#else /* SMP */
#define __mtx_lock_spin(mp, tid, opts, file, line) do { \
@@ -231,8 +231,7 @@ void thread_lock_flags_(struct thread *,
uintptr_t _tid = (uintptr_t)(tid); \
\
if ((mp)->mtx_recurse == 0) \
- LOCKSTAT_PROFILE_RELEASE_LOCK(LS_MTX_UNLOCK_RELEASE, \
- (mp)); \
+ LOCKSTAT_PROFILE_RELEASE_LOCK(adaptive__release, mp); \
if (!_mtx_release_lock((mp), _tid)) \
_mtx_unlock_sleep((mp), (opts), (file), (line)); \
} while (0)
@@ -252,21 +251,19 @@ void thread_lock_flags_(struct thread *,
if (mtx_recursed((mp))) \
(mp)->mtx_recurse--; \
else { \
- LOCKSTAT_PROFILE_RELEASE_LOCK(LS_MTX_SPIN_UNLOCK_RELEASE, \
- mp); \
+ LOCKSTAT_PROFILE_RELEASE_LOCK(spin__release, mp); \
_mtx_release_lock_quick((mp)); \
- } \
- spinlock_exit(); \
+ } \
+ spinlock_exit(); \
} while (0)
#else /* SMP */
#define __mtx_unlock_spin(mp) do { \
if (mtx_recursed((mp))) \
(mp)->mtx_recurse--; \
else { \
- LOCKSTAT_PROFILE_RELEASE_LOCK(LS_MTX_SPIN_UNLOCK_RELEASE, \
- mp); \
+ LOCKSTAT_PROFILE_RELEASE_LOCK(spin__release, mp); \
(mp)->mtx_lock = MTX_UNOWNED; \
- } \
+ } \
spinlock_exit(); \
} while (0)
#endif /* SMP */
Modified: head/sys/sys/rwlock.h
==============================================================================
--- head/sys/sys/rwlock.h Sun Jul 19 21:31:52 2015 (r285702)
+++ head/sys/sys/rwlock.h Sun Jul 19 22:14:09 2015 (r285703)
@@ -95,12 +95,12 @@
/* Acquire a write lock. */
#define __rw_wlock(rw, tid, file, line) do { \
uintptr_t _tid = (uintptr_t)(tid); \
- \
+ \
if (!_rw_write_lock((rw), _tid)) \
_rw_wlock_hard((rw), _tid, (file), (line)); \
else \
- LOCKSTAT_PROFILE_OBTAIN_LOCK_SUCCESS(LS_RW_WLOCK_ACQUIRE, \
- rw, 0, 0, (file), (line)); \
+ LOCKSTAT_PROFILE_OBTAIN_LOCK_SUCCESS(rw__acquire, rw, \
+ 0, 0, file, line); \
} while (0)
/* Release a write lock. */
@@ -110,8 +110,7 @@
if ((rw)->rw_recurse) \
(rw)->rw_recurse--; \
else { \
- LOCKSTAT_PROFILE_RELEASE_LOCK(LS_RW_WUNLOCK_RELEASE, \
- (rw)); \
+ LOCKSTAT_PROFILE_RELEASE_LOCK(rw__release, rw); \
if (!_rw_write_unlock((rw), _tid)) \
_rw_wunlock_hard((rw), _tid, (file), (line)); \
} \
Modified: head/sys/sys/sx.h
==============================================================================
--- head/sys/sys/sx.h Sun Jul 19 21:31:52 2015 (r285702)
+++ head/sys/sys/sx.h Sun Jul 19 22:14:09 2015 (r285703)
@@ -153,8 +153,8 @@ __sx_xlock(struct sx *sx, struct thread
if (!atomic_cmpset_acq_ptr(&sx->sx_lock, SX_LOCK_UNLOCKED, tid))
error = _sx_xlock_hard(sx, tid, opts, file, line);
else
- LOCKSTAT_PROFILE_OBTAIN_LOCK_SUCCESS(LS_SX_XLOCK_ACQUIRE,
- sx, 0, 0, file, line);
+ LOCKSTAT_PROFILE_OBTAIN_LOCK_SUCCESS(sx__acquire, sx,
+ 0, 0, file, line);
return (error);
}
@@ -166,7 +166,7 @@ __sx_xunlock(struct sx *sx, struct threa
uintptr_t tid = (uintptr_t)td;
if (sx->sx_recurse == 0)
- LOCKSTAT_PROFILE_RELEASE_LOCK(LS_SX_XUNLOCK_RELEASE, sx);
+ LOCKSTAT_PROFILE_RELEASE_LOCK(sx__release, sx);
if (!atomic_cmpset_rel_ptr(&sx->sx_lock, tid, SX_LOCK_UNLOCKED))
_sx_xunlock_hard(sx, tid, file, line);
}
@@ -182,8 +182,8 @@ __sx_slock(struct sx *sx, int opts, cons
!atomic_cmpset_acq_ptr(&sx->sx_lock, x, x + SX_ONE_SHARER))
error = _sx_slock_hard(sx, opts, file, line);
else
- LOCKSTAT_PROFILE_OBTAIN_LOCK_SUCCESS(LS_SX_SLOCK_ACQUIRE, sx, 0,
- 0, file, line);
+ LOCKSTAT_PROFILE_OBTAIN_LOCK_SUCCESS(sx__acquire, sx,
+ 0, 0, file, line);
return (error);
}
@@ -200,7 +200,7 @@ __sx_sunlock(struct sx *sx, const char *
{
uintptr_t x = sx->sx_lock;
- LOCKSTAT_PROFILE_RELEASE_LOCK(LS_SX_SUNLOCK_RELEASE, sx);
+ LOCKSTAT_PROFILE_RELEASE_LOCK(sx__release, sx);
if (x == (SX_SHARERS_LOCK(1) | SX_LOCK_EXCLUSIVE_WAITERS) ||
!atomic_cmpset_rel_ptr(&sx->sx_lock, x, x - SX_ONE_SHARER))
_sx_sunlock_hard(sx, file, line);
More information about the svn-src-all
mailing list