summaryrefslogtreecommitdiffstats
path: root/sys/kern/kern_lockstat.c
diff options
context:
space:
mode:
authormarkj <markj@FreeBSD.org>2015-07-18 00:22:00 +0000
committermarkj <markj@FreeBSD.org>2015-07-18 00:22:00 +0000
commit90a3119284b43adced3a11a1f3bcd020c3630453 (patch)
tree298c04314a37eabda9a60c929317ede1dd060c25 /sys/kern/kern_lockstat.c
parente853fb249f0a2e510bb3c9a54cda60ba290e5777 (diff)
downloadFreeBSD-src-90a3119284b43adced3a11a1f3bcd020c3630453.zip
FreeBSD-src-90a3119284b43adced3a11a1f3bcd020c3630453.tar.gz
Modify lockstat_nsecs() to just return unless lockstat probes are actually
enabled. The cost of a timecounter read can be quite significant, and the problem became more apparent after r284297, since that change resulted in a call to lockstat_nsecs() for each acquisition of an rwlock read lock. PR: 201642 Reviewed by: avg Tested by: Jason Unovitch MFC after: 3 days Differential Revision: https://reviews.freebsd.org/D3073
Diffstat (limited to 'sys/kern/kern_lockstat.c')
-rw-r--r--sys/kern/kern_lockstat.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/sys/kern/kern_lockstat.c b/sys/kern/kern_lockstat.c
index 1c77312..eb7e177 100644
--- a/sys/kern/kern_lockstat.c
+++ b/sys/kern/kern_lockstat.c
@@ -45,7 +45,7 @@
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)
@@ -53,6 +53,9 @@ lockstat_nsecs(void)
struct bintime bt;
uint64_t ns;
+ if (!lockstat_enabled)
+ return (0);
+
binuptime(&bt);
ns = bt.sec * (uint64_t)1000000000;
ns += ((uint64_t)1000000000 * (uint32_t)(bt.frac >> 32)) >> 32;
OpenPOWER on IntegriCloud