public inbox for drm-ai-reviews@public-inbox.freedesktop.org
 help / color / mirror / Atom feed
* [PATCH v11 00/65] Fix DRM_USE_DYNAMIC_DEBUG=y
@ 2026-03-13 13:09 Jim Cromie
  2026-03-13 13:09 ` [PATCH v11 01/65] dyndbg: fix NULL ptr on i386 due to section alignment Jim Cromie
                   ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: Jim Cromie @ 2026-03-13 13:09 UTC (permalink / raw)
  Cc: Jim Cromie, mripard, tzimmermann, maarten.lankhorst, jani.nikula,
	ville.syrjala, christian.koenig, matthew.auld,
	arunpravin.paneerselvam, louis.chauvet, skhan, pmladek, ukaszb,
	dri-devel, linux-kernel, intel-gfx, amd-gfx

The drm subsystem has *lots* of debug statements, in 11 categories

 $> ack '\w*_dbg' drivers/gpu/drm/ | wc
    5532   29318  553806
 $> ack 'DRM_DEBUG\w*' drivers/gpu/drm/ | wc
    2208   12856  212035

All of these are bit-tests on __drm_debug, exposed to users as
/sys/module/drm/parameters/debug.  Many of these are done often,
vblank is done ~100/sec for some displays.  Over the uptime of many
boxes, this is a lot of cpu cycles, on bits that are almost always
off.

Dynamic-debug excels at replacing such tests with NOOPS.  Classmaps
was devised to bring that 0-off-cost to drm's categories.

Classmaps-v1 went into the kernel in Sept 2022, in 2 chunks:
  b7b4eebdba7b..6ea3bf466ac6    # core dyndbg changes
  0406faf25fb1..ee7d633f2dfb    # drm adoption

Sadly DRM-CI found a regression during init with drm.debug=<initval>;
the static-keys underneath the drm-dbgs in drm.ko got enabled, but
those in drivers & helpers did not.

Root Problem:

DECLARE_DYNDBG_CLASSMAP defined the classmap, but it repeated use in
both core and drivers violated a K&R rule "define once, refer
afterwards".  This flaw resulted in a regression; with drm.debug=0xFF
boot arg, drm-core got enabled, but drivers,etc did not.

So in feb 2023, this resulted in:
commit bb2ff6c27bc9 ("drm: Disable dynamic debug as broken")

This patchset replaces it with DYNDBG_CLASSMAP_DEFINE (invoked once in
drm-core) and DYNDBG_CLASSMAP_USE (invoked repeatedly, in drivers &
helpers).

_DEFINE exports the classmap it creates (in drm.ko), other modules
_USE the classmap.  The _USE adds a record ref'g the _DEFINEd (&
exported) classmap, in a 2nd __dyndbg_class_users section.

So now at modprobe, dyndbg scans the new section after the 1st
__dyndbg_class_maps section, follows the linkage to the _DEFINEr
module, finds the (optional) kernel-param controlling the classmap,
examines its drm.debug=<initval>, and applies it to the module being
initialized.

Savings effect:

No real effort was made to quantify the savings; bit-tests are almost
unmeasurable individually, and [1] DRM_USE_DYNAMIC_DEBUG=y purposely
depends upon JUMP_LABEL to avoid its use where it cannot help.

That said, Ive booted one box with drm.debug=0x1ff on the boot-line,
with a script run by systemd to turn it off once boot completes. It
issued ~25k messages in that time.

Status-v11:

Now rebased on drm-misc-next, to allow grinding on DRM-CI.
https://gitlab.freedesktop.org/jim.cromie/kernel-drm-next-dd/-/pipelines/1622778

DRM-CI revealed 2 bugs, fixes now included:
1. drm_buddy had 32bit truncation error, causing unexpected pass
2. drm_printer_debug_fn disregarded drm.debug, spewing msgs, causing timeout.

Also tuned vblank* to avoid drm_debug_enabled() bit-test.
Probably should defer this until [1]=y is default. It isnt yet.

Up to this point, classmaps-v2 has been stuck, straddled on the fence
between drm and dynamic-debug; it needs a little help towards one side
or the other.  ISTM that drm is the actual user, and the acid-test of
its proper function; the dyndbg selftest recaps the 2-module scenario,
but this cannot finally prove anything absent drm.

Verification: DRM-CI Pipeline #1622778
  - KUnit (arm32, arm64, x86_64): All 621 tests PASSED.
    Specifically confirms the 64-bit truncation fixes in drm_buddy.
  - i915-CML: 370 tests PASSED, 0 FAIL.
    Confirms the quelling of the UART storm in shared print callbacks.
  - Overall: No regressions found in dyndbg or buddy allocator logic.

Future:

Lukas Bartosik has been patiently waiting for classmaps to land, so he
can add dyndbg-to-ftrace functionality.  This new feature will allow
steering any/all drm.debug messages to a private ftrace buffer, and
also to mix in other pr_debug messages.  Other ftrace streams could
also be sent there (possibly w/o code changes, tbd).  It could be a
big step towards a featureful crash-buffer.

Ive also cobbled together a maple-tree based replacement for the
__dyndbg_descriptors linker section; it copies the section contents
into 3 maple trees, then drops the section in __init.  By eliminating
the redundant columns (module, file, function) it reduces the storage
needed by 40%.  Early measurements show no net runtime costs, maple
trees make good furniture.

Given that progress, I also hacked up a maple-tree based dynamic
prefix cache.  Currently the dynamic-prefix is re-written for every
prefixed callsite; this can get expensive.  By careful keying (flags
on top, descriptor address underneath), a single prefix string can
span an entire range (smallest of enabled module, file, function).

That last one doesn't help DRM, cuz it doesnt use dynamic-prefixes,
but with this optimization in place, it could be adapted to do so.

Lastly, I have an RFC jump-label patchset that dramatically cuts IPIs,
currently 1 per pr_debug (to ~1/140), by sorting the (existing) queue,
rather than flushing it when a non-increasing patch-addr is queued.

I'd like to move forward with all these, but I anticipate a "fix
classmaps 1st" response.

To: airlied@gmail.com
To: daniel@ffwll.ch
To: jbaron@akamai.com
To: gregkh@linuxfoundation.org
Cc: mripard@kernel.org
Cc: tzimmermann@suse.de
Cc: maarten.lankhorst@linux.intel.com
Cc: jani.nikula@intel.com
Cc: ville.syrjala@linux.intel.com
Cc: christian.koenig@amd.com
Cc: matthew.auld@intel.com
Cc: arunpravin.paneerselvam@amd.com
Cc: louis.chauvet@bootlin.com
Cc: skhan@linuxfoundation.org
Cc: pmladek@suse.com
Cc: ukaszb@chromium.org
Cc: dri-devel@lists.freedesktop.org
Cc: linux-kernel@vger.kernel.org
Cc: intel-gfx@lists.freedesktop.org
Cc: amd-gfx@lists.freedesktop.org

Jim Cromie (65):
  dyndbg: fix NULL ptr on i386 due to section alignment
  dyndbg: factor ddebug_match_desc out from ddebug_change
  dyndbg: add stub macro for DECLARE_DYNDBG_CLASSMAP
  docs/dyndbg: update examples \012 to \n
  docs/dyndbg: explain flags parse 1st
  test-dyndbg: fixup CLASSMAP usage error
  dyndbg: reword "class unknown," to "class:_UNKNOWN_"
  dyndbg: make ddebug_class_param union members same size
  dyndbg: drop NUM_TYPE_ARRAY
  dyndbg: tweak pr_fmt to avoid expansion conflicts
  dyndbg: reduce verbose/debug clutter
  dyndbg: refactor param_set_dyndbg_classes and below
  dyndbg: tighten fn-sig of ddebug_apply_class_bitmap
  dyndbg: replace classmap list with a vector
  dyndbg: macrofy a 2-index for-loop pattern
  dyndbg,module: make proper substructs in _ddebug_info
  dyndbg: hoist classmap-filter-by-modname up to ddebug_add_module
  dyndbg: move mod_name down from struct ddebug_table to _ddebug_info
  dyndbg-API: remove DD_CLASS_TYPE_(DISJOINT|LEVEL)_NAMES and code
  selftests-dyndbg: add a dynamic_debug run_tests target
  dyndbg: change __dynamic_func_call_cls* macros into expressions
  dyndbg-API: replace DECLARE_DYNDBG_CLASSMAP
  dyndbg: detect class_id reservation conflicts
  dyndbg: check DYNAMIC_DEBUG_CLASSMAP_DEFINE args at compile-time
  dyndbg-test: change do_prints testpoint to accept a loopct
  dyndbg-API: promote DYNAMIC_DEBUG_CLASSMAP_PARAM to API
  dyndbg: treat comma as a token separator
  dyndbg: split multi-query strings with %
  selftests-dyndbg: add test_mod_submod
  dyndbg: resolve "protection" of class'd pr_debug
  dyndbg: add DYNAMIC_DEBUG_CLASSMAP_USE_(dd_class_name, offset)
  dyndbg: Harden classmap and callsite validation
  docs/dyndbg: add classmap info to howto
  drm: use correct ccflags-y spelling
  drm-dyndbg: adapt drm core to use dyndbg classmaps-v2
  drm-dyndbg: adapt DRM to invoke DYNAMIC_DEBUG_CLASSMAP_PARAM
  drm-print: modernize an archaic comment
  drm-print: fix config-dependent unused variable
  drm-dyndbg: DRM_CLASSMAP_USE in amdgpu driver
  drm-dyndbg: DRM_CLASSMAP_USE in i915 driver
  drm-dyndbg: DRM_CLASSMAP_USE in drm_crtc_helper
  drm-dyndbg: DRM_CLASSMAP_USE in drm_dp_helper
  drm-dyndbg: DRM_CLASSMAP_USE in nouveau
  drm-dyndbg: add DRM_CLASSMAP_USE to Xe driver
  drm-dyndbg: add DRM_CLASSMAP_USE to virtio_gpu
  drm-dyndbg: add DRM_CLASSMAP_USE to simpledrm
  drm-dyndbg: add DRM_CLASSMAP_USE to bochs
  drm-dyndbg: add DRM_CLASSMAP_USE to etnaviv
  drm-dyndbg: add DRM_CLASSMAP_USE to gma500 driver
  drm-dyndbg: add DRM_CLASSMAP_USE to radeon
  drm-dyndbg: add DRM_CLASSMAP_USE to vmwgfx driver
  drm-dyndbg: add DRM_CLASSMAP_USE to vkms driver
  drm-dyndbg: add DRM_CLASSMAP_USE to udl driver
  drm-dyndbg: add DRM_CLASSMAP_USE to mgag200 driver
  drm-dyndbg: add DRM_CLASSMAP_USE to the gud driver
  drm-dyndbg: add DRM_CLASSMAP_USE to the qxl driver
  drm-dyndbg: add DRM_CLASSMAP_USE to the drm_gem_shmem_helper driver
  accel: add -DDYNAMIC_DEBUG_MODULE to subdir-ccflags
  accel/ivpu: implement IVPU_DBG_* as a dyndbg classmap
  drm: restore CONFIG_DRM_USE_DYNAMIC_DEBUG un-BROKEN
  accel/ethosu: enable drm.debug control
  accel/rocket: enable drm.debug control
  drm_buddy: fix 64-bit truncation in power-of-2 rounding
  drm_print: fix drm_printer dynamic debug bypass
  drm_vblank: use dyndbg's static-key to avoid flag-check

 .../admin-guide/dynamic-debug-howto.rst       | 184 +++-
 MAINTAINERS                                   |   3 +-
 drivers/accel/Makefile                        |   7 +-
 drivers/accel/ethosu/ethosu_drv.c             |   3 +
 drivers/accel/ivpu/ivpu_drv.c                 |  27 +-
 drivers/accel/ivpu/ivpu_drv.h                 |  45 +-
 drivers/accel/rocket/rocket_gem.c             |   2 +
 drivers/gpu/buddy.c                           |   4 +-
 drivers/gpu/drm/Kconfig.debug                 |   1 -
 drivers/gpu/drm/Makefile                      |   3 +-
 drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c       |  12 +-
 drivers/gpu/drm/display/drm_dp_helper.c       |  12 +-
 drivers/gpu/drm/drm_crtc_helper.c             |  12 +-
 drivers/gpu/drm/drm_gem_shmem_helper.c        |   1 +
 drivers/gpu/drm/drm_print.c                   |  38 +-
 drivers/gpu/drm/drm_vblank.c                  |  10 +-
 drivers/gpu/drm/etnaviv/etnaviv_drv.c         |   2 +
 drivers/gpu/drm/gma500/psb_drv.c              |   2 +
 drivers/gpu/drm/gud/gud_drv.c                 |   2 +
 drivers/gpu/drm/i915/i915_params.c            |  12 +-
 drivers/gpu/drm/mgag200/mgag200_drv.c         |   2 +
 drivers/gpu/drm/nouveau/nouveau_drm.c         |  12 +-
 drivers/gpu/drm/qxl/qxl_drv.c                 |   2 +
 drivers/gpu/drm/radeon/radeon_drv.c           |   2 +
 drivers/gpu/drm/sysfb/simpledrm.c             |   2 +
 drivers/gpu/drm/tiny/bochs.c                  |   2 +
 drivers/gpu/drm/udl/udl_main.c                |   2 +
 drivers/gpu/drm/virtio/virtgpu_drv.c          |   2 +
 drivers/gpu/drm/vkms/vkms_drv.c               |   2 +
 drivers/gpu/drm/vmwgfx/vmwgfx_drv.c           |   2 +
 drivers/gpu/drm/xe/xe_drm_client.c            |   2 +
 include/asm-generic/vmlinux.lds.h             |  19 +-
 include/drm/drm_print.h                       |  22 +-
 include/linux/dynamic_debug.h                 | 304 +++++--
 kernel/module/main.c                          |  15 +-
 lib/Kconfig.debug                             |  24 +-
 lib/Makefile                                  |   5 +
 lib/dynamic_debug.c                           | 814 ++++++++++++------
 lib/test_dynamic_debug.c                      | 198 +++--
 lib/test_dynamic_debug_submod.c               |  21 +
 tools/testing/selftests/Makefile              |   1 +
 .../testing/selftests/dynamic_debug/Makefile  |   9 +
 tools/testing/selftests/dynamic_debug/config  |   7 +
 .../dynamic_debug/dyndbg_selftest.sh          | 373 ++++++++
 44 files changed, 1665 insertions(+), 561 deletions(-)
 create mode 100644 lib/test_dynamic_debug_submod.c
 create mode 100644 tools/testing/selftests/dynamic_debug/Makefile
 create mode 100644 tools/testing/selftests/dynamic_debug/config
 create mode 100755 tools/testing/selftests/dynamic_debug/dyndbg_selftest.sh

-- 
2.53.0


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH v11 01/65] dyndbg: fix NULL ptr on i386 due to section alignment
  2026-03-13 13:09 [PATCH v11 00/65] Fix DRM_USE_DYNAMIC_DEBUG=y Jim Cromie
@ 2026-03-13 13:09 ` Jim Cromie
  2026-03-13 21:02   ` Claude review: " Claude Code Review Bot
  2026-03-13 13:09 ` [PATCH v11 02/65] dyndbg: factor ddebug_match_desc out from ddebug_change Jim Cromie
  2026-03-13 21:02 ` Claude review: Fix DRM_USE_DYNAMIC_DEBUG=y Claude Code Review Bot
  2 siblings, 1 reply; 7+ messages in thread
From: Jim Cromie @ 2026-03-13 13:09 UTC (permalink / raw)
  To: Arnd Bergmann, linux-arch, linux-kernel
  Cc: Jim Cromie, mripard, tzimmermann, maarten.lankhorst, jani.nikula,
	ville.syrjala, christian.koenig, matthew.auld,
	arunpravin.paneerselvam, louis.chauvet, skhan, pmladek, ukaszb,
	dri-devel, intel-gfx, amd-gfx, kernel test robot

When dyndbg classmaps get used (later in this series), the
__dyndbg_classes section (which has 28 byte structs on i386), causes
mis-alignment of the following __dyndbg section, resulting in a NULL
pointer deref in dynamic_debug_init().

To fix this, employ belt + suspenders:

1. move __dyndbg section above __dyndbg_classes.  This restores it to
its original position directly after the ALIGN(8), and fixes the
immediate problem.

2. add ALIGN(8) to the BOUNDED_SECTION* macros.  This aligns all
existing sections using the macro, and also fixes a future
dyndbg_class_* addition which would suffer the same misalignment on
i386.  Many of the existing macro uses already have a preceding ALIGN,
these are now redundant, but are harmless, so are left to avoid churn.

3. remove BOUNDED_SECTION* uses in ORC_UNWINDER sections.  These have
smaller alignments, *and* scripts/sorttable.c does not tolerate the
added ALIGN(8) padding.

Reported-by: kernel test robot <oliver.sang@intel.com>
Closes: https://lore.kernel.org/oe-lkp/202601211325.7e1f336-lkp@intel.com
Signed-off-by: Jim Cromie <jim.cromie@gmail.com>
---
 include/asm-generic/vmlinux.lds.h | 16 ++++++++++++----
 1 file changed, 12 insertions(+), 4 deletions(-)

diff --git a/include/asm-generic/vmlinux.lds.h b/include/asm-generic/vmlinux.lds.h
index eeb070f330bd..a2ba7e3d9994 100644
--- a/include/asm-generic/vmlinux.lds.h
+++ b/include/asm-generic/vmlinux.lds.h
@@ -212,11 +212,13 @@
 #endif
 
 #define BOUNDED_SECTION_PRE_LABEL(_sec_, _label_, _BEGIN_, _END_)	\
+	. = ALIGN(8);							\
 	_BEGIN_##_label_ = .;						\
 	KEEP(*(_sec_))							\
 	_END_##_label_ = .;
 
 #define BOUNDED_SECTION_POST_LABEL(_sec_, _label_, _BEGIN_, _END_)	\
+	. = ALIGN(8);							\
 	_label_##_BEGIN_ = .;						\
 	KEEP(*(_sec_))							\
 	_label_##_END_ = .;
@@ -383,8 +385,8 @@
 	*(__tracepoints)						\
 	/* implement dynamic printk debug */				\
 	. = ALIGN(8);							\
-	BOUNDED_SECTION_BY(__dyndbg_classes, ___dyndbg_classes)		\
 	BOUNDED_SECTION_BY(__dyndbg, ___dyndbg)				\
+	BOUNDED_SECTION_BY(__dyndbg_classes, ___dyndbg_classes)		\
 	CODETAG_SECTIONS()						\
 	LIKELY_PROFILE()		       				\
 	BRANCH_PROFILE()						\
@@ -867,15 +869,21 @@
 #ifdef CONFIG_UNWINDER_ORC
 #define ORC_UNWIND_TABLE						\
 	.orc_header : AT(ADDR(.orc_header) - LOAD_OFFSET) {		\
-		BOUNDED_SECTION_BY(.orc_header, _orc_header)		\
+		__start_orc_header = .;					\
+		KEEP(*(.orc_header))					\
+		__stop_orc_header = .;					\
 	}								\
 	. = ALIGN(4);							\
 	.orc_unwind_ip : AT(ADDR(.orc_unwind_ip) - LOAD_OFFSET) {	\
-		BOUNDED_SECTION_BY(.orc_unwind_ip, _orc_unwind_ip)	\
+		__start_orc_unwind_ip = .;				\
+		KEEP(*(.orc_unwind_ip))					\
+		__stop_orc_unwind_ip = .;				\
 	}								\
 	. = ALIGN(2);							\
 	.orc_unwind : AT(ADDR(.orc_unwind) - LOAD_OFFSET) {		\
-		BOUNDED_SECTION_BY(.orc_unwind, _orc_unwind)		\
+		__start_orc_unwind = .;					\
+		KEEP(*(.orc_unwind))					\
+		__stop_orc_unwind = .;					\
 	}								\
 	text_size = _etext - _stext;					\
 	. = ALIGN(4);							\
-- 
2.53.0


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH v11 02/65] dyndbg: factor ddebug_match_desc out from ddebug_change
  2026-03-13 13:09 [PATCH v11 00/65] Fix DRM_USE_DYNAMIC_DEBUG=y Jim Cromie
  2026-03-13 13:09 ` [PATCH v11 01/65] dyndbg: fix NULL ptr on i386 due to section alignment Jim Cromie
