Thread (56 messages) 56 messages, 3 authors, 2026-09-11

Re: [PATCH v9 15/39] kbuild, dyndbg: Clean up builtin module-name ambiguities

flat view

From: jim.cromie@gmail.com
Date: 2026-09-11 18:21:05
Also in: dri-devel, linux-arch, linux-doc, linux-kbuild, linux-kselftest, linux-pm, lkml

On Wed, Sep 9, 2026 at 9:50 AM Nicolas Schier [off-list ref] wrote:
On Tue, Sep 08, 2026 at 06:55:11PM -0600, Jim Cromie via B4 Relay wrote:
[...]
quoted
diff --git a/Documentation/admin-guide/dynamic-debug-howto.rst b/Documentation/admin-guide/dynamic-debug-howto.rst
index 9c2f096ed1d8..99bbae37d34e 100644
--- a/Documentation/admin-guide/dynamic-debug-howto.rst
+++ b/Documentation/admin-guide/dynamic-debug-howto.rst
[...]
quoted
@@ -161,17 +161,21 @@ file
      file kernel/freezer.c   # ie column 1 of control file
      file drivers/usb/*      # all callsites under it
      file inode.c:start_*    # parse :tail as a func (above)
-     file inode.c:1-100      # parse :tail as a line-range (above)
+     file inode.c:1-100      # parse :tail as a line-range (below)

 module
-    The given string is compared against the module name
-    of each callsite.  The module name is the string as
-    seen in ``lsmod``, i.e. without the directory or the ``.ko``
-    suffix and with ``-`` changed to ``_``.  Examples::
-
-     module sunrpc
-     module nfsd
-     module drm*     # both drm, drm_kms_helper
+    The query string is compared against the subsystem module name of
+    each callsite, as shown in the control file, or its simple name.
+    The simple module name is the string as seen in ``lsmod``,
+    i.e. without the directory or the ``.ko`` suffix and with ``-``
+    changed to ``_``.
+    Examples::
+
+        module nfsd        # simple modname (as from lsmod)
+     module init/main   # subsystem modname (as in control file)
+     module */main      # any subsystem ending in main
+        module main     # simple modname, selects same as above
+     module drm*        # both drm, drm_kms_helper
The five lines above have mixed indentation, please switch them all to
one tab (no spaces).
thanks, will fix.
[...]
quoted
diff --git a/scripts/Makefile.lib b/scripts/Makefile.lib
index 0a4fdd8bd975..e129c4d10ed8 100644
--- a/scripts/Makefile.lib
+++ b/scripts/Makefile.lib
@@ -23,6 +23,32 @@ modname_flags  = -DKBUILD_MODNAME=$(call name-fix,$(modname)) \
               -D__KBUILD_MODNAME=$(call name-fix-token,$(modname))
 modfile_flags  = -DKBUILD_MODFILE=$(call stringify,$(modfile))

+# Dynamic debug subsystem modname with clean heuristic and override support
+dd_modname_override = $(strip $(firstword $(DD_MODNAME_$(target-stem).o) \
+                                       $(DD_MODNAME)))
+dd_obj := $(strip $(filter-out .,\
+             $(patsubst drivers/%,%,\
+             $(patsubst arch/$(SRCARCH)/%,%,\
+             $(patsubst arch/%/,%,$(obj))))))
May it become problematic if there is a conflict with

  arch/sh/drivers/dma/*
  arch/sh/drivers/pci/*

vs.

  drivers/dma/*
  drivers/pci/*

?
2 questions here really -
- what should happen ?   strip arch/sh/ and then also drivers ?
- what will happen - I will play with the expressions to find out.

quoted
+dd_modname_default = $(strip $(if $(filter $(notdir $(obj)),$(__modname)),\
+                      $(__modname),\
+                      $(if $(filter main core common util init snapshot \
+                                    process,$(__modname)),\
+                          $(dd_obj),\
+                          $(if $(word 2,$(__modname)),\
+                              $(dd_obj),\
+                              $(if $(dd_obj),$(dd_obj),$(__modname))))))
This looks quite complex.  I _think_ this should be equivalent, but
perhaps a bit more simple to maintenance:

dd_modname_default = \
    $(or \
        $(filter $(notdir obj), $(__modname)), \
        $(filter-out main core common util init snapshot process, $(__modname)), \
        $(dd_obj)))

(Removed $(strip) and the last $(__modname) fallback as both are already
in definition of 'dd_modname'.)

What do you think?
it does read better.  I will try it too.




quoted
+dd_modname = $(strip $(or $(dd_modname_override),\
+                       $(dd_modname_default),\
+                       $(__modname)))
+dd-name-subst = $(subst $(comma),_,$(subst -,_,$(strip $1)))
+dd-name-fix-token = $(subst $(space),_,$(call dd-name-subst,$1))
+dd_tok = $(call dd-name-fix-token,$(dd_modname))
+dd_modname_flags = $(if $(dd_modname),\
+     -DKBUILD_DD_MODNAME=$(call stringify,$(dd_tok)))
+
+modfile_flags += $(dd_modname_flags)
dd-name-subst and dd-name-fix-token are not needed, dd_modname_flags is
used only once and can be folded:


dd_tok = $(call name-fix,$(subst $(space),_,$(dd_modname)))

modfile_flags += $(if (dd_modname), -DKBUILD_DD_MODNAME=$(dd_tok))
yes, this all looks cleaner and more comprehensible. thanks.

--
Nicolas
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help