[DTrace-devel] [PATCH 13/19] Get rid of relocatable EPID, dt_nextepid, and dt_ddesc[]

eugene.loh at oracle.com eugene.loh at oracle.com
Thu Aug 29 05:25:52 UTC 2024


From: Eugene Loh <eugene.loh at oracle.com>

We no longer have to assign an EPID value during relocation.  So we
no longer need dt_nextepid, dt_maxprobe, dt_ddesc[], dt_epid_add(),
or dt_epid_destroy() or to track an EPID during linking.

Signed-off-by: Eugene Loh <eugene.loh at oracle.com>
---
 libdtrace/dt_bpf.h   | 47 +++++++++++++++++-----------------
 libdtrace/dt_cc.c    | 20 +++++----------
 libdtrace/dt_dlibs.c |  1 -
 libdtrace/dt_impl.h  |  5 ----
 libdtrace/dt_map.c   | 61 --------------------------------------------
 libdtrace/dt_open.c  |  3 ---
 6 files changed, 29 insertions(+), 108 deletions(-)

diff --git a/libdtrace/dt_bpf.h b/libdtrace/dt_bpf.h
index 5b2df264..5981eb0e 100644
--- a/libdtrace/dt_bpf.h
+++ b/libdtrace/dt_bpf.h
@@ -32,30 +32,29 @@ extern "C" {
 					(dtp)->dt_bpffeatures |= (feat); \
 				} while (0)
 
-#define DT_CONST_EPID			1
-#define DT_CONST_PRID			2
-#define DT_CONST_CLID			3
-#define DT_CONST_ARGC			4
-#define DT_CONST_STBSZ			5
-#define DT_CONST_STRSZ			6
-#define DT_CONST_STKSIZ			7
-#define DT_CONST_BOOTTM			8
-#define DT_CONST_NSPEC			9
-#define DT_CONST_NCPUS			10
-#define DT_CONST_PC			11
-#define DT_CONST_TUPSZ			12
-#define DT_CONST_TASK_PID		13
-#define DT_CONST_TASK_TGID		14
-#define DT_CONST_TASK_REAL_PARENT	15
-#define DT_CONST_TASK_COMM		16
-#define DT_CONST_MUTEX_OWNER		17
-#define DT_CONST_RWLOCK_CNTS		18
-#define DT_CONST_DCTX_RODATA		19
-#define DT_CONST_RODATA_OFF		20
-#define DT_CONST_RODATA_SIZE		21
-#define DT_CONST_ZERO_OFF		22
-#define DT_CONST_STACK_OFF		23
-#define DT_CONST_STACK_SKIP		24
+#define DT_CONST_PRID			1
+#define DT_CONST_CLID			2
+#define DT_CONST_ARGC			3
+#define DT_CONST_STBSZ			4
+#define DT_CONST_STRSZ			5
+#define DT_CONST_STKSIZ			6
+#define DT_CONST_BOOTTM			7
+#define DT_CONST_NSPEC			8
+#define DT_CONST_NCPUS			9
+#define DT_CONST_PC			10
+#define DT_CONST_TUPSZ			11
+#define DT_CONST_TASK_PID		12
+#define DT_CONST_TASK_TGID		13
+#define DT_CONST_TASK_REAL_PARENT	14
+#define DT_CONST_TASK_COMM		15
+#define DT_CONST_MUTEX_OWNER		16
+#define DT_CONST_RWLOCK_CNTS		17
+#define DT_CONST_DCTX_RODATA		18
+#define DT_CONST_RODATA_OFF		19
+#define DT_CONST_RODATA_SIZE		20
+#define DT_CONST_ZERO_OFF		21
+#define DT_CONST_STACK_OFF		22
+#define DT_CONST_STACK_SKIP		23
 
 #define DT_BPF_LOG_SIZE_DEFAULT	(UINT32_MAX >> 8)
 #define DT_BPF_LOG_SIZE_SMALL	4096
