mbox series

[00/12] use dynamic-debug under drm.debug api

Message ID 20220301164629.3814634-1-jim.cromie@gmail.com (mailing list archive)
Headers show
Series use dynamic-debug under drm.debug api | expand

Message

Jim Cromie March 1, 2022, 4:46 p.m. UTC
hi Jason, Greg, Daniel, DRM-everyone

drm.debug api provides ~23 macros to issue 10 categories of debug
messages, each enabled by a bit in /sys/module/drm/parameters/debug.
drm_debug_enabled(category) tests these bits at runtime; while cheap
individually, the costs accumulate.

Daniel,
I think this revision addresses most of your early review, a lot has
changed since.  Heres the link:
https://patchwork.freedesktop.org/patch/443989/

For CONFIG_DRM_USE_DYNAMIC_DEBUG=y, this patchset obsoletes those
runtime tests (inside drm_*dbg) by wrapping the 2 fns in one of the
dynamic_func_call* Factory macros.  The config dependence is due to
the .data footprint cost of the tables; AMDGPU has ~4k callsites, at
56 bytes each.

This patchset creates entries in /proc/dynamic_debug/control for each
callsite, and each has .class_id = macros' category.  Those entries,
and a new query keyword, allow (1st):

  # 1=DRM_UT_KMS (iirc)
  #> echo "module drm class 1 +p  > /proc/dynamic_debug/control

Then equivalently:
  # except it also clears other flags
  #> echo 0x01 > /sys/module/drm/parameters/debug

series overview:

dyndbg:
 - fix a bug in dyndbg static_key toggling, @stable cc'd
 - adds support for distinct classes to dyndbg (new,unused feature)
 - add DECLARE_DYNAMIC_DEBUG_CLASSBITS macro and callbacks
   to implement bitmap -> classid sysfs knob
dyndbg:
 - drops exported fn: dynamic_debug_exec_queries()
   any potential users would just use macro, or a tweak on it.
 - improve info-msg to print both "old -> new" flags
drm:
 - adapts drm debug category to dyndbg.class_id
 - wraps drm_*dbg() in a dyndbg Factory macro to get NOOP optimized debugs
   this disconnects drm.debug sysfs knob
 - uses DECLARE_DYNAMIC_DEBUG_CLASSBITS macro
   this reconnects sysfs knob

This could be -v12, but the focus and subject has wandered a bit, and
patchwork CI had multiple different notions of the version.

Noteworthy changes:

- no tracefs stuff here, refocus

In contrast, the previous drm.debug approach:

- replaced drm_dbg & drm_devdbg with calls to pr_debug & dev_dbg
  this preserved the optional decorations: module:function:line:

- used DRM_UT_CORE => "drm:core:" prefix-string, cpp cat'd to formats
  this made sites selectable by matching to that format prefix

This version:

- .class_id is easier to explain, and no config/format-string diffs

- wraps drm_dbg & drm_devdbg callsites for jumplabel enablement
  efficiency was original goal.

- loses the optional decorations.
  drm has its own logmsg standards, doesn't need decorations slapped on
  later: could recast flags for drm specific decorations

This is based on 5.17-rc4, for no particular reason.

Its also here: in (dd-drm branch)
  ghlinux-ro	https://github.com/jimc/linux.git (fetch)


Jim Cromie (13):
  dyndbg: fix static_branch manipulation @stable
  dyndbg: add class_id field and query support
  dyndbg: add DEFINE_DYNAMIC_DEBUG_CLASSBITS macro and callbacks
  dyndbg: drop EXPORTed dynamic_debug_exec_queries
  dyndbg: improve change-info to have old and new
  dyndbg: abstract dyndbg_site_is_printing
  drm_print: condense enum drm_debug_category
  drm_print: interpose drm_*dbg with forwarding macros
  drm_print: wrap drm_*_dbg in dyndbg jumplabel
  drm_print: refine drm_debug_enabled for dyndbg+jump-label
  drm_print: prefer bare printk KERN_DEBUG on generic fn
  drm_print: add _ddebug desc to drm_*dbg prototypes
  drm_print: use DEFINE_DYNAMIC_DEBUG_CLASSBITS for drm.debug

 .../admin-guide/dynamic-debug-howto.rst       |   7 +
 drivers/gpu/drm/Kconfig                       |  12 ++
 drivers/gpu/drm/Makefile                      |   2 +
 drivers/gpu/drm/drm_print.c                   |  56 ++++---
 include/drm/drm_print.h                       |  80 +++++++---
 include/linux/dynamic_debug.h                 | 113 +++++++++++---
 lib/dynamic_debug.c                           | 140 ++++++++++++++----
 7 files changed, 323 insertions(+), 87 deletions(-)

Comments

Jim Cromie March 1, 2022, 11:22 p.m. UTC | #1
On Tue, Mar 1, 2022 at 2:32 PM Patchwork
<patchwork@emeril.freedesktop.org> wrote:
>
> Patch Details
> Series:use dynamic-debug under drm.debug api (rev2)
> URL:https://patchwork.freedesktop.org/series/100289/
> State:failure
> Details:https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_22448/index.html
>
> CI Bug Log - changes from CI_DRM_11306 -> Patchwork_22448
>
> Summary
>
> FAILURE
>
> Serious unknown changes coming with Patchwork_22448 absolutely need to be
> verified manually.
>
> If you think the reported changes have nothing to do with the changes
> introduced in Patchwork_22448, please notify your bug team to allow them
> to document this new failure mode, which will reduce false positives in CI.
>
> External URL: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_22448/index.html
>
> Participating hosts (50 -> 45)
>
> Missing (5): shard-tglu fi-hsw-4200u fi-bsw-cyan fi-ctg-p8600 fi-bdw-samus
>
> Possible new issues
>
> Here are the unknown changes that may have been introduced in Patchwork_22448:
>
> IGT changes
>
> Possible regressions
>
> igt@gem_exec_suspend@basic-s3@smem:
>
> fi-cml-u2: PASS -> INCOMPLETE


