svn commit: r291963 - in head: cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/usdt sys/cddl/contrib/opensolaris/uts/common/dtrace sys/cddl/contrib/opensolaris/uts/common/sys

Mark Johnston markj at FreeBSD.org
Mon Dec 7 21:49:35 UTC 2015


Author: markj
Date: Mon Dec  7 21:49:32 2015
New Revision: 291963
URL: https://svnweb.freebsd.org/changeset/base/291963

Log:
  MFV r289003:
  6271 dtrace caused excessive fork time
  
  Author: Bryan Cantrill <bryan at joyent.com>
  Reviewed by: Adam Leventhal <ahl at delphix.com>
  Reviewed by: Dan McDonald <danmcd at omniti.com>
  Reviewed by: Richard Lowe <richlowe at richlowe.net>
  Approved by: Gordon Ross <gwr at nexenta.com>
  
  illumos/illumos-gate at 7bd3c1d12d0c764e1517c3aca62c634409356764

Added:
  head/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/usdt/tst.sameprovmulti.ksh
     - copied, changed from r289003, vendor/illumos/dist/cmd/dtrace/test/tst/common/usdt/tst.sameprovmulti.ksh
  head/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/usdt/tst.sameprovmulti.ksh.out
     - copied unchanged from r289003, vendor/illumos/dist/cmd/dtrace/test/tst/common/usdt/tst.sameprovmulti.ksh.out
Modified:
  head/sys/cddl/contrib/opensolaris/uts/common/dtrace/dtrace.c
  head/sys/cddl/contrib/opensolaris/uts/common/dtrace/fasttrap.c
  head/sys/cddl/contrib/opensolaris/uts/common/sys/dtrace.h
Directory Properties:
  head/cddl/contrib/opensolaris/   (props changed)
  head/sys/cddl/contrib/opensolaris/   (props changed)

Copied and modified: head/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/usdt/tst.sameprovmulti.ksh (from r289003, vendor/illumos/dist/cmd/dtrace/test/tst/common/usdt/tst.sameprovmulti.ksh)
==============================================================================
--- vendor/illumos/dist/cmd/dtrace/test/tst/common/usdt/tst.sameprovmulti.ksh	Thu Oct  8 04:29:39 2015	(r289003, copy source)
+++ head/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/usdt/tst.sameprovmulti.ksh	Mon Dec  7 21:49:32 2015	(r291963)
@@ -59,14 +59,14 @@ provider doogle {
 };
 EOF
 
-	gcc -m32 -c $oogle.c
+	cc -c $oogle.c
 
 	if [ $? -ne 0 ]; then
 		print -u2 "failed to compile $oogle.c"
 		exit 1
 	fi
 
-	$dtrace -G -32 -s $oogle.d $oogle.o -o $oogle.d.o
+	$dtrace -G -s $oogle.d $oogle.o -o $oogle.d.o
 
 	if [ $? -ne 0 ]; then
 		print -u2 "failed to process $oogle.d"
@@ -79,7 +79,7 @@ done
 
 echo "}" >> test.c
 
-gcc -m32 -o test test.c $objs
+cc -o test test.c $objs
 
 if [ $? -ne 0 ]; then
 	print -u2 "failed to compile test.c"
@@ -95,5 +95,5 @@ if [ $? -ne 0 ]; then
 fi
 
 cd /
-/usr/bin/rm -rf $DIR
+rm -rf $DIR
 exit 0

Copied: head/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/usdt/tst.sameprovmulti.ksh.out (from r289003, vendor/illumos/dist/cmd/dtrace/test/tst/common/usdt/tst.sameprovmulti.ksh.out)
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/usdt/tst.sameprovmulti.ksh.out	Mon Dec  7 21:49:32 2015	(r291963, copy of r289003, vendor/illumos/dist/cmd/dtrace/test/tst/common/usdt/tst.sameprovmulti.ksh.out)
@@ -0,0 +1,4 @@
+bagnoogle  1
+cockoogle  1
+stalloogle 1
+

