Skip to content

dyndbg & drm.debug to tracefs

Jim Cromie amd-gfx dri-devel intel-gfx linux-arm-kernel linux-arm-msm lkml 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v11 Latest19 patches 4 repliesIn review

Patches in v11 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/19dyndbg: add _DPRINTK_FLAGS_ENABLEDinclude/linux/dynamic_debug.h lib/dynamic_debug.c+10 -82 replies
2/19dyndbg: add _DPRINTK_FLAGS_TRACEinclude/linux/dynamic_debug.h+3 -10 replies
3/19dyndbg: add write-to-tracefs codeDocumentation/admin-guide/dynamic-debug-howto.rst lib/dynamic_debug.c+130 -262 replies
4/19dyndbg: add trace-events for pr_debug, dev_dbginclude/trace/events/dyndbg.h lib/dynamic_debug.c+96 -240 replies
5/19dyndbg: add desc, dev fields to event recordinclude/trace/events/dyndbg.h+10 -30 replies
6/19dyndbg: add class_id to callsitesDocumentation/admin-guide/dynamic-debug-howto.rst include/linux/dynamic_debug.h lib/dynamic_debug.c+67 -150 replies
7/19drm_print: condense enum drm_debug_categoryinclude/drm/drm_print.h+11 -110 replies
8/19drm_print: add trace_drm_dbg, trace_drm_devdbg eventsdrivers/gpu/drm/drm_print.c include/trace/events/drm.h+78 -30 replies
9/19drm_print: add CONFIG_DRM_USE_DYNAMIC_DEBUGdrivers/gpu/drm/Kconfig drivers/gpu/drm/Makefile+14 -00 replies
10/19drm_print: interpose drm_dev_dbg, __drm_dbg with forwarding macrosdrivers/gpu/drm/drm_print.c include/drm/drm_print.h+12 -70 replies
11/19drm_print: wrap drm_dev_dbg in _dynamic_func_call_no_descinclude/drm/drm_print.h+6 -00 replies
12/19drm_print: wrap drm_dbg in _dynamic_func_call_no_descinclude/drm/drm_print.h+33 -10 replies
13/19drm_print: refine drm_debug_enabled for dyndbg+jump-labeldrivers/gpu/drm/drm_print.c+2 -20 replies
14/19drm_print: prefer bare printk KERN_DEBUG on generic fndrivers/gpu/drm/drm_print.c+2 -30 replies
15/19drm_print: use _dynamic_func_call_no_desc_clsinclude/drm/drm_print.h+6 -50 replies
16/19drm_print: add struct _ddebug desc to drm_*dbgdrivers/gpu/drm/drm_print.c include/drm/drm_print.h+26 -190 replies
17/19drm_print: add struct _ddebug *desc to trace-drm-*() paramsdrivers/gpu/drm/drm_print.c include/trace/events/drm.h+21 -210 replies
18/19dyndbg: add DEFINE_DYNAMIC_DEBUG_CLASSBITS macro and callbacksinclude/linux/dynamic_debug.h lib/dynamic_debug.c+119 -10 replies
19/19drm_print: use DEFINE_DYNAMIC_DEBUG_CLASSBITS for drm.debugdrivers/gpu/drm/drm_print.c include/drm/drm_print.h+19 -30 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v11 yet.

Read the v11 thread

Cover letter [PATCH v11 00/19] dyndbg & drm.debug to tracefs

hi Jason, Steve, Greg, DRM-folks,

This patchset plumbs debug streams, from dynamic-debug, and from drm.debug, into tracefs. Enabling traffic is done on both source & destination:

	# enable at source
	echo module usbcore +T > /proc/dynamic_debug/control
	# enable events into tracefs
	echo 1 > /sys/kernel/tracing/events/dyndbg/enable
	# enable at source
	echo 0x03 > /sys/module/drm/parameters/debug
	# enable events into tracefs
	echo 1 > /sys/kernel/tracing/events/drm/enable

This allows selectivity at the sources, and in principle, filtering at tracefs (which is unaddressed, except for arg-passthru).

Here is v11, it differs subsantially from v10:

A: All tracefs action is via 4 new trace-events:

from dyndbg:
pr_debug() sends trace_prdbg()
dev_dbg() sends trace_devdbg()
both preserve args unchanged

similarly from drm:
drm_dev_dbg() -> trace_drm_devdbg()
drm_dbg() -> trace_drm_dbg()
again, args are captured unchanged.
for some reason 3 other drm_vblank* events showed up, I dont know why.

These 4 events (not counting vblank) all capture the args unchanged; ISTM full exposure of available info is best for filtering/triggering purposes.

B: dynamic-debug gets proper .class_id, and query support (dyndbg:)

so that this is legal input:

echo module drm class 3 +T > /proc/dynamic_debug/control

