[DTrace-devel] [PATCH 1/6] Reflect that the dvars map is not just for TLS variable storage

Kris Van Hees kris.van.hees at oracle.com
Mon Mar 7 19:49:45 UTC 2022


The 'dvars' BPF map is used for all dynamic variable storage.  While TLS
variables are currently the only implemented type of dynamic variables,
associative array elements will use this same storage area once they are
fully implemented.

Signed-off-by: Kris Van Hees <kris.van.hees at oracle.com>
---
 libdtrace/dt_bpf.c   | 18 +++++++++---------
 libdtrace/dt_ident.c |  4 ++--
 libdtrace/dt_impl.h  |  4 ++--
 3 files changed, 13 insertions(+), 13 deletions(-)

diff --git a/libdtrace/dt_bpf.c b/libdtrace/dt_bpf.c
index 635c74cb..7e560ab2 100644
--- a/libdtrace/dt_bpf.c
+++ b/libdtrace/dt_bpf.c
@@ -218,10 +218,10 @@ populate_probes_map(dtrace_hdl_t *dtp, int fd)
  * - gvars:	Global variables map.  This is a global map with a singleton
  *		element (key 0) addressed by variable offset.
  * - dvars:	Dynamic variables map.  This is a global hash map indexed with
- *		a unique numeric identifier for each variable per thread.  The
- *		value of each element is sized to accomodate the largest thread
- *		local ariable type found across all programsn the tracing
- *		session..
+ *		a unique numeric identifier for each dynamic variable (thread
+ *		local variable or associative array element).  The value of
+ *		each element is sized to accomodate the largest value type
+ *		all programs in the tracing session.
  * - lvars:	Local variables map.  This is a per-CPU map with a singleton
  *		element (key 0) addressed by variable offset.
  */
@@ -249,9 +249,9 @@ dt_bpf_gmap_create(dtrace_hdl_t *dtp)
 	/* Determine sizes for global, local, and TLS maps. */
 	gvarsz = P2ROUNDUP(dt_idhash_datasize(dtp->dt_globals), 8);
 	lvarsz = P2ROUNDUP(dtp->dt_maxlvaralloc, 8);
-	if (dtp->dt_maxtlslen)
+	if (dtp->dt_maxdvarsize)
 		dvarc = (dtp->dt_options[DTRACEOPT_DYNVARSIZE] /
-			 dtp->dt_maxtlslen) + 1;
+			 dtp->dt_maxdvarsize) + 1;
 
 	/* Create global maps as long as there are no errors. */
 	dtp->dt_stmap_fd = create_gmap(dtp, "state", BPF_MAP_TYPE_ARRAY,
@@ -354,15 +354,15 @@ dt_bpf_gmap_create(dtrace_hdl_t *dtp)
 
 	if (dvarc > 0) {
 		int	fd;
-		char	dflt[dtp->dt_maxtlslen];
+		char	dflt[dtp->dt_maxdvarsize];
 
 		fd = create_gmap(dtp, "dvars", BPF_MAP_TYPE_HASH,
-				 sizeof(uint64_t), dtp->dt_maxtlslen, dvarc);
+				 sizeof(uint64_t), dtp->dt_maxdvarsize, dvarc);
 		if (fd == -1)
 			return -1;	/* dt_errno is set for us */
 
 		/* Initialize the default value (key = 0). */
-		memset(dflt, 0, dtp->dt_maxtlslen);
+		memset(dflt, 0, dtp->dt_maxdvarsize);
 		dt_bpf_map_update(fd, &key, &dflt);
 	}
 
diff --git a/libdtrace/dt_ident.c b/libdtrace/dt_ident.c
index 78e11cc4..6d8a8efa 100644
--- a/libdtrace/dt_ident.c
+++ b/libdtrace/dt_ident.c
@@ -1018,8 +1018,8 @@ dt_ident_set_storage(dt_ident_t *idp, uint_t alignment, uint_t size)
 		dhp->dh_nextoff = idp->di_offset + size;
 	} else {
 		idp->di_offset = 0;
-		if (size > dtp->dt_maxtlslen)
-			dtp->dt_maxtlslen = size;
+		if (size > dtp->dt_maxdvarsize)
+			dtp->dt_maxdvarsize = size;
 	}
 
 	idp->di_size = size;
diff --git a/libdtrace/dt_impl.h b/libdtrace/dt_impl.h
index f6bb63b8..f738ebeb 100644
--- a/libdtrace/dt_impl.h
+++ b/libdtrace/dt_impl.h
@@ -1,6 +1,6 @@
 /*
  * Oracle Linux DTrace.
- * Copyright (c) 2010, 2021, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2010, 2022, Oracle and/or its affiliates. All rights reserved.
  * Licensed under the Universal Permissive License v 1.0 as shown at
  * http://oss.oracle.com/licenses/upl.
  */
@@ -292,7 +292,7 @@ struct dtrace_hdl {
 	dt_strtab_t *dt_ccstab;	/* global string table (during compilation) */
 	uint_t dt_strlen;	/* global string table (runtime) size */
 	uint_t dt_maxreclen;	/* largest record size across programs */
-	uint_t dt_maxtlslen;	/* largest TLS variable across programs */
+	uint_t dt_maxdvarsize;	/* largest dynamic variable across programs */
 	uint_t dt_maxlvaralloc;	/* largest lvar alloc across pcbs */
 	dt_tstring_t *dt_tstrings; /* temporary string slots */
 	dt_list_t dt_modlist;	/* linked list of dt_module_t's */
-- 
2.34.1




More information about the DTrace-devel mailing list