[DTrace-devel] [PATCH 7/7] Report an error to the consumer if a probe cannot be enabled
Kris Van Hees
kris.van.hees at oracle.com
Wed Dec 7 03:17:48 UTC 2022
On Tue, Dec 06, 2022 at 06:00:11PM -0500, Eugene Loh via DTrace-devel wrote:
> Reviewed-by: Eugene Loh <eugene.loh at oracle.com>
> One question below:
>
> On 12/6/22 16:50, Kris Van Hees via DTrace-devel wrote:
> > Some probes (esp. uprobes) appear to be useable, but yet the kernel
> > tracing subsystem reports a failure when trying to enable the probe.
> > It need not be a fatal error (esp. when probing a set of probes based
> > on a wildcard specification), but it should get reported.
> >
> > Signed-off-by: Kris Van Hees <kris.van.hees at oracle.com>
> > ---
> > libdtrace/dt_bpf.c | 20 +++++++++++++++++---
> > libdtrace/dt_provider_tp.c | 4 ++--
> > 2 files changed, 19 insertions(+), 5 deletions(-)
> >
> > diff --git a/libdtrace/dt_bpf.c b/libdtrace/dt_bpf.c
> > index 92cbc4ed..a9536511 100644
> > --- a/libdtrace/dt_bpf.c
> > +++ b/libdtrace/dt_bpf.c
> > @@ -1044,7 +1044,8 @@ dt_bpf_load_progs(dtrace_hdl_t *dtp, uint_t cflags)
> > */
> > for (prp = dt_list_next(&dtp->dt_enablings); prp != NULL;
> > prp = dt_list_next(prp)) {
> > - int fd;
> > + int fd;
> > + int rc = -1;
> > /* Already done. */
> > if (prp == dtp->dt_error)
> > @@ -1070,9 +1071,22 @@ dt_bpf_load_progs(dtrace_hdl_t *dtp, uint_t cflags)
> > dt_difo_free(dtp, dp);
> > - if (!prp->prov->impl->attach ||
> > - prp->prov->impl->attach(dtp, prp, fd) < 0)
> > + if (prp->prov->impl->attach)
> > + rc = prp->prov->impl->attach(dtp, prp, fd);
> > +
> > + if (rc == -ENOTSUPP) {
> > + char *s;
> > +
> > + if (asprintf(&s, "Failed to enable %s:%s:%s:%s",
> > + prp->desc->prv, prp->desc->mod,
> > + prp->desc->fun, prp->desc->prb) == -1)
> > + return dt_set_errno(dtp, EDT_ENABLING_ERR);
> > + dt_handle_rawerr(dtp, s);
> > + free(s);
>
> Should there also be a close(fd) here?
Oops, yes.
> > + } else if (rc < 0) {
> > + close(fd);
> > return dt_set_errno(dtp, EDT_ENABLING_ERR);
> > + }
> > }
> > return 0;
> > diff --git a/libdtrace/dt_provider_tp.c b/libdtrace/dt_provider_tp.c
> > index fdd7f9c5..7388bb94 100644
> > --- a/libdtrace/dt_provider_tp.c
> > +++ b/libdtrace/dt_provider_tp.c
> > @@ -74,13 +74,13 @@ dt_tp_attach(dtrace_hdl_t *dtp, tp_probe_t *tpp, int bpf_fd)
> > fd = perf_event_open(&attr, -1, 0, -1, 0);
> > if (fd < 0)
> > - return dt_set_errno(dtp, errno);
> > + return -errno;
> > tpp->event_fd = fd;
> > }
> > if (ioctl(tpp->event_fd, PERF_EVENT_IOC_SET_BPF, bpf_fd) < 0)
> > - return dt_set_errno(dtp, errno);
> > + return -errno;
> > return 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