[PATCH v6 45/57] dyndbg: de-duplicate sites

Jim Cromie jim.cromie at gmail.com
Sun Sep 4 21:41:22 UTC 2022


In __ddebug_add_module(), detect repeated site records (by function
name changes), and push changes onto the stack/vector passed in
from dynamic_debug_init().

For ddebug_add_module(), this transparently de-duplicates the local
sites vector (passed in recently added stack-base, and offset 0).

Signed-off-by: Jim Cromie <jim.cromie at gmail.com>
---
 lib/dynamic_debug.c | 20 ++++++++++++++------
 1 file changed, 14 insertions(+), 6 deletions(-)

diff --git a/lib/dynamic_debug.c b/lib/dynamic_debug.c
index 1b57e43e9c31..41c23ec979f4 100644
--- a/lib/dynamic_debug.c
+++ b/lib/dynamic_debug.c
@@ -1347,7 +1347,7 @@ static int __ddebug_add_module(struct _ddebug_info *di, unsigned int base,
 	struct ddebug_table *dt;
 	int i;
 
-	v3pr_info("add-module: %s.%d sites\n", modname, di->num_descs);
+	v3pr_info("add-module: %s.%d sites, start: %d\n", modname, di->num_descs, base);
 	if (!di->num_descs) {
 		v3pr_info(" skip %s\n", modname);
 		return 0;
@@ -1376,11 +1376,19 @@ static int __ddebug_add_module(struct _ddebug_info *di, unsigned int base,
 		ddebug_attach_module_classes(dt, di->classes, di->num_classes);
 
 	for (i = 0; i < di->num_descs; i++) {
-		di->descs[i]._index = base + i;
-		v3pr_info(" %d %d %s.%s.%d\n", i, base, modname,
-			  di->descs[i].site->_function, di->descs[i].lineno);
-	}
 
+		if (di->descs[i].site->_function != packed_sites[(*packed_base)]._function)
+			memcpy((void *) &packed_sites[++(*packed_base)],
+			       (void *) di->descs[i].site, sizeof(struct _ddebug_site));
+		else
+			di->descs[i].site = &packed_sites[(*packed_base)];
+
+		di->descs[i]._index = i + base;
+		di->descs[i]._map = *packed_base;
+
+		v3pr_info(" %d %d %s.%s.%d - %d\n", i, *packed_base, modname,
+			  di->descs[i].site->_function, di->descs[i].lineno, *packed_base);
+	}
 	mutex_lock(&ddebug_lock);
 	list_add_tail(&dt->link, &ddebug_tables);
 	mutex_unlock(&ddebug_lock);
@@ -1539,7 +1547,7 @@ static int __init dynamic_debug_init(void)
 	iter = iter_mod_start = __start___dyndbg;
 	site = site_mod_start = __start___dyndbg_sites;
 	modname = iter->site->_modname;
-	i = mod_sites = mod_ct = 0;
+	i = mod_sites = mod_ct = site_base = 0;
 
 	for (; iter < __stop___dyndbg; iter++, site++, i++, mod_sites++) {
 
-- 
2.37.2



More information about the amd-gfx mailing list