@ 2026-03-13 13:09 ` Jim Cromie
  2026-03-13 21:02   ` Claude review: " Claude Code Review Bot
  2026-03-13 21:02 ` Claude review: Fix DRM_USE_DYNAMIC_DEBUG=y Claude Code Review Bot
  2 siblings, 1 reply; 7+ messages in thread
From: Jim Cromie @ 2026-03-13 13:09 UTC (permalink / raw)
  To: Andrew Morton, Jason Baron, Jim Cromie, linux-kernel
  Cc: mripard, tzimmermann, maarten.lankhorst, jani.nikula,
	ville.syrjala, christian.koenig, matthew.auld,
	arunpravin.paneerselvam, louis.chauvet, skhan, pmladek, ukaszb,
	dri-devel, intel-gfx, amd-gfx

ddebug_change() is a big (~100 lines) function with a nested for loop.

The outer loop walks the per-module ddebug_tables list, and does
module stuff: it filters on a query's "module FOO*" and "class BAR",
failures here skip the entire inner loop.

The inner loop (60 lines) scans a module's descriptors.  It starts
with a long block of filters on function, line, format, and the
validated "BAR" class (or the legacy/_DPRINTK_CLASS_DFLT).

These filters "continue" past pr_debugs that don't match the query
criteria, before it falls through the code below that counts matches,
then adjusts the flags and static-keys.  This is unnecessarily hard to
think about.

So move the per-descriptor filter-block into a boolean function:
ddebug_match_desc(desc), and change each "continue" to "return false".
This puts a clear interface in place, so any future changes are either
inside, outside, or across this interface.

also fix checkpatch complaints about spaces and braces.

Signed-off-by: Jim Cromie <jim.cromie@gmail.com>
---
 lib/dynamic_debug.c | 83 +++++++++++++++++++++++++--------------------
 1 file changed, 47 insertions(+), 36 deletions(-)

diff --git a/lib/dynamic_debug.c b/lib/dynamic_debug.c
index 18a71a9108d3..6b1e983cfedc 100644
--- a/lib/dynamic_debug.c
+++ b/lib/dynamic_debug.c
@@ -172,6 +172,52 @@ static struct ddebug_class_map *ddebug_find_valid_class(struct ddebug_table cons
  * callsites, normally the same as number of changes.  If verbose,
  * logs the changes.  Takes ddebug_lock.
  */
+static bool ddebug_match_desc(const struct ddebug_query *query,
+			      struct _ddebug *dp,
+			      int valid_class)
+{
+	/* match site against query-class */
+	if (dp->class_id != valid_class)
+		return false;
+
+	/* match against the source filename */
+	if (query->filename &&
+	    !match_wildcard(query->filename, dp->filename) &&
+	    !match_wildcard(query->filename,
+			    kbasename(dp->filename)) &&
+	    !match_wildcard(query->filename,
+			    trim_prefix(dp->filename)))
+		return false;
+
+	/* match against the function */
+	if (query->function &&
+	    !match_wildcard(query->function, dp->function))
+		return false;
+
+	/* match against the format */
+	if (query->format) {
+		if (*query->format == '^') {
+			char *p;
+			/* anchored search. match must be at beginning */
+			p = strstr(dp->format, query->format + 1);
+			if (p != dp->format)
+				return false;
+		} else if (!strstr(dp->format, query->format)) {
+			return false;
+		}
+	}
+
+	/* match against the line number range */
+	if (query->first_lineno &&
+	    dp->lineno < query->first_lineno)
+		return false;
+	if (query->last_lineno &&
+	    dp->lineno > query->last_lineno)
+		return false;
+
+	return true;
+}
+
 static int ddebug_change(const struct ddebug_query *query,
 			 struct flag_settings *modifiers)
 {
@@ -204,42 +250,7 @@ static int ddebug_change(const struct ddebug_query *query,
 		for (i = 0; i < dt->num_ddebugs; i++) {
 			struct _ddebug *dp = &dt->ddebugs[i];
 
-			/* match site against query-class */
-			if (dp->class_id != valid_class)
-				continue;
-
-			/* match against the source filename */
-			if (query->filename &&
-			    !match_wildcard(query->filename, dp->filename) &&
-			    !match_wildcard(query->filename,
-					   kbasename(dp->filename)) &&
-			    !match_wildcard(query->filename,
-					   trim_prefix(dp->filename)))
-				continue;
-
-			/* match against the function */
-			if (query->function &&
-			    !match_wildcard(query->function, dp->function))
-				continue;
-
-			/* match against the format */
-			if (query->format) {
-				if (*query->format == '^') {
-					char *p;
-					/* anchored search. match must be at beginning */
-					p = strstr(dp->format, query->format+1);
-					if (p != dp->format)
-						continue;
-				} else if (!strstr(dp->format, query->format))
-					continue;
-			}
-
-			/* match against the line number range */
-			if (query->first_lineno &&
-			    dp->lineno < query->first_lineno)
-				continue;
-			if (query->last_lineno &&
-			    dp->lineno > query->last_lineno)
+			if (!ddebug_match_desc(query, dp, valid_class))
 				continue;
 
 			nfound++;
-- 
2.53.0


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Claude review: Fix DRM_USE_DYNAMIC_DEBUG=y
  2026-03-13 13:19 [PATCH v11 00/65] " Jim Cromie
@ 2026-03-13 21:00 ` Claude Code Review Bot
  0 siblings, 0 replies; 7+ messages in thread