v10 used "format drm:core:", which worked, but required addition of category string prefixes, and possible user-facing-changes issues.

New field is uint:4, big enough to fit DRMs enum drm_debug_category (once it has been condensed). The name is .class_id, distinct from but related to DRMs "category".

This also includes _CLS name & arg extensions of the Factory macros that implement dyndbgs jump-label/NOOP optimizations.

C: integration of dyndbg into drm.debug (drm_print:)

The purpose here (and originally) is to avoid drm_debug_enabled() runtime costs, and to put a more flexible substrate underneath the sysfs bitmap api. Ive made it CONFIG dependent, since each _ddebug is 56 bytes, and i915 & amdgpu have ~1700 & ~3800 callsites respectively, of which 127 & ~2k are plain pr_debugs.

1. We shrink enum drm_debug_category to fit in 4 bits, at nominal cost of BIT(category) at runtime, which dyndbg will avoid anyway.

2. Add the trace_drm_*dbg() events

3. insert macro indirection, and use it to wrap drm_*dbg()s in dyndbg's _no_desc_ Factory macro.

4. add __drm_debug_enabled (optimized to true) to use behind jumplabel.

5. use _CLS extension of _no_desc_ Factory macro this makes cls available to initialize _ddebug.class_id

6. alter drm_*dbg, replacing category with struct _ddebug *desc. desc.class_id is category
desc.flags allows selection of PRINTK or TRACE or both

7. propagate struct _ddebug *desc thru trace_drm_*dbg() make all of _ddebug available for filtering

8. add sysfs bitmap to dyndbg, use it to implement drm.debug

D: The "flight-recorder" special instance was unneeded, and is gone:

this handles it generically:

mkdir instances/flightrec
echo 1 > instances/flightrec/events/drm/enable echo module autopilot +T >/proc/dynamic_debug/control

v10 is here:
https://lore.kernel.org/lkml/[email protected]/

patches 1-3 are from:
https://lore.kernel.org/lkml/[email protected]/

this patchset addresses goals of:
https://patchwork.freedesktop.org/series/78133/
https://lore.kernel.org/lkml/3706af20bc64a320ff8f3ff8950738b988f4bdf5.1636452784.git.quic_saipraka@quicinc.com/

Jim Cromie (19):

1st 3 are basically direct from <[email protected]> execpt I dropped his printk:dyndbg event:
dyndbg: add _DPRINTK_FLAGS_ENABLED
dyndbg: add _DPRINTK_FLAGS_TRACE
dyndbg: add write-to-tracefs code

add 2 events, and record args (could be squashed)
dyndbg: add trace-events for pr_debug, dev_dbg
dyndbg: add desc, dev fields to event record

add field, selection mechanisms, and CLS extensions to Factory macros
dyndbg: add class_id to callsites

make category fit in .class_id:
drm_print: condense enum drm_debug_category

repeat trace event addition:
drm_print: add trace_drm_dbg, trace_drm_devdbg events

kconfig+Make-flag:
drm_print: add CONFIG_DRM_USE_DYNDBG

macro indirection:
drm_print: interpose drm_dev_dbg, __drm_dbg with forwarding macros

add >control entries for ~4660 drm.debug callsites:
drm_print: wrap drm_dev_dbg in _dynamic_func_call_no_desc
drm_print: wrap drm_dbg in _dynamic_func_call_no_desc

prep:
drm_print: refine drm_debug_enabled for dyndbg+jump-label

drive-by:
drm_print: prefer bare printk KERN_DEBUG on generic fn

get .class_id initialized at compile.
drm_print: use _dynamic_func_call_no_desc_cls

need this to selectively trace/print:
drm_print: add struct _ddebug desc to drm_dbg, drm_dev_dbg

propagate arg upgrade of HEAD~1 into trace-events:
drm_print: add struct _ddebug *desc to trace-drm-*() params

add and use sysfs bitmap support:
dyndbg: add DEFINE_DYNAMIC_DEBUG_CLASSBITS macro and callbacks
drm_print: use DEFINE_DYNAMIC_DEBUG_CLASSBITS for drm.debug

 .../admin-guide/dynamic-debug-howto.rst       |  12 +
 drivers/gpu/drm/Kconfig                       |  12 +
 drivers/gpu/drm/drm_print.c                   |  66 +++--
 include/drm/drm_print.h                       |  80 +++--
 include/linux/dynamic_debug.h                 | 101 ++++++-
 include/trace/events/drm.h                    |  68 +++++
 include/trace/events/dyndbg.h                 |  74 +++++
 lib/dynamic_debug.c                           | 273 +++++++++++++++---
 8 files changed, 601 insertions(+), 85 deletions(-)
 create mode 100644 include/trace/events/drm.h
 create mode 100644 include/trace/events/dyndbg.h
Signature · 1 line
2.33.1