diff --git a/libdtrace/dt_cc.c b/libdtrace/dt_cc.c
index 2510db86..b801c87a 100644
--- a/libdtrace/dt_cc.c
+++ b/libdtrace/dt_cc.c
@@ -949,7 +949,7 @@ static int get_boottime() {
 static int
 dt_link_construct(dtrace_hdl_t *dtp, const dt_probe_t *prp, dtrace_difo_t *dp,
 		  dt_ident_t *idp, const dtrace_difo_t *sdp, uint_t *pcp,
-		  uint_t *rcp, uint_t *vcp, dtrace_epid_t epid, uint_t clid)
+		  uint_t *rcp, uint_t *vcp, uint_t clid)
 {
 	uint_t			pc = *pcp;
 	uint_t			rc = *rcp;
@@ -1030,7 +1030,6 @@ dt_link_construct(dtrace_hdl_t *dtp, const dt_probe_t *prp, dtrace_difo_t *dp,
 	for (; len != 0; len--, rp++, nrp++) {
 		const char	*name = dt_difo_getstr(sdp, rp->dofr_name);
 		dtrace_difo_t	*rdp;
-		dtrace_epid_t	nepid;
 		int		ipc;
 
 		idp = dt_dlib_get_sym(dtp, name);
@@ -1045,9 +1044,6 @@ dt_link_construct(dtrace_hdl_t *dtp, const dt_probe_t *prp, dtrace_difo_t *dp,
 			}
 
 			switch (idp->di_id) {
-			case DT_CONST_EPID:
-				nrp->dofr_data = epid;
-				continue;
 			case DT_CONST_PRID:
 				nrp->dofr_data = prp->desc->id;
 				continue;
@@ -1212,13 +1208,10 @@ dt_link_construct(dtrace_hdl_t *dtp, const dt_probe_t *prp, dtrace_difo_t *dp,
 			rdp = dt_dlib_get_func_difo(dtp, idp);
 			if (rdp == NULL)
 				return -1;
-			if (rdp->dtdo_ddesc != NULL) {
-				nepid = dt_epid_add(dtp, rdp->dtdo_ddesc);
-				clid++;
-			} else
-				nepid = 0;
+			if (rdp->dtdo_ddesc != NULL)
+				clid++;               /* FIXME: dump this? */
 			ipc = dt_link_construct(dtp, prp, dp, idp, rdp, pcp,
-						rcp, vcp, nepid, clid);
+						rcp, vcp, clid);
 			if (ipc == -1)
 				return -1;
 
@@ -1259,7 +1252,7 @@ dt_link_resolve(dtrace_hdl_t *dtp, dtrace_difo_t *dp)
 			continue;
 
 		/*
-		 * We are only relocating constants (EPID and ARGC) and call
+		 * We are only relocating constants and call
 		 * instructions to functions that have been linked in.
 		 */
 		switch (idp->di_kind) {
@@ -1332,8 +1325,7 @@ dt_link(dtrace_hdl_t *dtp, const dt_probe_t *prp, dtrace_difo_t *dp,
 	 */
 	insc = relc = varc = 0;
 
-	rc = dt_link_construct(dtp, prp, fdp, idp, dp, &insc, &relc, &varc, 0,
-			       0);
+	rc = dt_link_construct(dtp, prp, fdp, idp, dp, &insc, &relc, &varc, 0);
 	dt_dlib_reset(dtp, B_FALSE);
 	if (rc == -1)
 		goto fail;
diff --git a/libdtrace/dt_dlibs.c b/libdtrace/dt_dlibs.c
index 060cf28b..140ac9a6 100644
--- a/libdtrace/dt_dlibs.c
+++ b/libdtrace/dt_dlibs.c
@@ -74,7 +74,6 @@ static const dt_ident_t		dt_bpf_symbols[] = {
 	DT_BPF_SYMBOL(tuples, DT_IDENT_PTR),
 
 	/* BPF internal identifiers */
-	DT_BPF_SYMBOL_ID(EPID, DT_IDENT_SCALAR, DT_CONST_EPID),
 	DT_BPF_SYMBOL_ID(PRID, DT_IDENT_SCALAR, DT_CONST_PRID),
 	DT_BPF_SYMBOL_ID(CLID, DT_IDENT_SCALAR, DT_CONST_CLID),
 	DT_BPF_SYMBOL_ID(ARGC, DT_IDENT_SCALAR, DT_CONST_ARGC),
diff --git a/libdtrace/dt_impl.h b/libdtrace/dt_impl.h
index 2378235c..3fa2b9d7 100644
--- a/libdtrace/dt_impl.h
+++ b/libdtrace/dt_impl.h
@@ -343,9 +343,6 @@ struct dtrace_hdl {
 	ctf_id_t dt_type_symaddr; /* cached CTF identifier for _symaddr type */
 	ctf_id_t dt_type_usymaddr; /* cached CTF ident. for _usymaddr type */
 	ctf_id_t dt_type_void;	/* cached CTF identifier for void type */
-	dtrace_epid_t dt_nextepid; /* next enabled probe ID to assign */
-	size_t dt_maxprobe;	/* max enabled probe ID */
-	dtrace_datadesc_t **dt_ddesc; /* probe data descriptions */
 	size_t dt_maxagg;	/* max aggregation ID */
 	dtrace_aggdesc_t **dt_adesc; /* aggregation descriptions */
 	struct dt_aggregate *dt_aggregate; /* aggregate */
@@ -779,9 +776,7 @@ extern dtrace_datadesc_t *dt_datadesc_hold(dtrace_datadesc_t *ddp);
 extern void dt_datadesc_release(dtrace_hdl_t *, dtrace_datadesc_t *);
 extern dtrace_datadesc_t *dt_datadesc_create(dtrace_hdl_t *);
 extern int dt_datadesc_finalize(dtrace_hdl_t *, dtrace_datadesc_t *);
-extern dtrace_epid_t dt_epid_add(dtrace_hdl_t *, dtrace_datadesc_t *);
 extern int dt_epid_lookup(dtrace_hdl_t *, dtrace_epid_t, dtrace_datadesc_t **);
-extern void dt_epid_destroy(dtrace_hdl_t *);
 typedef void (*dt_cg_gap_f)(dt_pcb_t *, int);
 extern uint32_t dt_rec_add(dtrace_hdl_t *, dt_cg_gap_f, dtrace_actkind_t,
 			   uint32_t, uint16_t, dt_pfargv_t *, uint64_t);
diff --git a/libdtrace/dt_map.c b/libdtrace/dt_map.c
index 9011da5d..26f101e4 100644
--- a/libdtrace/dt_map.c
+++ b/libdtrace/dt_map.c
@@ -85,46 +85,6 @@ dt_datadesc_finalize(dtrace_hdl_t *dtp, dtrace_datadesc_t *ddp)
 	return 0;
 }
 
-/*
- * Associate a probe data description and probe description with an enabled
- * probe ID.  This means that the given ID refers to the program matching the
- * probe data description being attached to the probe that matches the probe
- * description.
- */
-dtrace_epid_t
-dt_epid_add(dtrace_hdl_t *dtp, dtrace_datadesc_t *ddp)
-{
-	dtrace_id_t	max = dtp->dt_maxprobe;
-	dtrace_epid_t	epid;
-
-	epid = dtp->dt_nextepid++;
-	if (epid >= max || dtp->dt_ddesc == NULL) {
-		dtrace_id_t		nmax = max ? (max << 1) : 2;
-		dtrace_datadesc_t	**nddesc;
-
-		nddesc = dt_calloc(dtp, nmax, sizeof(void *));
-		if (nddesc == NULL)
-			return dt_set_errno(dtp, EDT_NOMEM);
-
-		if (dtp->dt_ddesc != NULL) {
-			size_t	osize = max * sizeof(void *);
-
-			memcpy(nddesc, dtp->dt_ddesc, osize);
-			dt_free(dtp, dtp->dt_ddesc);
-		}
-
-		dtp->dt_ddesc = nddesc;
-		dtp->dt_maxprobe = nmax;
-	}
-
-	if (dtp->dt_ddesc[epid] != NULL)
-		return epid;
-
-	dtp->dt_ddesc[epid] = dt_datadesc_hold(ddp);
-
-	return epid;
-}
-
 int
 dt_epid_lookup(dtrace_hdl_t *dtp, dtrace_epid_t epid, dtrace_datadesc_t **ddp)
 {
@@ -140,27 +100,6 @@ dt_epid_lookup(dtrace_hdl_t *dtp, dtrace_epid_t epid, dtrace_datadesc_t **ddp)
 	return (*ddp == NULL) ? -1 : 0;
 }
 
-void
-dt_epid_destroy(dtrace_hdl_t *dtp)
-{
-	size_t i;
-
-	assert((dtp->dt_ddesc != NULL && dtp->dt_maxprobe > 0) ||
-	       (dtp->dt_ddesc == NULL && dtp->dt_maxprobe == 0));
-
-	for (i = 0; i < dtp->dt_maxprobe; i++) {
-		if (dtp->dt_ddesc[i] == NULL)
-			continue;
-
-		dt_datadesc_release(dtp, dtp->dt_ddesc[i]);
-	}
-
-	free(dtp->dt_ddesc);
-	dtp->dt_ddesc = NULL;
-	dtp->dt_nextepid = 0;
-	dtp->dt_maxprobe = 0;
-}
-
 uint32_t
 dt_rec_add(dtrace_hdl_t *dtp, dt_cg_gap_f gapf, dtrace_actkind_t kind,
 	   uint32_t size, uint16_t alignment, dt_pfargv_t *pfp, uint64_t arg)
diff --git a/libdtrace/dt_open.c b/libdtrace/dt_open.c
index 8ae6cdfa..848141dd 100644
--- a/libdtrace/dt_open.c
+++ b/libdtrace/dt_open.c
@@ -739,8 +739,6 @@ dt_vopen(int version, int flags, int *errp,
 	dt_proc_hash_create(dtp);
 	dt_proc_signal_init(dtp);
 	dtp->dt_proc_fd = eventfd(0, EFD_CLOEXEC | EFD_NONBLOCK);
-	dtp->dt_nextepid = 1;
-	dtp->dt_maxprobe = 0;
 	if (dt_aggregate_init(dtp) == -1)
 		return set_open_errno(dtp, errp, dtrace_errno(dtp));
 	dtp->dt_vmax = DT_VERS_LATEST;
@@ -1303,7 +1301,6 @@ dtrace_close(dtrace_hdl_t *dtp)
 	if (dtp->dt_poll_fd != -1)
 		close(dtp->dt_poll_fd);
 
-	dt_epid_destroy(dtp);
 	dt_aggid_destroy(dtp);
 	dt_buffered_destroy(dtp);
 	dt_aggregate_destroy(dtp);
-- 
2.43.5




More information about the DTrace-devel mailing list