All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 13/20] libdtrace: use module address index for aggregation
@ 2026-10-30 19:36 Kris Van Hees
  2026-11-06 13:07 ` Nick Alcock
  0 siblings, 1 reply; 2+ messages in thread
From: Kris Van Hees @ 2026-10-30 19:36 UTC (permalink / raw)
  To: dtrace, dtrace-devel

Share dt_module_by_addr() with dt_aggregate_mod() to avoid scanning every
module when normalizing aggregation keys. Preserve the representative module
address and reuse the indexed lookup, including overlap precedence and its
allocation-failure fallback.
---
 libdtrace/dt_aggregate.c | 38 ++++++++++----------------------------
 libdtrace/dt_module.c    |  2 +-
 libdtrace/dt_module.h    |  1 +
 3 files changed, 12 insertions(+), 29 deletions(-)

diff --git a/libdtrace/dt_aggregate.c b/libdtrace/dt_aggregate.c
index 1fc8294d..f04c39b6 100644
--- a/libdtrace/dt_aggregate.c
+++ b/libdtrace/dt_aggregate.c
@@ -1,6 +1,6 @@
 /*
  * Oracle Linux DTrace.
- * Copyright (c) 2008, 2025, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2008, 2026, 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.
  */
@@ -18,6 +18,7 @@
 #include <port.h>
 #include <dt_aggregate.h>
 #include <dt_bpf.h>
+#include <dt_module.h>
 
 typedef struct dt_ahashent {
 	struct dt_ahashent *dtahe_prev;		/* prev on hash chain */
@@ -394,34 +395,15 @@ dt_aggregate_mod(dtrace_hdl_t *dtp, uint64_t *addr)
 		return;
 	}
 
-	for (dmp = dt_list_next(&dtp->dt_modlist); dmp != NULL;
-	    dmp = dt_list_next(dmp)) {
-		/*
-		 * Check text and data ranges for match.  If there is a range
-		 * that covers the given address, normalize it.
-		 */
-		if (dmp->dm_text_addrs != NULL &&
-		    bsearch(addr, dmp->dm_text_addrs, dmp->dm_text_addrs_size,
-			    sizeof(struct dtrace_addr_range),
-			    dtrace_addr_range_cmp) != NULL) {
-
-			*addr = dmp->dm_text_addrs[0].dar_va;
-			return;
-		}
-
-		if (dmp->dm_data_addrs != NULL &&
-		    bsearch(addr, dmp->dm_data_addrs, dmp->dm_data_addrs_size,
-			    sizeof(struct dtrace_addr_range),
-			    dtrace_addr_range_cmp) != NULL) {
-
-			if (dmp->dm_text_addrs != NULL)
-				*addr = dmp->dm_text_addrs[0].dar_va;
-			else
-				*addr = dmp->dm_data_addrs[0].dar_va;
+	dmp = dt_module_by_addr(dtp, *addr);
+	if (dmp == NULL)
+		return;
 
-			return;
-		}
-	}
+	/* Normalize text and data addresses to the same module address. */
+	if (dmp->dm_text_addrs != NULL)
+		*addr = dmp->dm_text_addrs[0].dar_va;
+	else
+		*addr = dmp->dm_data_addrs[0].dar_va;
 }
 
 static dtrace_aggid_t
diff --git a/libdtrace/dt_module.c b/libdtrace/dt_module.c
index 9d93b9d8..3b40c1cb 100644
--- a/libdtrace/dt_module.c
+++ b/libdtrace/dt_module.c
@@ -2421,7 +2421,7 @@ dt_module_ranges_build(dtrace_hdl_t *dtp)
 	return 0;
 }
 
-static dt_module_t *
+dt_module_t *
 dt_module_by_addr(dtrace_hdl_t *dtp, GElf_Addr addr)
 {
 	dt_module_range_t *index;
diff --git a/libdtrace/dt_module.h b/libdtrace/dt_module.h
index c94cf7b5..73be7144 100644
--- a/libdtrace/dt_module.h
+++ b/libdtrace/dt_module.h
@@ -20,6 +20,7 @@ extern void dt_user_path_destroy(dtrace_hdl_t *);
 
 extern dt_module_t *dt_module_lookup_by_name(dtrace_hdl_t *, const char *);
 extern dt_module_t *dt_module_lookup_by_ctf(dtrace_hdl_t *, ctf_file_t *);
+extern dt_module_t *dt_module_by_addr(dtrace_hdl_t *, GElf_Addr);
 extern int dt_module_sym_iter(const dt_module_t *, proc_sym_f *, void *);
 
 extern ctf_file_t *dt_module_shared_ctf(dtrace_hdl_t *);
-- 
2.52.0


^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-11-06 13:07 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-10-30 19:36 [PATCH 13/20] libdtrace: use module address index for aggregation Kris Van Hees
2026-11-06 13:07 ` Nick Alcock

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.