this one's incomplete cuz of an ext4 boot problem and panic.  unrelated.

<2>[   77.549595] EXT4-fs error (device sda2):
ext4_journal_check_start:83: comm dmesg: Detected aborted journal
<3>[   77.549651] Buffer I/O error on dev sda2, logical block
58228736, lost sync page write
<2>[   77.549684] EXT4-fs error (device sda2):
ext4_journal_check_start:83: comm rs:main Q:Reg: Detected aborted
journal
<3>[   77.550560] JBD2: Error -5 detected when updating journal
superblock for sda2-8.
<3>[   77.553593] Buffer I/O error on dev sda2, logical block 0, lost
sync page write
<3>[   77.554225] EXT4-fs (sda2): I/O error while writing superblock
<3>[   77.554229] EXT4-fs (sda2): I/O error while writing superblock
<0>[   77.554869] Kernel panic - not syncing: EXT4-fs (device sda2):
panic forced after error
<0>[   78.581703] Shutting down cpus with NMI
<0>[   78.581733] Kernel Offset: disabled
<4>[   78.581785] CPU: 5 PID: 957 Comm: dmesg Not tainted
5.17.0-rc6-CI-Patchwork_22448+ #1


>
> Known issues
>
> Here are the changes found in Patchwork_22448 that come from known issues:
>
> c2ed9cc02d9c dyndbg: fix static_branch manipulation
Jim Cromie March 1, 2022, 11:37 p.m. UTC | #2
On Tue, Mar 1, 2022 at 2:00 PM Patchwork
<patchwork@emeril.freedesktop.org> wrote:
>
> == Series Details ==
>
> Series: use dynamic-debug under drm.debug api (rev2)
> URL   : https://patchwork.freedesktop.org/series/100289/
> State : warning
>
> == Summary ==
>
> $ dim sparse --fast origin/drm-tip
> Sparse version: v0.6.2
> Fast mode used, each commit won't be checked separately.
>
>

why a warning ?
is there a report missing ?  suppressed by fastmode ?
Jim Cromie March 4, 2022, 9:56 p.m. UTC | #3
On Tue, Mar 1, 2022 at 1:57 PM Patchwork
<patchwork@emeril.freedesktop.org> wrote:
>
> == Series Details ==
>
> Series: use dynamic-debug under drm.debug api (rev2)
> URL   : https://patchwork.freedesktop.org/series/100289/
> State : warning
>
> == Summary ==
>
> $ dim checkpatch origin/drm-tip
> c2ed9cc02d9c dyndbg: fix static_branch manipulation
> a8f6c71f283e dyndbg: add class_id field and query support
> -:141: CHECK:MACRO_ARG_REUSE: Macro argument reuse 'id' - possible side-effects?
> #141: FILE: include/linux/dynamic_debug.h:142:
> +#define __dynamic_func_call_cls(id, cls, fmt, func, ...) do {  \
> +       DEFINE_DYNAMIC_DEBUG_METADATA_CLS(id, cls, fmt);        \
> +       if (DYNAMIC_DEBUG_BRANCH(id))                           \
> +               func(&id, ##__VA_ARGS__);                       \
>  } while (0)
>
> -:151: CHECK:MACRO_ARG_REUSE: Macro argument reuse 'id' - possible side-effects?
> #151: FILE: include/linux/dynamic_debug.h:148:
> +#define __dynamic_func_call_no_desc_cls(id, cls, fmt, func, ...) do {  \
> +       DEFINE_DYNAMIC_DEBUG_METADATA_CLS(id, cls, fmt);                \
> +       if (DYNAMIC_DEBUG_BRANCH(id))                                   \
> +               func(__VA_ARGS__);                                      \
>  } while (0)
>

Can I get a pass on this ?

the usual approach doesnt work:
+       typeof(id) id = (id);           \

it appears to be due to the outer / wrapping macro inserting the
__UNIQUE_ID(ddebug)
which gets expanded 2x, giving:

      |         ^~~~~~~~
/home/jimc/projects/lx/linux.git/include/linux/compiler-gcc.h:42:45:
note: previous definition of ‘__UNIQUE_ID_ddebug437’ with type ‘int’
   42 | #define __UNIQUE_ID(prefix) __PASTE(__PASTE(__UNIQUE_ID_,
prefix), __COUNTER__)
      |                                             ^~~~~~~~~~~~
/home/jimc/projects/lx/linux.git/include/linux/dynamic_debug.h:230:20:
note: in definition of macro ‘__dynamic_func_call_cls’
  230 |         typeof(id) id = (id);           \


Moreover, these 2 macros imitate existing macros,
which would suffer the same WARNING.

My macro-fu is insufficient,
can anyone suggest a clean way to fix this warning ?

tia
Jim