Fix two bugs in DTrace:
* when the process exits, remove the associated USDT probes * when the process forks, duplicate the USDT probes. Sponsored by: The FreeBSD Foundation
This commit is contained in:
parent
4946fa6791
commit
d3555b6fc2
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=212357
@ -9218,7 +9218,6 @@ dtrace_difo_init(dtrace_difo_t *dp, dtrace_vstate_t *vstate)
|
||||
dtrace_difo_hold(dp);
|
||||
}
|
||||
|
||||
#if defined(sun)
|
||||
static dtrace_difo_t *
|
||||
dtrace_difo_duplicate(dtrace_difo_t *dp, dtrace_vstate_t *vstate)
|
||||
{
|
||||
@ -9262,7 +9261,6 @@ dtrace_difo_duplicate(dtrace_difo_t *dp, dtrace_vstate_t *vstate)
|
||||
dtrace_difo_init(new, vstate);
|
||||
return (new);
|
||||
}
|
||||
#endif
|
||||
|
||||
static void
|
||||
dtrace_difo_destroy(dtrace_difo_t *dp, dtrace_vstate_t *vstate)
|
||||
@ -14615,12 +14613,16 @@ dtrace_helpers_create(proc_t *p)
|
||||
}
|
||||
|
||||
#if defined(sun)
|
||||
static void
|
||||
dtrace_helpers_destroy(void)
|
||||
static
|
||||
#endif
|
||||
void
|
||||
dtrace_helpers_destroy(proc_t *p)
|
||||
{
|
||||
dtrace_helpers_t *help;
|
||||
dtrace_vstate_t *vstate;
|
||||
#if defined(sun)
|
||||
proc_t *p = curproc;
|
||||
#endif
|
||||
int i;
|
||||
|
||||
mutex_enter(&dtrace_lock);
|
||||
@ -14707,7 +14709,10 @@ dtrace_helpers_destroy(void)
|
||||
mutex_exit(&dtrace_lock);
|
||||
}
|
||||
|
||||
static void
|
||||
#if defined(sun)
|
||||
static
|
||||
#endif
|
||||
void
|
||||
dtrace_helpers_duplicate(proc_t *from, proc_t *to)
|
||||
{
|
||||
dtrace_helpers_t *help, *newhelp;
|
||||
@ -14788,7 +14793,6 @@ dtrace_helpers_duplicate(proc_t *from, proc_t *to)
|
||||
if (hasprovs)
|
||||
dtrace_helper_provider_register(to, newhelp, NULL);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(sun)
|
||||
/*
|
||||
|
@ -456,6 +456,16 @@ fasttrap_fork(proc_t *p, proc_t *cp)
|
||||
#if defined(sun)
|
||||
ASSERT(p->p_dtrace_count > 0);
|
||||
#else
|
||||
if (p->p_dtrace_helpers) {
|
||||
/*
|
||||
* dtrace_helpers_duplicate() allocates memory.
|
||||
*/
|
||||
PROC_UNLOCK(p);
|
||||
PROC_UNLOCK(cp);
|
||||
dtrace_helpers_duplicate(p, cp);
|
||||
PROC_LOCK(cp);
|
||||
PROC_LOCK(p);
|
||||
}
|
||||
/*
|
||||
* This check is purposely here instead of in kern_fork.c because,
|
||||
* for legal resons, we cannot include the dtrace_cddl.h header
|
||||
@ -539,6 +549,10 @@ fasttrap_exec_exit(proc_t *p)
|
||||
* static probes are handled by the meta-provider remove entry point.
|
||||
*/
|
||||
fasttrap_provider_retire(p->p_pid, FASTTRAP_PID_NAME, 0);
|
||||
#if !defined(sun)
|
||||
if (p->p_dtrace_helpers)
|
||||
dtrace_helpers_destroy(p);
|
||||
#endif
|
||||
PROC_LOCK(p);
|
||||
}
|
||||
|
||||
|
@ -2289,6 +2289,11 @@ extern int dtrace_blksuword32(uintptr_t, uint32_t *, int);
|
||||
extern void dtrace_getfsr(uint64_t *);
|
||||
#endif
|
||||
|
||||
#if !defined(sun)
|
||||
extern void dtrace_helpers_duplicate(proc_t *, proc_t *);
|
||||
extern void dtrace_helpers_destroy(proc_t *);
|
||||
#endif
|
||||
|
||||
#define DTRACE_CPUFLAG_ISSET(flag) \
|
||||
(cpu_core[curcpu].cpuc_dtrace_flags & (flag))
|
||||
|
||||
|
@ -671,15 +671,6 @@ fork1(td, flags, pages, procp)
|
||||
p2->p_pfsflags = p1->p_pfsflags;
|
||||
}
|
||||
|
||||
#ifdef KDTRACE_HOOKS
|
||||
/*
|
||||
* Tell the DTrace fasttrap provider about the new process
|
||||
* if it has registered an interest.
|
||||
*/
|
||||
if (dtrace_fasttrap_fork)
|
||||
dtrace_fasttrap_fork(p1, p2);
|
||||
#endif
|
||||
|
||||
/*
|
||||
* This begins the section where we must prevent the parent
|
||||
* from being swapped.
|
||||
@ -744,6 +735,21 @@ fork1(td, flags, pages, procp)
|
||||
PROC_SLOCK(p2);
|
||||
p2->p_state = PRS_NORMAL;
|
||||
PROC_SUNLOCK(p2);
|
||||
#ifdef KDTRACE_HOOKS
|
||||
/*
|
||||
* Tell the DTrace fasttrap provider about the new process
|
||||
* if it has registered an interest. We have to do this only after
|
||||
* p_state is PRS_NORMAL since the fasttrap module will use pfind()
|
||||
* later on.
|
||||
*/
|
||||
if (dtrace_fasttrap_fork) {
|
||||
PROC_LOCK(p1);
|
||||
PROC_LOCK(p2);
|
||||
dtrace_fasttrap_fork(p1, p2);
|
||||
PROC_UNLOCK(p2);
|
||||
PROC_UNLOCK(p1);
|
||||
}
|
||||
#endif
|
||||
|
||||
/*
|
||||
* If RFSTOPPED not requested, make child runnable and add to
|
||||
|
Loading…
Reference in New Issue
Block a user