aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRuslan Bukin <br@FreeBSD.org>2015-07-01 14:09:59 +0000
committerRuslan Bukin <br@FreeBSD.org>2015-07-01 14:09:59 +0000
commit0ff41755cd3cedc806eb0b9eeb3e4315cc119ecb (patch)
tree6199dfbc4b92c4270c1395f02b3508e80a596b45
parent27e54fb59e46cc309e9bdbd0697cafb11938c23c (diff)
downloadsrc-0ff41755cd3cedc806eb0b9eeb3e4315cc119ecb.tar.gz
src-0ff41755cd3cedc806eb0b9eeb3e4315cc119ecb.zip
Add a central location for exclusion checks. We check
here if function is excluded from FBT instrumentation. Reviewed by: andrew, emaste, markj Differential Revision: https://reviews.freebsd.org/D2899
Notes
Notes: svn path=/head/; revision=285004
-rw-r--r--sys/cddl/dev/fbt/fbt.c31
-rw-r--r--sys/cddl/dev/fbt/fbt.h1
2 files changed, 32 insertions, 0 deletions
diff --git a/sys/cddl/dev/fbt/fbt.c b/sys/cddl/dev/fbt/fbt.c
index c347f2d0d4c9..00ab7cf3264a 100644
--- a/sys/cddl/dev/fbt/fbt.c
+++ b/sys/cddl/dev/fbt/fbt.c
@@ -111,6 +111,37 @@ static struct cdev *fbt_cdev;
static int fbt_probetab_size;
static int fbt_verbose = 0;
+int
+fbt_excluded(const char *name)
+{
+
+ if (strncmp(name, "dtrace_", 7) == 0 &&
+ strncmp(name, "dtrace_safe_", 12) != 0) {
+ /*
+ * Anything beginning with "dtrace_" may be called
+ * from probe context unless it explicitly indicates
+ * that it won't be called from probe context by
+ * using the prefix "dtrace_safe_".
+ */
+ return (1);
+ }
+
+ /* Exclude some internal functions */
+ if (name[0] == '_' && name[1] == '_')
+ return (1);
+
+ /*
+ * When DTrace is built into the kernel we need to exclude
+ * the FBT functions from instrumentation.
+ */
+#ifndef _KLD_MODULE
+ if (strncmp(name, "fbt_", 4) == 0)
+ return (1);
+#endif
+
+ return (0);
+}
+
static void
fbt_doubletrap(void)
{
diff --git a/sys/cddl/dev/fbt/fbt.h b/sys/cddl/dev/fbt/fbt.h
index 1522b40b08fe..643858317cd5 100644
--- a/sys/cddl/dev/fbt/fbt.h
+++ b/sys/cddl/dev/fbt/fbt.h
@@ -58,6 +58,7 @@ int fbt_invop(uintptr_t, uintptr_t *, uintptr_t);
void fbt_patch_tracepoint(fbt_probe_t *, fbt_patchval_t);
int fbt_provide_module_function(struct linker_file *, int,
struct linker_symval *, void *);
+int fbt_excluded(const char *name);
extern dtrace_provider_id_t fbt_id;
extern fbt_probe_t **fbt_probetab;