From: Claude Code Review Bot @ 2026-03-13 21:00 UTC (permalink / raw)
  To: dri-devel-reviews

Overall Series Review

Subject: Fix DRM_USE_DYNAMIC_DEBUG=y
Author: Jim Cromie <jim.cromie@gmail.com>
Patches: 66
Reviewed: 2026-03-14T07:00:19.881421

---

This is a v11, 65-patch series by Jim Cromie to fix `CONFIG_DRM_USE_DYNAMIC_DEBUG=y`, which has been marked `BROKEN` since Feb 2023 (commit `bb2ff6c27bc9`). The root cause was that the original `DECLARE_DYNDBG_CLASSMAP` was invoked redundantly in both drm-core and each driver, violating define-once semantics. The fix introduces a `DEFINE`/`USE` split: `DYNAMIC_DEBUG_CLASSMAP_DEFINE` (once in drm.ko) and `DYNAMIC_DEBUG_CLASSMAP_USE` (in each driver/helper).

**Architecture:** The overall design is sound. The DEFINE/USE separation correctly addresses the regression where `drm.debug=0xFF` at boot enabled debug in drm-core but not drivers. The new linker section `__dyndbg_class_users` allows dyndbg to propagate the kernel parameter's initial value to driver modules at load time.

**Concerns:**
- **Series size and ordering:** 65 patches is very large and arrives out of numbered order in the mbox (patches appear in a different sequence than their numbering). This makes review difficult and risks bisectability issues.
- **Patch 23 uses a macro name (`DYNDBG_CLASSMAP_DEFINE`) that doesn't exist until patch 24**, creating a build breakage window in the bisect chain.
- **Maintenance burden:** Each DRM driver needs a `DRM_CLASSMAP_USE()` line. New drivers will silently miss it. A mechanism tied to `drm_dev_register()` or a common C file would be preferable long-term.
- **Several patches mix cleanup with functional changes**, making review harder (e.g., patch 11 claims "no functional change" but alters observable verbose output).
- **Multiple typos in commit messages** and a few actual bugs noted below.