Modified: head/sys/cddl/contrib/opensolaris/uts/common/dtrace/dtrace.c
==============================================================================
--- head/sys/cddl/contrib/opensolaris/uts/common/dtrace/dtrace.c	Mon Dec  7 21:44:05 2015	(r291962)
+++ head/sys/cddl/contrib/opensolaris/uts/common/dtrace/dtrace.c	Mon Dec  7 21:49:32 2015	(r291963)
@@ -15749,8 +15749,8 @@ dtrace_helper_provider_add(dof_helper_t 
 	 * Check to make sure this isn't a duplicate.
 	 */
 	for (i = 0; i < help->dthps_nprovs; i++) {
-		if (dofhp->dofhp_dof ==
-		    help->dthps_provs[i]->dthp_prov.dofhp_dof)
+		if (dofhp->dofhp_addr ==
+		    help->dthps_provs[i]->dthp_prov.dofhp_addr)
 			return (EALREADY);
 	}
 
@@ -16110,7 +16110,14 @@ dtrace_helper_slurp(dof_hdr_t *dof, dof_
 	dtrace_enabling_destroy(enab);
 
 	if (dhp != NULL && nprovs > 0) {
+		/*
+		 * Now that this is in-kernel, we change the sense of the
+		 * members:  dofhp_dof denotes the in-kernel copy of the DOF
+		 * and dofhp_addr denotes the address at user-level.
+		 */
+		dhp->dofhp_addr = dhp->dofhp_dof;
 		dhp->dofhp_dof = (uint64_t)(uintptr_t)dof;
+
 		if (dtrace_helper_provider_add(dhp, help, gen) == 0) {
 			mutex_exit(&dtrace_lock);
 			dtrace_helper_provider_register(p, help, dhp);

Modified: head/sys/cddl/contrib/opensolaris/uts/common/dtrace/fasttrap.c
==============================================================================
--- head/sys/cddl/contrib/opensolaris/uts/common/dtrace/fasttrap.c	Mon Dec  7 21:44:05 2015	(r291962)
+++ head/sys/cddl/contrib/opensolaris/uts/common/dtrace/fasttrap.c	Mon Dec  7 21:49:32 2015	(r291963)
@@ -2117,6 +2117,18 @@ fasttrap_meta_provide(void *arg, dtrace_
 	return (provider);
 }
 
+/*
+ * We know a few things about our context here:  we know that the probe being
+ * created doesn't already exist (DTrace won't load DOF at the same address
+ * twice, even if explicitly told to do so) and we know that we are
+ * single-threaded with respect to the meta provider machinery. Knowing that
+ * this is a new probe and that there is no way for us to race with another
+ * operation on this provider allows us an important optimization: we need not
+ * lookup a probe before adding it.  Saving this lookup is important because
+ * this code is in the fork path for processes with USDT probes, and lookups
+ * here are potentially very expensive because of long hash conflicts on
+ * module, function and name (DTrace doesn't hash on provider name).
+ */
 /*ARGSUSED*/
 static void
 fasttrap_meta_create_probe(void *arg, void *parg,
@@ -2153,19 +2165,6 @@ fasttrap_meta_create_probe(void *arg, vo
 			return;
 	}
 
-	/*
-	 * Grab the creation lock to ensure consistency between calls to
-	 * dtrace_probe_lookup() and dtrace_probe_create() in the face of
-	 * other threads creating probes.
-	 */
-	mutex_enter(&provider->ftp_cmtx);
-
-	if (dtrace_probe_lookup(provider->ftp_provid, dhpb->dthpb_mod,
-	    dhpb->dthpb_func, dhpb->dthpb_name) != 0) {
-		mutex_exit(&provider->ftp_cmtx);
-		return;
-	}
-
 	ntps = dhpb->dthpb_noffs + dhpb->dthpb_nenoffs;
 	ASSERT(ntps > 0);
 
@@ -2173,7 +2172,6 @@ fasttrap_meta_create_probe(void *arg, vo
 
 	if (fasttrap_total > fasttrap_max) {
 		atomic_add_32(&fasttrap_total, -ntps);
-		mutex_exit(&provider->ftp_cmtx);
 		return;
 	}
 
@@ -2237,8 +2235,6 @@ fasttrap_meta_create_probe(void *arg, vo
 	 */
 	pp->ftp_id = dtrace_probe_create(provider->ftp_provid, dhpb->dthpb_mod,
 	    dhpb->dthpb_func, dhpb->dthpb_name, FASTTRAP_OFFSET_AFRAMES, pp);
-
-	mutex_exit(&provider->ftp_cmtx);
 }
 
 /*ARGSUSED*/

Modified: head/sys/cddl/contrib/opensolaris/uts/common/sys/dtrace.h
==============================================================================
--- head/sys/cddl/contrib/opensolaris/uts/common/sys/dtrace.h	Mon Dec  7 21:44:05 2015	(r291962)
+++ head/sys/cddl/contrib/opensolaris/uts/common/sys/dtrace.h	Mon Dec  7 21:49:32 2015	(r291963)
@@ -2205,12 +2205,18 @@ extern void dtrace_probe(dtrace_id_t, ui
  *
  * 1.2.4  Caller's context
  *
- *   dtms_create_probe() is called from either ioctl() or module load context.
- *   The DTrace framework is locked in such a way that meta providers may not
- *   register or unregister. This means that the meta provider cannot call
- *   dtrace_meta_register() or dtrace_meta_unregister(). However, the context is
- *   such that the provider may (and is expected to) call provider-related
- *   DTrace provider APIs including dtrace_probe_create().
+ *   dtms_create_probe() is called from either ioctl() or module load context
+ *   in the context of a newly-created provider (that is, a provider that
+ *   is a result of a call to dtms_provide_pid()). The DTrace framework is
+ *   locked in such a way that meta providers may not register or unregister,
+ *   such that no other thread can call into a meta provider operation and that
+ *   atomicity is assured with respect to meta provider operations across
+ *   dtms_provide_pid() and subsequent calls to dtms_create_probe().
+ *   The context is thus effectively single-threaded with respect to the meta
+ *   provider, and that the meta provider cannot call dtrace_meta_register()
+ *   or dtrace_meta_unregister(). However, the context is such that the
+ *   provider may (and is expected to) call provider-related DTrace provider
+ *   APIs including dtrace_probe_create().
  *
  * 1.3  void *dtms_provide_pid(void *arg, dtrace_meta_provider_t *mprov,
  *	      pid_t pid)


More information about the svn-src-head mailing list