This series fixes problems which broke CONFIG_DRM_USE_DYNAMIC_DEBUG=Y.
Briefly, the bug was that the handling of drm.debug settings occurs
when drm.ko is up/ready, long before drm drivers and helper modules
are up/ready. So they missed the enablement.
The fix is to split DECLARE_DYNDBG_CLASSMAP in 2; a client-server
scheme where drm calls DYNAMIC_DEBUG_CLASSMAP_DEFINE, and drivers call
DYNAMIC_DEBUG_CLASSMAP_USE. Now when a driver is modprobed, dyndbg
sees the _USE record, follows it to the classmap _DEFINition, finds
drm's drm.debug param which the classmap is wired to, and applies its
setting to the driver module.
The patchset, by chunks:
1. tools/testing/selftests/dynamic_debug/dyndbg_selftest.sh
moved to front
available from start to validate each following commit
"fingerprint" based.
2. DRM setup
enable code under test thru entire series
remove BROKEN on CONFIG_DRM_USE_DYNAMIC_DEBUG
fix ccflags-y in Makefile - build with -DDYNAMIC_DEBUG_MODULE
probably omit this for merge
3. vmlinux fixes for i386 misalignment crash
cleanups needed,added too.
4. cleanups, preps, etc
unused code removal
callchain refactors, struct re-structuring,
verbose debug reduction
5. The API fix
new __dyndbg_class_users section
new test_dynamic_debug_submod.ko
selftests - reproduce the drm-drivers scenario
Not included:
a few drm-core adaptation patches
75+ 1-liner-ish DRM patches to +DYNAMIC_DEBUG_CLASSMAP_USE
patches validating DYNAMIC_DEBUG_CLASSMAP_* args at compile-time, etc
There are 2 user-visible changes I should note:
1. change an ERROR condition displayed in dynamic_debug/control,
from "class:unknown, _id:1" to "class:_UNKNOWN_ id:1"
This only happens if a classmap is incorrectly defined. Such a
problem should be caught in review, and should be SHOUTED about. And
since classmaps are BROKEN for DRM (its only user), this affects no
users. Followon patches will catch more classmap definition errors,
but not this particular one.
2. change builtin module names, displayed in dynamic_debug/control,
from simple "[main]" to subsystem "[init/main]" etc. This corrects an
existing naming ambiguity, which is disallowed for loadable modules by
the module loader. To preserve legacy query behavior, "module main"
will select all of "[*/main]".
NB: the current ambiguity prevents cleanly adding classmaps to
builtins named "[main]". Such an addition is quite unlikely, so this
change could/can be dropped, but it seemed proper to point it out and
correct it.
3. revert a change in classmaps-v1 (2022) which enlarged __drm_debug
from (unsigned) int to long int. 64 categories of drm-debug is well
past reasonable and useful. The param is now a u32, for clarity.
NB: 63 class-ids allows 2+ classmaps per module.
PS: shortened cc list to stay under gmail's 500/day limit,
pls cc folks you think should see this.
Signed-off-by: Jim Cromie <jim.cromie@gmail.com>
---
Changes in v7:
- rebased onto v7.2-rc4
- applies clean to mm-nonmm-unstable@376804729797
- move selftest script to front, always there for validating, bisecting.
- substantial rewrite of test script. now fingerprint based.
- move DRM patches to front, for more thorough build-tests
- drop statements-to-expressions, the compile error no longer exists.
- sashiko fixes - all, I hope
- Link to v6: https://lore.kernel.org/r/20260707-dd-maint-2-v6-0-381f3edb0045@gmail.com
Changes in v6:
previous versions split the 1st chunk into a separate submission, in
an attempt to get past gmail's 500 msgs/day limit, and to ease review.
This complicated application; although the 2nd chunk had the b4
dependency on the 1st, this fact was missed by sashiko, which
therefore couldnt apply it.
A followon series adds compile-time and runtime checks to fail-fast if
classmaps are used incorrectly.
Changes in v5:
move KBUILD_MODFILE ahead of array-slice, to address sashiko
complaints which were fixed by later patches in V4.
Changes in v4:
Dyndbg previously used KBUILD_MODNAME to provide module-name, this
works well for loadable modules (module loader requires unique module
names), but for builtin modules, is effectively kbasename, and is not
guaranteed unique.
So we get 4 modules named "main": init/main, kernel/power/main,
kernel/base/power/main. This ambiguity is visible in user-space since
the beginning of dyndbg.
Now suppose kernel/{,base}/power/main want to define classmaps to
categorize the various pr-debugs they have. The current code finds a
module's classmaps by strcmp on modname, so init/main will match
against classmaps defined by both kernel/{,base}/power/main.
The current code will also map "main" classes to kernel/*/power/main,
so they will probably work at first, but 2 independent classmaps can
both use class-ids 0-N, but will conflict if they're both used by a
module. Then we have classmap overlaps and unpredictable results.
v3:
- move #includes to top of files,
- drop redundant ALIGN(8) in dydnbg.lds.S: DYNDBG_SECTIONS macro
- add Reviewed-by tag (thx Petr)
v2:
- avoid BOUNDED_SECTION in modules, dont need _start & _end symbols.
- sets 0 address to the sections, not just whatever current is.
---
Jim Cromie (29):
params: fix a pr_debug(" %p ") use - already in MM-*
selftests/dyndbg: Add kselftest script to verify dynamic-debug
drm: Fix incorrect ccflags-y spelling inside Makefile
drm: fix config dependent unused variable warning.
drm: Mark CONFIG_DRM_USE_DYNAMIC_DEBUG as unBROKEN
vmlinux.lds.h: refactor BOUNDED_SECTION_* macros into bounded_sections.lds.h
vmlinux.lds.h: drop unused HEADERED_SECTION* macros
vmlinux.lds.h: Fix ALIGN(8) omission causing NULL ptr on i386
vmlinux.lds.h: remove redundant ALIGN(8) directives
dyndbg.lds.S: fix lost dyndbg sections in modules
dyndbg: factor ddebug_match_desc out from ddebug_change
dyndbg: add stub macro for DECLARE_DYNDBG_CLASSMAP
dyndbg: reword "class unknown," to "class:_UNKNOWN_"
dyndbg-API: remove DD_CLASS_TYPE_(DISJOINT|LEVEL)_NAMES and code
dyndbg: drop NUM_TYPE_ARGS
dyndbg: bump num-tokens in a query-cmd from 9 to 15
dyndbg: reduce verbose/debug clutter
lib/parser: add match_wildcard_hyphen() for agnostic matching
dyndbg: use KBUILD_MODFILE for unique builtin module names
dyndbg: refactor param_set_dyndbg_classes and below
dyndbg: tighten fn-sig of ddebug_apply_class_bitmap
dyndbg: replace classmap list with an array-slice
dyndbg: macrofy a 2-index for-loop pattern
dyndbg: pin class param storage to u32
dyndbg,module: make proper substructs in _ddebug_info
dyndbg: move mod_name down from struct ddebug_table to _ddebug_info
dyndbg: hoist classmap-filter-by-modname up to ddebug_add_module
dyndbg-API: replace DECLARE_DYNDBG_CLASSMAP
selftests/dyndbg: enable FT_classmap_inheritance
Documentation/admin-guide/dynamic-debug-howto.rst | 42 +-
MAINTAINERS | 2 +
drivers/gpu/drm/Kconfig.debug | 1 -
drivers/gpu/drm/Makefile | 3 +-
drivers/gpu/drm/drm_print.c | 7 +-
include/asm-generic/bounded_sections.lds.h | 32 +
include/asm-generic/dyndbg.lds.h | 22 +
include/asm-generic/vmlinux.lds.h | 68 +-
include/drm/drm_print.h | 2 +-
include/linux/dynamic_debug.h | 257 +++++--
include/linux/parser.h | 1 +
kernel/module/main.c | 15 +-
kernel/params.c | 4 +-
lib/Kconfig.debug | 24 +-
lib/Makefile | 3 +
lib/dynamic_debug.c | 607 +++++++++------
lib/parser.c | 58 +-
lib/test_dynamic_debug.c | 145 ++--
lib/test_dynamic_debug_submod.c | 14 +
scripts/module.lds.S | 2 +
tools/testing/selftests/dynamic_debug/Makefile | 10 +
tools/testing/selftests/dynamic_debug/config | 8 +
.../selftests/dynamic_debug/dyndbg_selftest.sh | 847 +++++++++++++++++++++
.../dynamic_debug/syslog_hash_validation.sh | 384 ++++++++++
24 files changed, 2089 insertions(+), 469 deletions(-)
---
base-commit: 6946cd5d0aa4dd10a414ddcb7a10844fdb0ad345
change-id: 20260521-dd-maint-2-76c542079420
Best regards,
--
Jim Cromie <jim.cromie@gmail.com>