From: Jim Cromie <jim.cromie@gmail.com>
To: Andrew Morton <akpm@linux-foundation.org>,
Jason Baron <jbaron@akamai.com>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
Shuah Khan <skhan@linuxfoundation.org>,
Simona Vetter <simona@ffwll.ch>,
Luis Chamberlain <mcgrof@kernel.org>,
Petr Pavlu <petr.pavlu@suse.com>
Cc: linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org,
dri-devel@lists.freedesktop.org, linux-arch@vger.kernel.org,
linux-modules@vger.kernel.org, linux-kselftest@vger.kernel.org,
Jim Cromie <jim.cromie@gmail.com>,
stable@vger.kernel.org, Arnd Bergmann <arnd@arndb.de>,
Louis Chauvet <louis.chauvet@bootlin.com>
Subject: [PATCH v7 00/29] fix dynamic-debug classmaps API for DRM
Date: Tue, 21 Jul 2026 14:56:49 -0600 [thread overview]
Message-ID: <20260721-dd-maint-2-v7-0-010fbe73b311@gmail.com> (raw)
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>
next reply other threads:[~2026-07-21 20:57 UTC|newest]
Thread overview: 38+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-21 20:56 Jim Cromie [this message]
2026-07-21 20:56 ` [PATCH v7 01/29] params: fix a pr_debug(" %p ") use - already in MM-* Jim Cromie
2026-07-21 20:56 ` [PATCH v7 02/29] selftests/dyndbg: Add kselftest script to verify dynamic-debug Jim Cromie
2026-07-21 21:06 ` sashiko-bot
2026-07-21 20:56 ` [PATCH v7 03/29] drm: Fix incorrect ccflags-y spelling inside Makefile Jim Cromie
2026-07-21 20:56 ` [PATCH v7 04/29] drm: fix config dependent unused variable warning Jim Cromie
2026-07-21 20:56 ` [PATCH v7 05/29] drm: Mark CONFIG_DRM_USE_DYNAMIC_DEBUG as unBROKEN Jim Cromie
2026-07-21 20:56 ` [PATCH v7 06/29] vmlinux.lds.h: refactor BOUNDED_SECTION_* macros into bounded_sections.lds.h Jim Cromie
2026-07-21 20:56 ` [PATCH v7 07/29] vmlinux.lds.h: drop unused HEADERED_SECTION* macros Jim Cromie
2026-07-21 20:56 ` [PATCH v7 08/29] vmlinux.lds.h: Fix ALIGN(8) omission causing NULL ptr on i386 Jim Cromie
2026-07-21 20:56 ` [PATCH v7 09/29] vmlinux.lds.h: remove redundant ALIGN(8) directives Jim Cromie
2026-07-21 20:56 ` [PATCH v7 10/29] dyndbg.lds.S: fix lost dyndbg sections in modules Jim Cromie
2026-07-21 20:57 ` [PATCH v7 11/29] dyndbg: factor ddebug_match_desc out from ddebug_change Jim Cromie
2026-07-21 21:05 ` sashiko-bot
2026-07-21 20:57 ` [PATCH v7 12/29] dyndbg: add stub macro for DECLARE_DYNDBG_CLASSMAP Jim Cromie
2026-07-21 20:57 ` [PATCH v7 13/29] dyndbg: reword "class unknown," to "class:_UNKNOWN_" Jim Cromie
2026-07-21 20:57 ` [PATCH v7 14/29] dyndbg-API: remove DD_CLASS_TYPE_(DISJOINT|LEVEL)_NAMES and code Jim Cromie
2026-07-21 20:57 ` [PATCH v7 15/29] dyndbg: drop NUM_TYPE_ARGS Jim Cromie
2026-07-21 20:57 ` [PATCH v7 16/29] dyndbg: bump num-tokens in a query-cmd from 9 to 15 Jim Cromie
2026-07-21 20:57 ` [PATCH v7 17/29] dyndbg: reduce verbose/debug clutter Jim Cromie
2026-07-21 20:57 ` [PATCH v7 18/29] lib/parser: add match_wildcard_hyphen() for agnostic matching Jim Cromie
2026-07-21 20:57 ` [PATCH v7 19/29] dyndbg: use KBUILD_MODFILE for unique builtin module names Jim Cromie
2026-07-21 20:57 ` [PATCH v7 20/29] dyndbg: refactor param_set_dyndbg_classes and below Jim Cromie
2026-07-21 21:11 ` sashiko-bot
2026-07-21 20:57 ` [PATCH v7 21/29] dyndbg: tighten fn-sig of ddebug_apply_class_bitmap Jim Cromie
2026-07-21 20:57 ` [PATCH v7 22/29] dyndbg: replace classmap list with an array-slice Jim Cromie
2026-07-21 20:57 ` [PATCH v7 23/29] dyndbg: macrofy a 2-index for-loop pattern Jim Cromie
2026-07-21 20:57 ` [PATCH v7 24/29] dyndbg: pin class param storage to u32 Jim Cromie
2026-07-21 21:10 ` sashiko-bot
2026-07-21 20:57 ` [PATCH v7 25/29] dyndbg,module: make proper substructs in _ddebug_info Jim Cromie
2026-07-21 21:09 ` sashiko-bot
2026-07-21 20:57 ` [PATCH v7 26/29] dyndbg: move mod_name down from struct ddebug_table to _ddebug_info Jim Cromie
2026-07-21 21:13 ` sashiko-bot
2026-07-21 20:57 ` [PATCH v7 27/29] dyndbg: hoist classmap-filter-by-modname up to ddebug_add_module Jim Cromie
2026-07-21 20:57 ` [PATCH v7 28/29] dyndbg-API: replace DECLARE_DYNDBG_CLASSMAP Jim Cromie
2026-07-21 21:18 ` sashiko-bot
2026-07-21 20:57 ` [PATCH v7 29/29] selftests/dyndbg: enable FT_classmap_inheritance Jim Cromie
2026-07-21 21:11 ` sashiko-bot
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260721-dd-maint-2-v7-0-010fbe73b311@gmail.com \
--to=jim.cromie@gmail.com \
--cc=akpm@linux-foundation.org \
--cc=arnd@arndb.de \
--cc=dri-devel@lists.freedesktop.org \
--cc=gregkh@linuxfoundation.org \
--cc=jbaron@akamai.com \
--cc=linux-arch@vger.kernel.org \
--cc=linux-doc@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=linux-modules@vger.kernel.org \
--cc=louis.chauvet@bootlin.com \
--cc=mcgrof@kernel.org \
--cc=petr.pavlu@suse.com \
--cc=simona@ffwll.ch \
--cc=skhan@linuxfoundation.org \
--cc=stable@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox