[DTrace-devel] [PATCH 01/12] proc: use a rawtp for the proc:::exit probe

Kris Van Hees kris.van.hees at oracle.com
Sat Jan 6 04:17:23 UTC 2024


On Fri, Jan 05, 2024 at 02:30:00PM -0500, Eugene Loh via DTrace-devel wrote:
> Reviewed-by: Eugene Loh <eugene.loh at oracle.com>
> 
> Do we need an audit to find more rawtp opportunities in existing code?

I think that would be worthwhile.

But note that this patch isn't really for convenience of using rawtp over
fbt.  It solves the real problem of the fbt probe not being availabnle in
newer kernels.

> Also...
> 
> On 1/5/24 00:24, Kris Van Hees via DTrace-devel wrote:
> > diff --git a/libdtrace/dt_prov_proc.c b/libdtrace/dt_prov_proc.c
> > @@ -204,10 +204,10 @@ static void enable(dtrace_hdl_t *dtp, dt_probe_t *prp)
> >   	} else if (strcmp(prp->desc->prb, "exit") == 0 ||
> >   		   strcmp(prp->desc->prb, "lwp-exit") == 0) {
> >   		pd.id = DTRACE_IDNONE;
> > -		pd.prv = "fbt";
> > +		pd.prv = "rawtp";
> >   		pd.mod = "";
> > -		pd.fun = "taskstats_exit";
> > -		pd.prb = "entry";
> > +		pd.fun = "";
> > +		pd.prb = "sched_process_exit";
> >   		uprp = dt_probe_lookup(dtp, &pd);
> >   		assert(uprp != NULL);
> > @@ -323,7 +323,7 @@ static int trampoline(dt_pcb_t *pcb, uint_t exitlbl)
> >   		int		rc = 0;
> >   		uint_t		lbl_out = dt_irlist_label(dlp);
> > -		emit(dlp,  BPF_LOAD(BPF_DW, BPF_REG_0, BPF_REG_7, DMST_ARG(1)));
> > +		emit(dlp,  BPF_LOAD(BPF_DW, BPF_REG_0, BPF_REG_7, DMST_ARG(0)));
> 
> I'm confused on this one.  We're switching from
>         taskstats_exit(tsk, group_dead);
> to
>         trace_sched_process_exit(tsk);
> So it seems we want arg0 in either case.  So the patch is right, but it
> means (iiuc) that there was a bug in the code.  So if a bug is being fixed,
> doesn't that mean there should be a test change?

Sadly, no.  It means we do not have adequate testing for all cases.

> >   		emit(dlp,  BPF_BRANCH_IMM(BPF_JEQ, BPF_REG_0, 0, exitlbl));
> >   		if (!cfp)
> > @@ -342,9 +342,9 @@ static int trampoline(dt_pcb_t *pcb, uint_t exitlbl)
> >   		/*
> >   		 * This implements:
> >   		 *	%r1 = tsk->exit_code
> > -		 *	if ((%r1 & 0x7f) == 0) args[0] = 1;
> > -		 *	else if (%r1 & 0x80) args[0] = 3;
> > -		 *	else args[0] = 2;
> > +		 *	if ((%r1 & 0x7f) == 0) args[0] = 1;	// CLD_EXITED
> > +		 *	else if (%r1 & 0x80) args[0] = 3;	// CLD_DUMPED
> > +		 *	else args[0] = 2;			// CLD_KILLED
> >   		 */
> >   		emit(dlp,  BPF_MOV_REG(BPF_REG_1, BPF_REG_FP));
> >   		emit(dlp,  BPF_ALU64_IMM(BPF_ADD, BPF_REG_1, DT_STK_SPILL(0)));
> 
> _______________________________________________
> DTrace-devel mailing list
> DTrace-devel at oss.oracle.com
> https://oss.oracle.com/mailman/listinfo/dtrace-devel



More information about the DTrace-devel mailing list