[RFC PATCH 05/10] dyndbg: avoid _ddebug.site in ddebug_condense_sites

From: Jim Cromie
Date: Thu Oct 12 2023 - 15:47:41 EST


Modify the for-loop in ddebug_condense_sites() to walk thru both
vectors: descs, sites in parallel.

This requires a 2nd set of cursor variables (*_ds) that mark the
start-of-range in the sites vector for the intervals to be
dd_store_range()d. So also rename the old cursors (*_dd) for better
consistency and readability.

This is a partial step. It still uses the desc_*() macros to provide
the values, and the macros use the site pointer. Next, we replace the
macros with site_*(), passing the *_ds vars.

Signed-off-by: Jim Cromie <jim.cromie@xxxxxxxxx>
---
lib/dynamic_debug.c | 39 ++++++++++++++++++++++++---------------
1 file changed, 24 insertions(+), 15 deletions(-)

diff --git a/lib/dynamic_debug.c b/lib/dynamic_debug.c
index 3dc17922a1d1..563d373224ba 100644
--- a/lib/dynamic_debug.c
+++ b/lib/dynamic_debug.c
@@ -1426,32 +1426,41 @@ static void dd_store_range(struct maple_tree *mt, const struct _ddebug *start,
v4pr_info(" ok %s at %lx\n", val, first);
}

+
static void ddebug_condense_sites(struct _ddebug_info *di)
{
- struct _ddebug *cur, *funcp, *filep, *modp;
+ struct _ddebug_site *cur_ds, *func_ds, *file_ds, *mod_ds;
+ struct _ddebug *cur_dd, *func_dd, *file_dd, *mod_dd;
int i;

- funcp = filep = modp = di->descs;
- for_each_boxed_vector(di, descs, num_descs, i, cur) {
+ cur_dd = func_dd = file_dd = mod_dd = di->descs;
+ cur_ds = func_ds = file_ds = mod_ds = di->sites;
+ i = 0;
+ for (; i < di->num_descs; i++, cur_dd++, cur_ds++) {
+
+ BUG_ON(site_function(cur_ds) != desc_function(cur_dd));

- if (!strcmp(desc_function(cur), desc_function(funcp)))
+ if (!strcmp(desc_function(cur_dd), desc_function(func_dd)))
continue;
- dd_store_range(&mt_funcs, funcp, cur, "func", desc_function(funcp));
- funcp = cur;
+ dd_store_range(&mt_funcs, func_dd, cur_dd, "func", desc_function(func_dd));
+ func_dd = cur_dd;
+ func_ds = cur_ds;

- if (!strcmp(desc_filename(cur), desc_filename(filep)))
+ if (!strcmp(desc_filename(cur_dd), desc_filename(file_dd)))
continue;
- dd_store_range(&mt_files, filep, cur, "file", desc_filename(filep));
- filep = cur;
+ dd_store_range(&mt_files, file_dd, cur_dd, "file", desc_filename(file_dd));
+ file_dd = cur_dd;
+ file_ds = cur_ds;

- if (!strcmp(desc_modname(cur), desc_modname(modp)))
+ if (!strcmp(desc_modname(cur_dd), desc_modname(mod_dd)))
continue;
- dd_store_range(&mt_mods, modp, cur, "mod", desc_modname(modp));
- modp = cur;
+ dd_store_range(&mt_mods, mod_dd, cur_dd, "mod", desc_modname(mod_dd));
+ mod_dd = cur_dd;
+ mod_ds = cur_ds;
}
- dd_store_range(&mt_funcs, funcp, cur, "func:", desc_function(funcp));
- dd_store_range(&mt_files, filep, cur, "file:", desc_filename(filep));
- dd_store_range(&mt_mods, modp, cur, "mod:", desc_modname(modp));
+ dd_store_range(&mt_funcs, func_dd, cur_dd, "func:", desc_function(func_dd));
+ dd_store_range(&mt_files, file_dd, cur_dd, "file:", desc_filename(file_dd));
+ dd_store_range(&mt_mods, mod_dd, cur_dd, "mod:", desc_modname(mod_dd));
}

/*
--
2.41.0