[DTrace-devel] [PATCH 01/12] proc: use a rawtp for the proc:::exit probe
Eugene Loh
eugene.loh at oracle.com
Fri Jan 5 19:30:00 UTC 2024
Reviewed-by: Eugene Loh <eugene.loh at oracle.com>
Do we need an audit to find more rawtp opportunities in existing code?
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?
> 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)));
More information about the DTrace-devel
mailing list