The dyndbg core refactoring (patches 1-18) is generally clean. The API changes (19-33) are the architectural heart and are well-designed. The DRM integration (34-65) is mostly mechanical but includes important bug fixes (drm_buddy, drm_print bypass) that arguably should be separate patches.

---
Generated by Claude Code Patch Reviewer

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Claude review: Fix DRM_USE_DYNAMIC_DEBUG=y
  2026-03-13 13:09 [PATCH v11 00/65] Fix DRM_USE_DYNAMIC_DEBUG=y Jim Cromie
  2026-03-13 13:09 ` [PATCH v11 01/65] dyndbg: fix NULL ptr on i386 due to section alignment Jim Cromie
  2026-03-13 13:09 ` [PATCH v11 02/65] dyndbg: factor ddebug_match_desc out from ddebug_change Jim Cromie
@ 2026-03-13 21:02 ` Claude Code Review Bot
  2 siblings, 0 replies; 7+ messages in thread
From: Claude Code Review Bot @ 2026-03-13 21:02 UTC (permalink / raw)
  To: dri-devel-reviews

Overall Series Review

Subject: Fix DRM_USE_DYNAMIC_DEBUG=y
Author: Jim Cromie <jim.cromie@gmail.com>
Patches: 3
Reviewed: 2026-03-14T07:02:58.467847

---

This filtered mbox contains the cover letter (0/65) and the first 2 patches of a 65-patch series "[PATCH v11 00/65] Fix DRM_USE_DYNAMIC_DEBUG=y" by Jim Cromie. The series aims to fix the long-standing regression (since Feb 2023, commit bb2ff6c27bc9) where `DRM_USE_DYNAMIC_DEBUG=y` was marked as `BROKEN` because dyndbg classmaps didn't properly propagate `drm.debug=<initval>` from drm-core to driver modules.

The two patches reviewed here are foundational preparatory changes — a linker script alignment fix and a code refactor. Both are reasonable and well-motivated. The overall series is ambitious at 65 patches on v11, spanning dyndbg core, linker scripts, DRM core, and many DRM drivers. This is a complex cross-subsystem change that has needed careful coordination.

**Key concern for the series overall:** At 65 patches and v11, this needs to land soon or risk perpetual rebasing churn. The cover letter mentions CI passing (pipeline #1622778), which is encouraging. The series would benefit from explicit Reviewed-by/Acked-by tags from the dyndbg and linker-script maintainers.

---
Generated by Claude Code Patch Reviewer

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Claude review: dyndbg: fix NULL ptr on i386 due to section alignment
  2026-03-13 13:09 ` [PATCH v11 01/65] dyndbg: fix NULL ptr on i386 due to section alignment Jim Cromie
