svn commit: r326134 - head/sys/cddl/contrib/opensolaris/uts/common/dtrace
Mark Johnston
markj at FreeBSD.org
Thu Nov 23 14:29:09 UTC 2017
Author: markj
Date: Thu Nov 23 14:29:07 2017
New Revision: 326134
URL: https://svnweb.freebsd.org/changeset/base/326134
Log:
Duplicate helpers after disabling inherited tracepoints during a fork.
We may create probes in the nascent child process, so we first need to
ensure that any inherited tracepoints are first removed. Otherwise the
probe sites will not be in the state expected by fasttrap, and it won't
be able to enable the probes.
MFC after: 2 weeks
Modified:
head/sys/cddl/contrib/opensolaris/uts/common/dtrace/fasttrap.c
Modified: head/sys/cddl/contrib/opensolaris/uts/common/dtrace/fasttrap.c
==============================================================================
--- head/sys/cddl/contrib/opensolaris/uts/common/dtrace/fasttrap.c Thu Nov 23 14:28:14 2017 (r326133)
+++ head/sys/cddl/contrib/opensolaris/uts/common/dtrace/fasttrap.c Thu Nov 23 14:29:07 2017 (r326134)
@@ -601,8 +601,8 @@ fasttrap_fork(proc_t *p, proc_t *cp)
pid_t ppid = p->p_pid;
int i;
-#ifdef illumos
ASSERT(curproc == p);
+#ifdef illumos
ASSERT(p->p_proc_flag & P_PR_LOCK);
#else
PROC_LOCK_ASSERT(p, MA_OWNED);
@@ -610,26 +610,15 @@ fasttrap_fork(proc_t *p, proc_t *cp)
#ifdef illumos
ASSERT(p->p_dtrace_count > 0);
#else
- if (p->p_dtrace_helpers) {
- /*
- * dtrace_helpers_duplicate() allocates memory.
- */
- _PHOLD(cp);
- PROC_UNLOCK(p);
- PROC_UNLOCK(cp);
- dtrace_helpers_duplicate(p, cp);
- PROC_LOCK(cp);
- PROC_LOCK(p);
- _PRELE(cp);
- }
/*
* This check is purposely here instead of in kern_fork.c because,
* for legal resons, we cannot include the dtrace_cddl.h header
* inside kern_fork.c and insert if-clause there.
*/
- if (p->p_dtrace_count == 0)
+ if (p->p_dtrace_count == 0 && p->p_dtrace_helpers == NULL)
return;
#endif
+
ASSERT(cp->p_dtrace_count == 0);
/*
@@ -658,6 +647,8 @@ fasttrap_fork(proc_t *p, proc_t *cp)
_PHOLD(cp);
PROC_UNLOCK(cp);
PROC_UNLOCK(p);
+ if (p->p_dtrace_count == 0)
+ goto dup_helpers;
#endif
/*
@@ -711,6 +702,9 @@ fasttrap_fork(proc_t *p, proc_t *cp)
mutex_enter(&cp->p_lock);
sprunlock(cp);
#else
+dup_helpers:
+ if (p->p_dtrace_helpers != NULL)
+ dtrace_helpers_duplicate(p, cp);
PROC_LOCK(p);
PROC_LOCK(cp);
_PRELE(cp);
More information about the svn-src-all
mailing list