On Wed, Sep 23, 2026 at 4:45 PM <[email protected]> wrote:
>
> Thank you for your contribution! Sashiko AI review found 1 potential issue(s) 
> to consider:
> - [Medium] dyndbg: classmaps for loadable modules are dropped if 
> DDEBUG_MODNAME is overridden
> --
>
> commit 5e35c3cb693ea4379aa99e08e89d78671956f5c5
> Author: Jim Cromie <[email protected]>
>
> dyndbg: Bind callsites and classmaps to DDEBUG_MODNAME
>
> Currently, dyndbg binds KBUILD_MODNAME directly into callsite and
> classmap declarator macros.
>
> For built-ins, KBUILD_MODNAME defaults to the basename of the source
> file. For many subsystems, this fragments what should be a single
> module into separate file basenames: kernel/power/ produces "main",
> "suspend", "hibernate", "snapshot", and "swap" when all should be
> "power". Conversely, multiple unrelated built-in files across the tree
> (init/main.c, kernel/power/main.c) all collide under "main".
>
> [ ... ]
>
> > diff --git a/include/linux/dynamic_debug.h b/include/linux/dynamic_debug.h
> > index baf5c0853f459..85863e24ad134 100644
> > --- a/include/linux/dynamic_debug.h
> > +++ b/include/linux/dynamic_debug.h
> [ ... ]
> > @@ -121,7 +129,7 @@ struct ddebug_class_param {
> >       static struct ddebug_class_map __aligned(8) __used              \
> >               __section("__dyndbg_classes") _var = {                  \
> >               .mod = THIS_MODULE,                                     \
> > -             .mod_name = KBUILD_MODNAME,                             \
> > +             .mod_name = DDEBUG_MODNAME,                             \
> >               .base = _base,                                          \
> >               .map_type = _maptype,                                   \
> >               .class_names = _var##_classnames,                       \
>
> [Severity: Medium]
> Will this drop classmaps for loadable modules if a maintainer overrides
> DDEBUG_MODNAME?
>
> When a loadable module is loaded, ddebug_module_notify() calls
> ddebug_add_module() using the module's actual load name (mod->name) to
> initialize the ddebug_table's module name.
>
> During initialization, ddebug_attach_module_classes() attempts to match the
> classmap to the module by comparing strings:
>
> lib/dynamic_debug.c:ddebug_attach_module_classes() {
>     ...
>     if (!strcmp(cm->mod_name, dt->mod_name)) {
>     ...
> }
>
> If a maintainer uses the opt-in hook (e.g., ccflags-y += 
> -DDDEBUG_MODNAME='"power"')
> on a loadable module whose load name is "suspend", cm->mod_name will be 
> "power"
> while dt->mod_name is "suspend".
>
> Since the string comparison fails, will all classmaps for the loadable module
> be silently dropped, causing class'd pr_debug calls to lose their 
> functionality
> and trigger pr_warn spam on load due to unknown class IDs?
>

I have dropped the DDEBUG_MODNAME indirection,
am keeping the existing KBUILD_MODNAME.

While it has the effect of breaking up what might be considered a single module,
like "power", into ~6 separate ones, with names like "core" and "main",
we can debate that separately, perhaps as an RFC,
since it touches so many builtin module names.

> --
> Sashiko AI review · 
> https://sashiko.dev/#/patchset/[email protected]?part=14

Reply via email to