summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormjg <mjg@FreeBSD.org>2018-01-02 00:11:56 +0000
committermjg <mjg@FreeBSD.org>2018-01-02 00:11:56 +0000
commitea78e9d88f2e3e927dfc146cad3b311b12292cc3 (patch)
tree000ac294c20b9477e97e25a663a79911678b4f53
parent075f7f627bb213a5cb1c0805bac208ef1e3f9391 (diff)
downloadFreeBSD-src-ea78e9d88f2e3e927dfc146cad3b311b12292cc3.zip
FreeBSD-src-ea78e9d88f2e3e927dfc146cad3b311b12292cc3.tar.gz
MFC r324867,r324869:
sdt: whack unused SDT_PROBE_ENABLED ============= sdt: make all sdt probe sites test one variable This saves on cache misses at the expense of a slight grow of .text. Note this is a bandaid for lack of hotpatching.
-rw-r--r--sys/cddl/dev/sdt/sdt.c8
-rw-r--r--sys/kern/kern_sdt.c1
-rw-r--r--sys/sys/sdt.h10
3 files changed, 14 insertions, 5 deletions
diff --git a/sys/cddl/dev/sdt/sdt.c b/sys/cddl/dev/sdt/sdt.c
index 26a41f0..e9d0118 100644
--- a/sys/cddl/dev/sdt/sdt.c
+++ b/sys/cddl/dev/sdt/sdt.c
@@ -76,6 +76,8 @@ static void sdt_kld_unload_try(void *, struct linker_file *, int *);
static MALLOC_DEFINE(M_SDT, "SDT", "DTrace SDT providers");
+static int sdt_probes_enabled_count;
+
static dtrace_pattr_t sdt_attr = {
{ DTRACE_STABILITY_EVOLVING, DTRACE_STABILITY_EVOLVING, DTRACE_CLASS_COMMON },
{ DTRACE_STABILITY_PRIVATE, DTRACE_STABILITY_PRIVATE, DTRACE_CLASS_UNKNOWN },
@@ -208,6 +210,9 @@ sdt_enable(void *arg __unused, dtrace_id_t id, void *parg)
probe->sdtp_lf->nenabled++;
if (strcmp(probe->prov->name, "lockstat") == 0)
lockstat_enabled++;
+ sdt_probes_enabled_count++;
+ if (sdt_probes_enabled_count == 1)
+ sdt_probes_enabled = true;
}
static void
@@ -217,6 +222,9 @@ sdt_disable(void *arg __unused, dtrace_id_t id, void *parg)
KASSERT(probe->sdtp_lf->nenabled > 0, ("no probes enabled"));
+ sdt_probes_enabled_count--;
+ if (sdt_probes_enabled_count == 0)
+ sdt_probes_enabled = false;
if (strcmp(probe->prov->name, "lockstat") == 0)
lockstat_enabled--;
probe->id = 0;
diff --git a/sys/kern/kern_sdt.c b/sys/kern/kern_sdt.c
index 5191a88..ebbf04e 100644
--- a/sys/kern/kern_sdt.c
+++ b/sys/kern/kern_sdt.c
@@ -37,6 +37,7 @@ SDT_PROVIDER_DEFINE(sdt);
* dtrace_probe() when it loads.
*/
sdt_probe_func_t sdt_probe_func = sdt_probe_stub;
+volatile bool __read_frequently sdt_probes_enabled;
/*
* This is a stub for probe calls in case kernel DTrace support isn't
diff --git a/sys/sys/sdt.h b/sys/sys/sdt.h
index c680ea8..6771bf9 100644
--- a/sys/sys/sdt.h
+++ b/sys/sys/sdt.h
@@ -80,13 +80,14 @@
#include <sys/cdefs.h>
#include <sys/linker_set.h>
+extern volatile bool sdt_probes_enabled;
+
#ifndef KDTRACE_HOOKS
#define SDT_PROVIDER_DEFINE(prov)
#define SDT_PROVIDER_DECLARE(prov)
#define SDT_PROBE_DEFINE(prov, mod, func, name)
#define SDT_PROBE_DECLARE(prov, mod, func, name)
-#define SDT_PROBE_ENABLED(prov, mod, func, name) 0
#define SDT_PROBE(prov, mod, func, name, arg0, arg1, arg2, arg3, arg4)
#define SDT_PROBE_ARGTYPE(prov, mod, func, name, num, type, xtype)
@@ -161,14 +162,13 @@ SET_DECLARE(sdt_argtypes_set, struct sdt_argtype);
#define SDT_PROBE_DECLARE(prov, mod, func, name) \
extern struct sdt_probe sdt_##prov##_##mod##_##func##_##name[1]
-#define SDT_PROBE_ENABLED(prov, mod, func, name) \
- __predict_false((sdt_##prov##_##mod##_##func##_##name->id))
-
#define SDT_PROBE(prov, mod, func, name, arg0, arg1, arg2, arg3, arg4) do { \
- if (__predict_false(sdt_##prov##_##mod##_##func##_##name->id)) \
+ if (__predict_false(sdt_probes_enabled)) { \
+ if (__predict_false(sdt_##prov##_##mod##_##func##_##name->id)) \
(*sdt_probe_func)(sdt_##prov##_##mod##_##func##_##name->id, \
(uintptr_t) arg0, (uintptr_t) arg1, (uintptr_t) arg2, \
(uintptr_t) arg3, (uintptr_t) arg4); \
+ } \
} while (0)
#define SDT_PROBE_ARGTYPE(prov, mod, func, name, num, type, xtype) \
OpenPOWER on IntegriCloud