1
0
mirror of https://git.FreeBSD.org/src.git synced 2024-12-31 12:13:10 +00:00

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.

Discussed with:	markj
This commit is contained in:
Mateusz Guzik 2017-10-22 20:22:23 +00:00
parent cc1307b67f
commit 5a17c5524f
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=324869
3 changed files with 14 additions and 1 deletions

View File

@ -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;

View File

@ -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

View File

@ -80,6 +80,8 @@
#include <sys/cdefs.h>
#include <sys/linker_set.h>
extern volatile bool sdt_probes_enabled;
#ifndef KDTRACE_HOOKS
#define SDT_PROVIDER_DEFINE(prov)
@ -161,10 +163,12 @@ SET_DECLARE(sdt_argtypes_set, struct sdt_argtype);
extern struct sdt_probe sdt_##prov##_##mod##_##func##_##name[1]
#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) \