summaryrefslogtreecommitdiffstats
path: root/sys/kern/kern_lockstat.c
diff options
context:
space:
mode:
authormarkj <markj@FreeBSD.org>2015-07-19 22:14:09 +0000
committermarkj <markj@FreeBSD.org>2015-07-19 22:14:09 +0000
commitfb4cb70b7d3b8771f051726851f280a5684263db (patch)
treef4dbaff3eee7463b0bc4a1e309dee981d6aaba59 /sys/kern/kern_lockstat.c
parent34ac7bd4d308634de1d2248b083ab98fc3d7ad28 (diff)
downloadFreeBSD-src-fb4cb70b7d3b8771f051726851f280a5684263db.zip
FreeBSD-src-fb4cb70b7d3b8771f051726851f280a5684263db.tar.gz
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
Diffstat (limited to 'sys/kern/kern_lockstat.c')
-rw-r--r--sys/kern/kern_lockstat.c53
1 files changed, 33 insertions, 20 deletions
diff --git a/sys/kern/kern_lockstat.c b/sys/kern/kern_lockstat.c
index b948d15..bedd108 100644
--- a/sys/kern/kern_lockstat.c
+++ b/sys/kern/kern_lockstat.c
@@ -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 */
OpenPOWER on IntegriCloud