@ 2026-03-13 21:02   ` Claude Code Review Bot
  0 siblings, 0 replies; 7+ messages in thread
From: Claude Code Review Bot @ 2026-03-13 21:02 UTC (permalink / raw)
  To: dri-devel-reviews

Patch Review

**Commit message quality:** Good. Clearly explains the root cause (28-byte `__dyndbg_classes` structs on i386 causing misalignment of following `__dyndbg` section) and the three-pronged fix.

**Review of the changes:**

1. **ALIGN(8) added to BOUNDED_SECTION macros** (lines 492, 498 of the diff):
```c
#define BOUNDED_SECTION_PRE_LABEL(_sec_, _label_, _BEGIN_, _END_)	\
	. = ALIGN(8);							\
	_BEGIN_##_label_ = .;						\
```
This is a reasonable belt-and-suspenders approach. However, this is a **broadly impactful change** — `BOUNDED_SECTION_PRE_LABEL` and `BOUNDED_SECTION_POST_LABEL` are used by many sections beyond dyndbg (e.g., `__bug_table`, jump tables, etc.). Adding ALIGN(8) to *all* bounded sections to fix a dyndbg-specific issue is heavy-handed. It may introduce unnecessary padding in sections that have smaller natural alignment requirements. The commit message acknowledges this for ORC but doesn't discuss the impact on other users of the macro.

   **Concern:** Has the impact on vmlinux size been measured across architectures? Adding ALIGN(8) padding before every bounded section could bloat the binary. The arch maintainers (especially Arnd Bergmann, who is CC'd) should weigh in.

2. **Section reordering** (lines 506-508):
```c
	BOUNDED_SECTION_BY(__dyndbg, ___dyndbg)				\
	BOUNDED_SECTION_BY(__dyndbg_classes, ___dyndbg_classes)		\
