[DTrace-devel] [PATCH 03/04] rawtp: report lockmem issues when determining rawtp argument count

Kris Van Hees kris.van.hees at oracle.com
Thu Nov 23 03:22:40 UTC 2023


On Wed, Nov 22, 2023 at 10:01:37PM -0500, Eugene Loh via DTrace-devel wrote:
> On 11/22/23 10:49, Kris Van Hees via DTrace-devel wrote:
> 
> > diff --git a/libdtrace/dt_prov_rawtp.c b/libdtrace/dt_prov_rawtp.c
> > @@ -181,7 +181,9 @@ static int probe_info(dtrace_hdl_t *dtp, const dt_probe_t *prp,
> >   		dif.dtdo_len = 2;
> >   		bpf_fd = dt_bpf_prog_load(dt_rawtp.prog_type, &dif, 0, NULL, 0);
> > -		if (bpf_fd == -1)
> > +		if (bpf_fd == -EPERM)
> 
> Is that right?  I think the only negative value is -1.  Might it be that you
> want to test errno==+EPERM?  And do we know that EPERM really means
> lockmem?  Or are we simply guessing that that's the most likely explanation?

It is actually correct, or as correct as we can get.  A result value of
-EPERM is almost always a lockmem issue, based on the reading of the kernel
code that relates to this.  And -EPERM *is* -1.

But other error codes can be returned also, for other failures.

> How about a test?  E.g.,

Nearly impossible because with the rest of the patch series, this code will
not be triggered except on really older kernels.  And honestly, it is quite
possible that support for raw tracepoints and BTF came about at roughtly the
same time, such that the support for this older approach may not even be
really needed.

So it is in the end a bit of a safety net.

> # dtrace -lv > out.default
> # dtrace -xlockmem=1 -lv > out.small
> # wc -l out.*
>  1445230 out.default
>  1380822 out.small
>  2826052 total
> # grep lockmem out.small
> # grep Cannot out.small
> #
> 
> Are things working as expected?
> 
> > +			return dt_bpf_lockmem_error(dtp, "Cannot retrieve argument count");
> > +		else if (bpf_fd < 0)
> >   			continue;
> >   		rtp_fd = dt_bpf_raw_tracepoint_open(prp->desc->prb, bpf_fd);
> >   		close(bpf_fd);
> 
> _______________________________________________
> 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