Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 1 Jul 2015 14:09:59 +0000 (UTC)
From:      Ruslan Bukin <br@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r285004 - head/sys/cddl/dev/fbt
Message-ID:  <201507011409.t61E9xfX046922@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: br
Date: Wed Jul  1 14:09:59 2015
New Revision: 285004
URL: https://svnweb.freebsd.org/changeset/base/285004

Log:
  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

Modified:
  head/sys/cddl/dev/fbt/fbt.c
  head/sys/cddl/dev/fbt/fbt.h

Modified: head/sys/cddl/dev/fbt/fbt.c
==============================================================================
--- head/sys/cddl/dev/fbt/fbt.c	Wed Jul  1 13:59:26 2015	(r285003)
+++ head/sys/cddl/dev/fbt/fbt.c	Wed Jul  1 14:09:59 2015	(r285004)
@@ -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)
 {

Modified: head/sys/cddl/dev/fbt/fbt.h
==============================================================================
--- head/sys/cddl/dev/fbt/fbt.h	Wed Jul  1 13:59:26 2015	(r285003)
+++ head/sys/cddl/dev/fbt/fbt.h	Wed Jul  1 14:09:59 2015	(r285004)
@@ -58,6 +58,7 @@ int	fbt_invop(uintptr_t, uintptr_t *, ui
 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;



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201507011409.t61E9xfX046922>