[PATCH v3 14/54] dyndbg: hoist classmap-filter-by-modname up to ddebug_add_module
Louis Chauvet
louis.chauvet at bootlin.com
Tue Apr 15 10:00:27 UTC 2025
Le 02/04/2025 à 19:41, Jim Cromie a écrit :
> The body of ddebug_attach_module_classes() is dominated by a
> code-block that finds the contiguous subrange of classmaps matching on
> modname, and saves it into the ddebug_table's info record.
>
> Implement this block in a macro to accommodate different component
> vectors in the "box" (as named in the for_subvec macro).
>
> And hoist its invocation out of ddebug_attach_module_classes() up into
> ddebug_add_module(). This moves the filtering step up closer to
> dynamic_debug_init(), which effectively does the same for builtin
> pr_debug descriptors; segmenting them into subranges by modname.
>
> Signed-off-by: Jim Cromie <jim.cromie at gmail.com>
> ---
> lib/dynamic_debug.c | 56 ++++++++++++++++++++++++++-------------------
> 1 file changed, 32 insertions(+), 24 deletions(-)
>
> diff --git a/lib/dynamic_debug.c b/lib/dynamic_debug.c
> index 104cf8abdf33..046c4ffb38f8 100644
> --- a/lib/dynamic_debug.c
> +++ b/lib/dynamic_debug.c
> @@ -161,8 +161,8 @@ static void vpr_info_dq(const struct ddebug_query *query, const char *msg)
> }
>
> static struct _ddebug_class_map *ddebug_find_valid_class(struct ddebug_table const *dt,
> - const char *class_string,
> - int *class_id)
> + const char *class_string,
> + int *class_id)
> {
> struct _ddebug_class_map *map;
> int i, idx;
> @@ -1224,30 +1224,34 @@ static const struct proc_ops proc_fops = {
>
> static void ddebug_attach_module_classes(struct ddebug_table *dt, struct _ddebug_info *di)
> {
> - struct _ddebug_class_map *cm;
> - int i, nc = 0;
> -
> - /*
> - * Find this module's classmaps in a subrange/wholerange of
> - * the builtin/modular classmap vector/section. Save the start
> - * and length of the subrange at its edges.
> - */
> - for_subvec(i, cm, di, maps) {
> - if (!strcmp(cm->mod_name, dt->mod_name)) {
> - if (!nc) {
> - v2pr_info("start subrange, class[%d]: module:%s base:%d len:%d ty:%d\n",
> - i, cm->mod_name, cm->base, cm->length, cm->map_type);
> - dt->info.maps.start = cm;
> - }
> - nc++;
> - }
> - }
> - if (nc) {
> - dt->info.maps.len = nc;
> - vpr_info("module:%s attached %d classes\n", dt->mod_name, nc);
> - }
> + vpr_info("module:%s attached %d classes\n", dt->mod_name, dt->info.maps.len);
> }
>
> +/*
> + * Walk the @_box->@_vec member, over @_vec.start[0..len], and find
> + * the contiguous subrange of elements matching on ->mod_name. Copy
> + * the subrange into @_dst. This depends on vars defd by caller.
> + *
> + * @_i: caller provided counter var, init'd by macro
> + * @_sp: cursor into @_vec.
> + * @_box: contains member named @_vec
> + * @_vec: an array-ref, with: .start .len fields.
> + * @_dst: an array-ref: to remember the module's subrange
_dst must contains a member info which contains a member named @_vec.
Can you specify this in the documentation?
Nitpick: Can you use the same order in documentation and macro definition?
> + */
> +#define dd_mark_vector_subrange(_i, _dst, _sp, _box, _vec) ({ \
> + int nc = 0; \
> + for_subvec(_i, _sp, _box, _vec) { \
> + if (!strcmp((_sp)->mod_name, (_dst)->mod_name)) { \
> + if (!nc++) \
> + (_dst)->info._vec.start = (_sp); \
> + } else { \
> + if (nc) \
> + break; /* end of consecutive matches */ \
> + } \
> + } \
> + (_dst)->info._vec.len = nc; \
> +})
> +
> /*
> * Allocate a new ddebug_table for the given module
> * and add it to the global list.
> @@ -1255,6 +1259,8 @@ static void ddebug_attach_module_classes(struct ddebug_table *dt, struct _ddebug
> static int ddebug_add_module(struct _ddebug_info *di, const char *modname)
> {
> struct ddebug_table *dt;
> + struct _ddebug_class_map *cm;
> + int i;
>
> if (!di->descs.len)
> return 0;
> @@ -1277,6 +1283,8 @@ static int ddebug_add_module(struct _ddebug_info *di, const char *modname)
>
> INIT_LIST_HEAD(&dt->link);
>
> + dd_mark_vector_subrange(i, dt, cm, di, maps);
> +
> if (di->maps.len)
> ddebug_attach_module_classes(dt, di);
>
--
Louis Chauvet, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com
More information about the Intel-gfx
mailing list