From: eugene.loh@oracle.com
To: dtrace@lists.linux.dev, dtrace-devel@oss.oracle.com
Subject: [PATCH 01/19] Change probes from having lists of clauses to lists of stmts
Date: Thu, 29 Aug 2024 01:25:40 -0400 [thread overview]
Message-ID: <20240829052558.3525-1-eugene.loh@oracle.com> (raw)
From: Eugene Loh <eugene.loh@oracle.com>
Each stmt has a clause and a probe description. Traditionally,
we have added clauses to probes. Further, we have generated an
enabled probe ID for each probe/clause combination, and the
consumer has use the EPID to determine the PRID as well as the
data descriptor for the clause.
In an up-coming patch, we will move to a new scheme, in which a
widened EPID will have the PRID in its upper 32 bits and a stmt
ID in the lower 32 bits. The stmt ID will be used to identify
clauses to call as well as the data descriptor for the clause.
In this patch, change from probes having clauses associated
with them to having stmts.
We move the definition of dt_probe_clause_t in dt_probe.c to
be a definition of dt_probe_stmt_t in dt_impl.h so that the
type will become available for providers that will need it.
Signed-off-by: Eugene Loh <eugene.loh@oracle.com>
---
libdtrace/dt_cg.c | 17 +++++----
libdtrace/dt_impl.h | 5 +++
libdtrace/dt_probe.c | 79 +++++++++++++++++++++++-------------------
libdtrace/dt_probe.h | 12 +++----
libdtrace/dt_program.c | 8 ++---
5 files changed, 66 insertions(+), 55 deletions(-)
diff --git a/libdtrace/dt_cg.c b/libdtrace/dt_cg.c
index 4fab8eed..a7861829 100644
--- a/libdtrace/dt_cg.c
+++ b/libdtrace/dt_cg.c
@@ -844,9 +844,10 @@ typedef struct {
} dt_clause_arg_t;
static int
-dt_cg_call_clause(dtrace_hdl_t *dtp, dt_ident_t *idp, dt_clause_arg_t *arg)
+dt_cg_call_clause(dtrace_hdl_t *dtp, dtrace_stmtdesc_t *sdp, dt_clause_arg_t *arg)
{
dt_irlist_t *dlp = arg->dlp;
+ dt_ident_t *idp = sdp->dtsd_clause;
/*
* if (*dctx.act != act) // ldw %r0, [%r9 + DCTX_ACT]
@@ -874,14 +875,12 @@ dt_cg_call_clause(dtrace_hdl_t *dtp, dt_ident_t *idp, dt_clause_arg_t *arg)
}
void
-dt_cg_tramp_call_clauses(dt_pcb_t *pcb, const dt_probe_t *prp,
- dt_activity_t act)
+dt_cg_tramp_call_clauses(dt_pcb_t *pcb, const dt_probe_t *prp, dt_activity_t act)
{
dt_irlist_t *dlp = &pcb->pcb_ir;
dt_clause_arg_t arg = { dlp, act, pcb->pcb_exitlbl };
- dt_probe_clause_iter(pcb->pcb_hdl, prp,
- (dt_clause_f *)dt_cg_call_clause, &arg);
+ dt_probe_stmt_iter(pcb->pcb_hdl, prp, (dt_stmt_f *)dt_cg_call_clause, &arg);
}
static int
@@ -990,9 +989,10 @@ dt_cg_tramp_epilogue_advance(dt_pcb_t *pcb, dt_activity_t act)
}
static int
-dt_cg_tramp_error_call_clause(dtrace_hdl_t *dtp, dt_ident_t *idp,
- dt_irlist_t *dlp)
+dt_cg_tramp_error_call_clause(dtrace_hdl_t *dtp, dtrace_stmtdesc_t *sdp, dt_irlist_t *dlp)
{
+ dt_ident_t *idp = sdp->dtsd_clause;
+
/*
* dt_error_#(dctx); // mov %r1, %r9
* // call dt_error_#
@@ -1029,8 +1029,7 @@ dt_cg_tramp_error(dt_pcb_t *pcb)
TRACE_REGSET("Trampoline: Begin");
emit(dlp, BPF_MOV_REG(BPF_REG_9, BPF_REG_1));
- dt_probe_clause_iter(dtp, dtp->dt_error,
- (dt_clause_f *)dt_cg_tramp_error_call_clause, dlp);
+ dt_probe_stmt_iter(dtp, dtp->dt_error, (dt_stmt_f *)dt_cg_tramp_error_call_clause, dlp);
emit(dlp, BPF_MOV_IMM(BPF_REG_0, 0));
emit(dlp, BPF_RETURN());
diff --git a/libdtrace/dt_impl.h b/libdtrace/dt_impl.h
index 44dd1415..98fddc23 100644
--- a/libdtrace/dt_impl.h
+++ b/libdtrace/dt_impl.h
@@ -258,6 +258,11 @@ typedef struct dt_percpu_drops {
typedef uint32_t dt_version_t; /* encoded version (see below) */
+typedef struct dt_probe_stmt {
+ dt_list_t list;
+ dtrace_stmtdesc_t *stmt;
+} dt_probe_stmt_t;
+
struct dtrace_hdl {
const dtrace_vector_t *dt_vector; /* library vector, if vectored open */
void *dt_varg; /* vector argument, if vectored open */
diff --git a/libdtrace/dt_probe.c b/libdtrace/dt_probe.c
index ab90d2ed..bb28bbed 100644
--- a/libdtrace/dt_probe.c
+++ b/libdtrace/dt_probe.c
@@ -24,11 +24,6 @@
#include <dt_list.h>
#include <dt_bpf.h>
-typedef struct dt_probe_clause {
- dt_list_t list;
- dt_ident_t *clause;
-} dt_probe_clause_t;
-
typedef struct dt_probe_dependent {
dt_list_t list;
dt_probe_t *probe;
@@ -467,7 +462,7 @@ dt_probe_enable(dtrace_hdl_t *dtp, dt_probe_t *prp)
void
dt_probe_destroy(dt_probe_t *prp)
{
- dt_probe_clause_t *pcp, *pcp_next;
+ dt_probe_stmt_t *psp, *psp_next;
dt_probe_instance_t *pip, *pip_next;
dt_probe_dependent_t *dep, *dep_next;
dtrace_hdl_t *dtp;
@@ -499,9 +494,18 @@ dt_probe_destroy(dt_probe_t *prp)
dt_free(dtp, prp->nargv);
dt_free(dtp, prp->xargv);
- for (pcp = dt_list_next(&prp->clauses); pcp != NULL; pcp = pcp_next) {
- pcp_next = dt_list_next(pcp);
- dt_free(dtp, pcp);
+ for (psp = dt_list_next(&prp->stmts); psp != NULL; psp = psp_next) {
+ psp_next = dt_list_next(psp);
+
+ /*
+ * FIXME? Is there nothing inside we also need to free?
+ *
+ * If psp->stmt was created with dt_probe_error_stmt(), maybe:
+ * dt_ident_t *idp = psp->stmt->dtsd_clause;
+ * dt_iddtor_difo(idp);
+ * dt_ident_destroy(idp);
+ */
+ dt_free(dtp, psp);
}
for (dep = dt_list_next(&prp->dependents); dep != NULL; dep = dep_next) {
@@ -1283,24 +1287,24 @@ dtrace_probe_iter(dtrace_hdl_t *dtp, const dtrace_probedesc_t *pdp,
}
/*
- * Create an ERROR-probe specific copy of a given clause.
+ * Create an ERROR-probe specific copy of a given stmt.
*
- * A modified copy of the clause is necessary because the ERROR probe may share
- * some clauses with other probes, and yet it needs to be handled differently.
+ * A modified copy of the stmt is necessary because the ERROR probe may share
+ * some stmts with other probes, and yet it needs to be handled differently.
*
- * The following modifications are made in the copy of the clause:
- *
- * - it is named dt_error_N where N is taken from the original clause
- * dt_clause_N (which also guarantees uniqueness)
+ * In the copy of the stmt, the clause is named dt_error_N, where N is taken
+ * from the original stmt's dt_clause_N (which also guarantees uniqueness).
*/
-dt_ident_t *
-dt_probe_error_clause(dtrace_hdl_t *dtp, dt_ident_t *idp)
+static dtrace_stmtdesc_t *
+dt_probe_error_stmt(dtrace_hdl_t *dtp, dtrace_stmtdesc_t *sdp)
{
char *name;
int len;
+ dt_ident_t *idp = sdp->dtsd_clause;
dtrace_difo_t *dp = dt_dlib_get_func_difo(dtp, idp);
dt_ident_t *nidp = NULL;
dtrace_difo_t *ndp;
+ dtrace_stmtdesc_t *nsdp = NULL;
/*
* Copy the DIFO.
@@ -1316,7 +1320,6 @@ dt_probe_error_clause(dtrace_hdl_t *dtp, dt_ident_t *idp)
name = dt_alloc(dtp, len);
if (name == NULL)
goto no_mem;
-
snprintf(name, len, "dt_error_%s", idp->di_name + strlen("dt_clause_"));
/*
@@ -1330,7 +1333,12 @@ dt_probe_error_clause(dtrace_hdl_t *dtp, dt_ident_t *idp)
dt_ident_set_data(nidp, ndp);
- return nidp;
+ nsdp = dt_alloc(dtp, sizeof(dtrace_stmtdesc_t));
+ if (nsdp == NULL)
+ goto no_mem;
+ nsdp->dtsd_clause = nidp;
+
+ return nsdp;
no_mem:
if (ndp != NULL)
@@ -1343,40 +1351,39 @@ no_mem:
}
int
-dt_probe_add_clause(dtrace_hdl_t *dtp, dt_probe_t *prp, dt_ident_t *idp)
+dt_probe_add_stmt(dtrace_hdl_t *dtp, dt_probe_t *prp, dtrace_stmtdesc_t *sdp)
{
- dt_probe_clause_t *pcp;
+ dt_probe_stmt_t *psp;
- pcp = dt_zalloc(dtp, sizeof(dt_probe_clause_t));
- if (pcp == NULL)
+ psp = dt_zalloc(dtp, sizeof(dt_probe_stmt_t));
+ if (psp == NULL)
return dt_set_errno(dtp, EDT_NOMEM);
if (prp == dtp->dt_error) {
- pcp->clause = dt_probe_error_clause(dtp, idp);
- if (pcp->clause == NULL) {
- dt_free(dtp, pcp);
+ psp->stmt = dt_probe_error_stmt(dtp, sdp);
+ if (psp->stmt == NULL) {
+ dt_free(dtp, psp);
return 0;
}
} else
- pcp->clause = idp;
+ psp->stmt = sdp;
- dt_list_append(&prp->clauses, pcp);
+ dt_list_append(&prp->stmts, psp);
return 0;
}
int
-dt_probe_clause_iter(dtrace_hdl_t *dtp, const dt_probe_t *prp,
- dt_clause_f *func, void *arg)
+dt_probe_stmt_iter(dtrace_hdl_t *dtp, const dt_probe_t *prp, dt_stmt_f *func, void *arg)
{
- dt_probe_clause_t *pcp;
- int rc;
+ dt_probe_stmt_t *psp;
+ int rc;
assert(func != NULL);
- for (pcp = dt_list_next(&prp->clauses); pcp != NULL;
- pcp = dt_list_next(pcp)) {
- rc = func(dtp, pcp->clause, arg);
+ for (psp = dt_list_next(&prp->stmts); psp != NULL;
+ psp = dt_list_next(psp)) {
+ rc = func(dtp, psp->stmt, arg);
if (rc != 0)
return rc;
diff --git a/libdtrace/dt_probe.h b/libdtrace/dt_probe.h
index b4c1a3e4..2a78cb9c 100644
--- a/libdtrace/dt_probe.h
+++ b/libdtrace/dt_probe.h
@@ -32,7 +32,7 @@ typedef struct dt_probe_instance {
typedef struct dt_probe {
dt_list_t list; /* prev/next in enablings chain */
- dt_list_t clauses; /* clauses to attach */
+ dt_list_t stmts; /* stmts */
dt_list_t dependents; /* dependenct probes to attach */
const dtrace_probedesc_t *desc; /* probe description (id, name) */
dt_provider_t *prov; /* pointer to containing provider */
@@ -86,11 +86,11 @@ typedef int dt_probe_f(dtrace_hdl_t *dtp, dt_probe_t *prp, void *arg);
extern int dt_probe_iter(dtrace_hdl_t *dtp, const dtrace_probedesc_t *pdp,
dt_probe_f *pfunc, dtrace_probe_f *dfunc, void *arg);
-extern int dt_probe_add_clause(dtrace_hdl_t *dtp, dt_probe_t *prp,
- dt_ident_t *idp);
-typedef int dt_clause_f(dtrace_hdl_t *dtp, dt_ident_t *idp, void *arg);
-extern int dt_probe_clause_iter(dtrace_hdl_t *dtp, const dt_probe_t *prp,
- dt_clause_f *func, void *arg);
+extern int dt_probe_add_stmt(dtrace_hdl_t *dtp, dt_probe_t *prp,
+ dtrace_stmtdesc_t *sdp);
+typedef int dt_stmt_f(dtrace_hdl_t *dtp, dtrace_stmtdesc_t *sdp, void *arg);
+extern int dt_probe_stmt_iter(dtrace_hdl_t *dtp, const dt_probe_t *prp,
+ dt_stmt_f *func, void *arg);
extern int dt_probe_add_dependent(dtrace_hdl_t *dtp, dt_probe_t *prp,
dt_probe_t *idprp);
diff --git a/libdtrace/dt_program.c b/libdtrace/dt_program.c
index bdb434e0..afbf7265 100644
--- a/libdtrace/dt_program.c
+++ b/libdtrace/dt_program.c
@@ -139,8 +139,8 @@ dtrace_program_info(dtrace_hdl_t *dtp, dtrace_prog_t *pgp,
}
typedef struct pi_state {
- int *cnt;
- dt_ident_t *idp;
+ int *cnt;
+ dtrace_stmtdesc_t *sdp;
} pi_state_t;
static int
@@ -151,7 +151,7 @@ dt_stmt_probe(dtrace_hdl_t *dtp, dt_probe_t *prp, pi_state_t *st)
dt_probe_info(dtp, prp->desc, &p);
dt_probe_enable(dtp, prp);
- dt_probe_add_clause(dtp, prp, st->idp);
+ dt_probe_add_stmt(dtp, prp, st->sdp);
(*st->cnt)++;
return 0;
@@ -166,7 +166,7 @@ dt_prog_stmt(dtrace_hdl_t *dtp, dtrace_prog_t *pgp, dtrace_stmtdesc_t *sdp,
int rc;
st.cnt = cnt;
- st.idp = sdp->dtsd_clause;
+ st.sdp = sdp;
rc = dt_probe_iter(dtp, pdp, (dt_probe_f *)dt_stmt_probe, NULL, &st);
/*
--
2.43.5
next reply other threads:[~2024-08-29 5:26 UTC|newest]
Thread overview: 44+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-08-29 5:25 eugene.loh [this message]
2024-08-29 5:25 ` [PATCH 02/19] Add a hook for a provider-specific "update" function eugene.loh
2024-08-29 5:25 ` [PATCH 03/19] Widen the EPID to include the PRID eugene.loh
2024-08-29 20:28 ` [DTrace-devel] " Sam James
2024-08-29 20:38 ` Kris Van Hees
2024-08-29 5:25 ` [PATCH 04/19] Eliminate dt_pdesc eugene.loh
2024-09-03 17:47 ` Eugene Loh
2024-08-29 5:25 ` [PATCH 05/19] Add flag to dt_pid_create_probes() eugene.loh
2024-09-18 20:33 ` Kris Van Hees
2024-09-24 20:24 ` Eugene Loh
2024-08-29 5:25 ` [PATCH 06/19] Allow for USDT wildcards eugene.loh
2024-09-17 17:34 ` Eugene Loh
2024-08-29 5:25 ` [PATCH 07/19] Create the BPF usdt_prids map eugene.loh
2024-08-29 5:25 ` [PATCH 08/19] Support multiple overlying probes in the uprobe trampoline eugene.loh
2024-10-24 2:42 ` Kris Van Hees
2024-10-24 13:52 ` [DTrace-devel] " Kris Van Hees
2024-10-24 23:30 ` Eugene Loh
2024-10-25 0:14 ` Kris Van Hees
2024-08-29 5:25 ` [PATCH 09/19] Use usdt_prids map to call clauses conditionally for USDT probes eugene.loh
2024-08-29 5:25 ` [PATCH 10/19] Remove the is-enabled provider eugene.loh
2024-10-24 15:18 ` Kris Van Hees
2024-10-26 1:13 ` Eugene Loh
2024-08-29 5:25 ` [PATCH 11/19] Support USDT wildcard provider descriptions eugene.loh
2024-08-29 5:25 ` [PATCH 12/19] Increase size of BPF probes map eugene.loh
2024-08-29 20:30 ` [DTrace-devel] " Sam James
2024-10-08 22:15 ` Eugene Loh
2024-08-29 5:25 ` [PATCH 13/19] Get rid of relocatable EPID, dt_nextepid, and dt_ddesc[] eugene.loh
2024-09-03 17:49 ` Eugene Loh
2024-08-29 5:25 ` [PATCH 14/19] Ignore clauses in USDT trampoline if we know they are impossible eugene.loh
2024-08-29 5:25 ` [PATCH 15/19] Ignore clauses: some clauses are impossible regardless of uprp eugene.loh
2024-08-29 20:31 ` [DTrace-devel] " Sam James
2024-09-03 19:54 ` Eugene Loh
2024-09-03 20:10 ` Kris Van Hees
2024-08-29 5:25 ` [PATCH 16/19] Ignore clauses: use underlying probe's function information eugene.loh
2024-10-24 16:52 ` Kris Van Hees
2024-08-29 5:25 ` [PATCH 17/19] test: Add a pid-USDT test eugene.loh
2024-08-29 20:32 ` [DTrace-devel] " Sam James
2024-10-04 4:49 ` Eugene Loh
2024-10-04 5:51 ` Sam James
2024-08-29 5:25 ` [PATCH 18/19] test: Add a lazy USDT test eugene.loh
2024-09-28 2:11 ` Eugene Loh
2024-08-29 5:25 ` [PATCH 19/19] test: Add another USDT open/close test eugene.loh
2024-10-24 17:01 ` Kris Van Hees
2024-09-18 14:18 ` [PATCH 01/19] Change probes from having lists of clauses to lists of stmts Kris Van Hees
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240829052558.3525-1-eugene.loh@oracle.com \
--to=eugene.loh@oracle.com \
--cc=dtrace-devel@oss.oracle.com \
--cc=dtrace@lists.linux.dev \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox