[DTrace-devel] [PATCH v2 03/04] rawtp: report lockmem issues when determining rawtp argument count
Kris Van Hees
kris.van.hees at oracle.com
Thu Nov 30 15:59:06 UTC 2023
No test is added for this condition because any such test would have to
be removed again in the next patch, where a better way to retrieve rawtp
argument info will be introduced. This code will remain as a fallback,
but we do not have any way to programmatically force it to be used.
Signed-off-by: Kris Van Hees <kris.van.hees at oracle.com>
---
libdtrace/dt_bpf.c | 2 +-
libdtrace/dt_bpf.h | 2 ++
libdtrace/dt_cc.c | 3 +++
libdtrace/dt_prov_rawtp.c | 4 +++-
4 files changed, 9 insertions(+), 2 deletions(-)
diff --git a/libdtrace/dt_bpf.c b/libdtrace/dt_bpf.c
index 8034af48..730f8d8e 100644
--- a/libdtrace/dt_bpf.c
+++ b/libdtrace/dt_bpf.c
@@ -62,7 +62,7 @@ dt_bpf_error(dtrace_hdl_t *dtp, const char *fmt, ...)
return dt_set_errno(dtp, EDT_BPF);
}
-static int
+int
dt_bpf_lockmem_error(dtrace_hdl_t *dtp, const char *msg)
{
return dt_bpf_error(dtp, "%s:\n"
diff --git a/libdtrace/dt_bpf.h b/libdtrace/dt_bpf.h
index 125a250d..9a8e9492 100644
--- a/libdtrace/dt_bpf.h
+++ b/libdtrace/dt_bpf.h
@@ -50,6 +50,8 @@ extern int perf_event_open(struct perf_event_attr *attr, pid_t pid, int cpu,
extern int bpf(enum bpf_cmd cmd, union bpf_attr *attr);
extern int dt_bpf_gmap_create(struct dtrace_hdl *);
+extern int dt_bpf_lockmem_error(struct dtrace_hdl *dtp, const char *msg);
+
extern int dt_bpf_map_lookup(int fd, const void *key, void *val);
extern int dt_bpf_map_next_key(int fd, const void *key, void *nxt);
extern int dt_bpf_map_update(int fd, const void *key, const void *val);
diff --git a/libdtrace/dt_cc.c b/libdtrace/dt_cc.c
index a42109f1..887e0be1 100644
--- a/libdtrace/dt_cc.c
+++ b/libdtrace/dt_cc.c
@@ -307,6 +307,9 @@ dt_setcontext(dtrace_hdl_t *dtp, const dtrace_probedesc_t *pdp)
pdp->prb);
}
+ if (err == EDT_BPF)
+ (yypcb->pcb_jmpbuf, err);
+
if (err != EDT_NOPROBE && err != EDT_UNSTABLE && err != 0)
xyerror(D_PDESC_INVAL, "%s\n", dtrace_errmsg(dtp, err));
diff --git a/libdtrace/dt_prov_rawtp.c b/libdtrace/dt_prov_rawtp.c
index 24104dd5..93a30bb7 100644
--- 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 < 0)
+ if (bpf_fd == -EPERM)
+ 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);
--
2.42.0
More information about the DTrace-devel
mailing list