Re: [PATCH v2 1/2] dyndbg: remove unused 'base' arg from __ddebug_add_module()

From: jim . cromie
Date: Tue Feb 28 2023 - 21:13:09 EST


On Tue, Feb 28, 2023 at 1:38 PM Luis Chamberlain <mcgrof@xxxxxxxxxx> wrote:
>
> On Tue, Feb 28, 2023 at 02:34:21PM -0500, Jason Baron wrote:
> > __ddebug_add_module() doesn't use the 'base' arg. Remove it.
>
> It would be good if the commit log explains why the base became unused.
> What commit removed its use? As of what kernel?
>
> Luis

the base arg became obsolete with this.
I had the same patch on-deck, but Jason did it 1st.


commit b7b4eebdba7b6aea6b34dc29691b71c39d1dbd6a
Author: Jim Cromie <jim.cromie@xxxxxxxxx>
Date: Sun Sep 4 15:40:48 2022 -0600

dyndbg: gather __dyndbg[] state into struct _ddebug_info

This new struct composes the linker provided (vector,len) section,
and provides a place to add other __dyndbg[] state-data later:

descs - the vector of descriptors in __dyndbg section.
num_descs - length of the data/section.

Use it, in several different ways, as follows:

In lib/dynamic_debug.c:

ddebug_add_module(): Alter params-list, replacing 2 args (array,index)
with a struct _ddebug_info * containing them both, with room for
expansion. This helps future-proof the function prototype against the
looming addition of class-map info into the dyndbg-state, by providing
a place to add more member fields later.

NB: later add static struct _ddebug_info builtins_state declaration,
not needed yet.

ddebug_add_module() is called in 2 contexts:

In dynamic_debug_init(), declare, init a struct _ddebug_info di
auto-var to use as a cursor. Then iterate over the prdbg blocks of
the builtin modules, and update the di cursor before calling
_add_module for each.

Its called from kernel/module/main.c:load_info() for each loaded
module:

In internal.h, alter struct load_info, replacing the dyndbg array,len
fields with an embedded _ddebug_info containing them both; and
populate its members in find_module_sections().

The 2 calling contexts differ in that _init deals with contiguous
subranges of __dyndbgs[] section, packed together, while loadable
modules are added one at a time.

So rename ddebug_add_module() into outer/__inner fns, call __inner
from _init, and provide the offset into the builtin __dyndbgs[] where
the module's prdbgs reside. The cursor provides start, len of the
subrange for each. The offset will be used later to pack the results
of builtin __dyndbg_sites[] de-duplication, and is 0 and unneeded for
loadable modules,