summaryrefslogtreecommitdiffstats
path: root/sys/kern/kern_lockstat.c
diff options
context:
space:
mode:
authormarkj <markj@FreeBSD.org>2015-07-21 17:16:37 +0000
committermarkj <markj@FreeBSD.org>2015-07-21 17:16:37 +0000
commit84c91edd5356f5693f0ecd74d787e98b52fee0b4 (patch)
treee3d69a4db0089a008c7c2596149b6277d1473fbf /sys/kern/kern_lockstat.c
parent10c80a84dab9d6dfc505ebcda9ca49b6caa78f90 (diff)
downloadFreeBSD-src-84c91edd5356f5693f0ecd74d787e98b52fee0b4.zip
FreeBSD-src-84c91edd5356f5693f0ecd74d787e98b52fee0b4.tar.gz
MFC r285663, r285664, r285667:
Ensure that locstat_nsecs() has no effect when lockstat probes are not enabled or when the profiled lock carries the LO_NOPROFILE flag. PR: 201642, 201517 Approved by: re (gjb) Tested by: Jason Unovitch
Diffstat (limited to 'sys/kern/kern_lockstat.c')
-rw-r--r--sys/kern/kern_lockstat.c12
1 files changed, 9 insertions, 3 deletions
diff --git a/sys/kern/kern_lockstat.c b/sys/kern/kern_lockstat.c
index 1f35893..3a65fa9 100644
--- a/sys/kern/kern_lockstat.c
+++ b/sys/kern/kern_lockstat.c
@@ -36,9 +36,10 @@
#ifdef KDTRACE_HOOKS
-#include <sys/time.h>
#include <sys/types.h>
+#include <sys/lock.h>
#include <sys/lockstat.h>
+#include <sys/time.h>
/*
* The following must match the type definition of dtrace_probe. It is
@@ -47,14 +48,19 @@
uint32_t lockstat_probemap[LS_NPROBES];
void (*lockstat_probe_func)(uint32_t, uintptr_t, uintptr_t,
uintptr_t, uintptr_t, uintptr_t);
-
+int lockstat_enabled = 0;
uint64_t
-lockstat_nsecs(void)
+lockstat_nsecs(struct lock_object *lo)
{
struct bintime bt;
uint64_t ns;
+ if (!lockstat_enabled)
+ return (0);
+ if ((lo->lo_flags & LO_NOPROFILE) != 0)
+ return (0);
+
binuptime(&bt);
ns = bt.sec * (uint64_t)1000000000;
ns += ((uint64_t)1000000000 * (uint32_t)(bt.frac >> 32)) >> 32;
OpenPOWER on IntegriCloud