```
Moving `__dyndbg` before `__dyndbg_classes` so it sits directly after the existing `ALIGN(8)` is the minimal correct fix. This alone would solve the immediate problem without the broader macro change.

3. **ORC unwinder de-macroification** (lines 516-533):
```c
	__start_orc_header = .;					\
	KEEP(*(.orc_header))					\
	__stop_orc_header = .;					\
```
Manually expanding the macro for ORC sections to avoid the new ALIGN(8) is correct — ORC has ALIGN(4) and ALIGN(2) requirements, and `scripts/sorttable.c` cannot tolerate extra padding. However, this creates a maintenance concern: these three sections now duplicate what `BOUNDED_SECTION_BY` would generate (minus the alignment). If `BOUNDED_SECTION_BY` changes semantics in the future, ORC won't track those changes.

   **Suggestion:** Consider adding a comment near the ORC sections explaining *why* they don't use `BOUNDED_SECTION_BY`, so future developers don't "helpfully" convert them back.

**Nit:** The commit says "Closes:" with a lore link, which is good for tracking.

**Verdict:** The fix works but the approach of modifying a global macro is concerning. The section reordering alone (change #2) fixes the immediate issue. The ALIGN(8) in the macro (change #1) is defensive but has non-trivial blast radius. Would prefer an ack from the linker-script/arch maintainers before merging.

---

---
Generated by Claude Code Patch Reviewer

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Claude review: dyndbg: factor ddebug_match_desc out from ddebug_change
  2026-03-13 13:09 ` [PATCH v11 02/65] dyndbg: factor ddebug_match_desc out from ddebug_change Jim Cromie
@ 2026-03-13 21:02   ` Claude Code Review Bot
  0 siblings, 0 replies; 7+ messages in thread
From: Claude Code Review Bot @ 2026-03-13 21:02 UTC (permalink / raw)
  To: dri-devel-reviews

Patch Review

**Commit message quality:** Good. Clearly explains the motivation — extracting the inner-loop filter logic into a separate function for readability.

**Review of the changes:**

This is a straightforward, clean code refactor. The new function:

```c
static bool ddebug_match_desc(const struct ddebug_query *query,
			      struct _ddebug *dp,
			      int valid_class)
```

extracts exactly the per-descriptor matching logic from `ddebug_change()`, converting each `continue` to `return false`. The transformation is correct — each filter condition is preserved identically.

**Minor observations:**

1. The `dp` parameter could be `const`:
```c
			      struct _ddebug *dp,
```
Since `ddebug_match_desc` only reads from `dp`, marking it `const struct _ddebug *dp` would better express intent. This is a nit, not a blocker.

2. The commit message says "also fix checkpatch complaints about spaces and braces." Looking at the diff, the only style change I can see is the spacing around `query->format+1` → `query->format + 1` (line 702 vs the removed line 750). The commit message should either enumerate what style fixes were made or just omit this note if it's a single trivial whitespace change. Mixing style fixes with refactoring in one commit is generally acceptable when the style fix is trivial like this one.

3. The function placement is good — it's placed immediately above `ddebug_change()` where it's called, with the existing block comment acting as a natural separator.

**Verdict:** Clean, correct refactoring. No functional changes. Reviewed-by worthy.

---
Generated by Claude Code Patch Reviewer

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2026-03-13 21:02 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-03-13 13:09 [PATCH v11 00/65] Fix DRM_USE_DYNAMIC_DEBUG=y Jim Cromie
2026-03-13 13:09 ` [PATCH v11 01/65] dyndbg: fix NULL ptr on i386 due to section alignment Jim Cromie
2026-03-13 21:02   ` Claude review: " Claude Code Review Bot
2026-03-13 13:09 ` [PATCH v11 02/65] dyndbg: factor ddebug_match_desc out from ddebug_change Jim Cromie
2026-03-13 21:02   ` Claude review: " Claude Code Review Bot
2026-03-13 21:02 ` Claude review: Fix DRM_USE_DYNAMIC_DEBUG=y Claude Code Review Bot
  -- strict thread matches above, loose matches on Subject: below --
2026-03-13 13:19 [PATCH v11 00/65] " Jim Cromie
2026-03-13 21:00 ` Claude review: " Claude Code Review Bot

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox