Skip to contentSkip to conversation

fix CONFIG_DRM_USE_DYNAMIC_DEBUG=y

PATCH In review Jim Cromie 6 participants 91 messages Jul 2, 2024 – Jul 17, 2024

Subsystems (22)
lore
Share & tools
lore

Jim Cromie

author maintainer
#0 lore raw

v9 cover fix CONFIG_DRM_USE_DYNAMIC_DEBUG=y

This fixes dynamic-debug support for DRM.debug, added via classmaps. commit bb2ff6c27bc9 (drm: Disable dynamic debug as broken)

CONFIG_DRM_USE_DYNAMIC_DEBUG=y was marked broken because drm.debug=val was applied when drm.ko was modprobed; too early for the yet-to-load drivers, which thus missed the enablement. My testing with /etc/modprobe.d/ entries and modprobes with dyndbg=$querycmd options obscured this omission.

The fix is to replace invocations of DECLARE_DYNDBG_CLASSMAP with DYNDBG_CLASSMAP_DEFINE for core, and DYNDBG_CLASSMAP_USE for drivers. The distinction allows dyndbg to also handle the users properly.

DRM is the only current classmaps user, and is not really using it, so if you think DRM could benefit from zero-off-cost debugs based on static-keys, please test.

HISTORY

9/4/22 - ee879be38bc8..ace7c4bbb240 commited - classmaps-v1 dyndbg parts 9/11/22 - 0406faf25fb1..16deeb8e18ca commited - classmaps-v1 drm parts

https://lore.kernel.org/lkml/[email protected]/
greg k-h says:
This should go through the drm tree now. The rest probably should also go that way and not through my tree as well.

https://lore.kernel.org/lkml/[email protected]/
v1- RFC. adds DYNDBG_CLASSMAP_DEFINE + test-submod to recap DRM failure

https://lore.kernel.org/lkml/[email protected]/
v2- w RFC on "tolerate toggled state"

https://lore.kernel.org/lkml/[email protected]/
- PeterZ - nacks tolerance of insane/uninit static-key state

https://lore.kernel.org/lkml/[email protected]/
- JasonB diagnoses prob - set jump-label b4 init

7deabd674988 dyndbg: use the module notifier callbacks
- JasonB lands fix for my problem
he moves dyndbg to use notifiers to do init, like & after jump-labels

https://lore.kernel.org/lkml/[email protected]/
v3- probing, workaround-ish

https://lore.kernel.org/lkml/[email protected]/
v4 - 7/13/23
- had extra/unused __UNIQUE_ID warnings/errs on lkp-tested arches due to unmatched __used marks
- RandyD doc fixes, thx.

https://lore.kernel.org/lkml/[email protected]/
v5 - 8/1/23
- lkp-test reported panics-on-boot
https://lore.kernel.org/lkml/[email protected]/
- DRM=y in apply-params
- missing align(8) in init-macro, failed only for builtin modules

https://lore.kernel.org/lkml/[email protected]/
v6 - 9/11/23 - no feedback

v7[a-d] - attempts to get into/thru DRM patchwork CI..
- "jenius" struck, I preserved DECLARE_DYNDBG_CLASSMAP til later

v8[a-i] - added tools/testing/selftests/dynamic_debug/*

- now turnkey testable without DRM

CLASSMAPS FROM THE TOP

dynamic-debug classmap's primary goal was to bring zero-off-cost debugs, via static-keys, to DRM.

drm.debug: is ~5000 debugs across core, drivers, helpers; each in 1 of 10 exclusive categories, all controlled by bits in a sysfs knob.

drm.debug=0x1ff # bootarg
echo 0x4 > /sys/module/drm/parameters/debug # run-time setting

Below the sysfs interface, classmaps are exposed in the >control grammar with a new "class" keyword. This is mostly like the other keywords, differing by:

a- classnames are client/subsystem/domain defined, not code-name-structural.
the classnames are global, across system
IOW: "class DRM_UT_CORE" selects on any module which knows the class

b- classes are protected from unqualified modification.

   # cannot disable any DRM (or other) classes
   echo -p > /proc/dynamic_debug/control

c- classes don't have wildcards - add if needed.
DRM uses "${SUBSYS}_${CATNAME}"
probably more useful with "${TOP}_${MID}_${LOW}" classnames

API in use:

DRM defines its categories with an enum-type, the obvious thing to do was to copy/emulate that for classmaps; this also preserves the __pr_dbg_class(DRM_UT_CORE, "core stuff") style already used in drm's ~5000 drm_dbg_* macro calls.

DYNDBG_CLASSMAP_DEFINE(drm_debug_classes, ...);
DYNDBG_CLASSMAP_USE(drm_debug_classes);

Classmaps get DEFINEd once (in drm.ko for core) and USEd (in drivers and helpers), these 2 declarations respectively define and export a classmap (in core), and refer to the exported class-struct from the modules.

They both tell dynamic-debug that the module has some of these class'd pr_debugs, so dyndbg uses the classmap's names to validate >control inputs.

The distinction allows USErs to act differently than the DEFINEr; they have to follow the ref back to the DEFINEing module, find the kparam connected to the classmap, and lookup and apply its modprobed value. (this is the bug-fix).

Dyndbg uses the classnames to validate "class FOO" >control inputs, and apply the changes to each module that has DEFINEd or USEd the classmap.

This makes classmaps opt-in: modules must _DEFINE or _USE a classmap for their class'd pr_debug()s to be >control'd.

NOTE: __pr_dbg_class(1, "const-int unreachable class 1"); is legal, but not controllable unless the const 1 has been mapped to a _DEFINE'd classname.

NB: and __pr_dbg_class(i++, "undeclared class") is illegal.

In drm_print.c we have:

/* classnames must match value-symbols of enum drm_debug_category */ DRM_CLASSMAP_DEFINE(drm_debug_classes, DD_CLASS_TYPE_DISJOINT_BITS,

                    DRM_UT_CORE,
                    "DRM_UT_CORE",
                    "DRM_UT_DRIVER",
                    "DRM_UT_KMS",
                    "DRM_UT_PRIME",
                    "DRM_UT_ATOMIC",
                    "DRM_UT_VBL",
                    "DRM_UT_STATE",
                    "DRM_UT_LEASE",
                    "DRM_UT_DP",
                    "DRM_UT_DRMRES");

This maps the sequence of "classnames" to ints starting with DRM_UT_CORE. other offsets allow sharing the per-module 0..63 class-id space

Only complete, linear maps are recommended.

An APPLY_FN(__stringify, __VA_ARGS__) would fix the "string-indirection" I have one written, but didnt want to overload this submission.

DYNDBG_CLASSMAP_PARAM_REF() creates the sysfs-kparam classbits knob, binding the extern'd long-int/bitvec to the classmap.

DRM's categories are independent of each other. The other possible classmap-type/behavior is "related", ie somehow "ordered": V3>V2. The relatedness of classes in a classmap is enforced at the kparam, where they are all set together, not at the >control interface.

THE PATCHSET has 2 halves:

1- dynamic-debug fix - API change

The root cause was DECLARE_DYNDBG_CLASSMAP tried to do too much, and its use in both core and drivers, helpers couldnt sort the difference.

The fix is to replace it with DYNDBG_CLASSMAP_DEFINE in core, and DYNDBG_CLASSMAP_USE in drivers,helpers. The 1st differs from -v1 by exporting the classmap, allowing 2nd to ref it. They respectively add records to 2 ELF sections in the module.

Now, dyndbg's on-modprobe handler follows the _USE/refs to the owning module, finds the controlling kparam: drm.debug, and applies its value thru the classmap, to the module's pr_debugs.

Recent revs of this patchset added a selftest for dyndbg, which recapitulates the DRM regression scenario using the 2 test modules. The test verifies that the dependent module is initialized properly from the parent's classmap kparam.

So it gives a basic turnkey selftest:

[root@v6 b0-dd-drm]# V=0 ../../tools/testing/selftests/dynamic_debug/dyndbg_selftest.sh

 # consulting KCONFIG_CONFIG: .config
 # BASIC_TESTS 
 : 0 matches on =p
 : 14 matches on =p
 : 0 matches on =p
 : 21 matches on =mf
 : 0 matches on =ml
 : 6 matches on =mfl
 ...
 # Done on: Sun Jun 30 10:34:24 PM MDT 2024

This latest rev fixes the test for the various CONFIG_DYNAMIC_DEBUG* build combos, by skipping some subtests where the expected counts are wrong. Lukasz Bartosik caught this - thanks.
CC: [email protected]

2- DRM fixes - use new api.

These are largely unchanged since -v1 above:

a. update core to invoke DRM_CLASSMAP_DEFINE
b. wrap DYNDBG_CLASSMAP_* with DRM_CLASSMAP_* - hide ifdef

c. now with separate +DRM_CLASSMAP_USE patches for each driver/helper:
d. and defer dropping DECLARE_DYNDBG_CLASSMAP til later

Maybe theres a single place to invoke DRM_CLASSMAP_USE just once, perhaps from a client library c-file. I poked a little, didn't find it.

Patches are against v6.9
theyre also at:
tree/branch: https://github.com/jimc/linux.git dd-classmap-fix-8i
branch HEAD: dd31011435409a5bd70cc92bfd846407f6f1a2d8 drm: restore CONFIG_DRM_USE_DYNAMIC_DEBUG un-BROKEN

Finally, classmaps are in a meta-stable state right now; some governor might walk it over to the gravel pit out back.

Tested-bys would help greatly, get it off the fence it straddles. Please specify method: selftest or drm.debug=0x1ff boot.

Also entertaining Reviewed-bys :-}

Jim Cromie (52):

DYNAMIC-DEBUG parts:

cleanup:
docs/dyndbg: update examples \012 to \n
test-dyndbg: fixup CLASSMAP usage error
dyndbg: reword "class unknown," to "class:_UNKNOWN_"
dyndbg: make ddebug_class_param union members same size
dyndbg: replace classmap list with a vector

prep:
dyndbg: ddebug_apply_class_bitmap - add module arg, select on it
dyndbg: split param_set_dyndbg_classes to _module & wrapper fns
dyndbg: drop NUM_TYPE_ARRAY
dyndbg: reduce verbose/debug clutter
dyndbg: silence debugs with no-change updates
dyndbg: tighten ddebug_class_name() 1st arg type
dyndbg: tighten fn-sig of ddebug_apply_class_bitmap
dyndbg: reduce verbose=3 messages in ddebug_add_module

API changes & selftest:
dyndbg-API: remove DD_CLASS_TYPE_(DISJOINT|LEVEL)_NAMES and code
dyndbg-API: fix DECLARE_DYNDBG_CLASSMAP
selftests-dyndbg: add tools/testing/selftests/dynamic_debug/*
dyndbg-API: promote DYNDBG_CLASSMAP_PARAM to API
dyndbg-doc: add classmap info to howto
dyndbg: treat comma as a token separator
selftests-dyndbg: add comma_terminator_tests
dyndbg: split multi-query strings with %
selftests-dyndbg: test_percent_splitting
docs/dyndbg: explain new delimiters: comma, percent
selftests-dyndbg: add test_mod_submod
dyndbg-doc: explain flags parse 1st
dyndbg: change __dynamic_func_call_cls* macros into expressions
selftests-dyndbg: check KCONFIG_CONFIG to avoid silly fails
dyndbg-selftest: reduce default verbosity

DRM-parts:

drm: use correct ccflags-y spelling
drm-dyndbg: adapt drm core to use dyndbg classmaps-v2
drm-dyndbg: adapt DRM to invoke DYNDBG_CLASSMAP_PARAM
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-print: workaround unused variable compiler meh
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
drm: restore CONFIG_DRM_USE_DYNAMIC_DEBUG un-BROKEN

 .../admin-guide/dynamic-debug-howto.rst       |  99 ++-
 MAINTAINERS                                   |   3 +-
 drivers/gpu/drm/Kconfig                       |   3 +-
 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        |   2 +
 drivers/gpu/drm/drm_print.c                   |  38 +-
 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/tiny/bochs.c                  |   2 +
 drivers/gpu/drm/tiny/simpledrm.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             |   1 +
 include/drm/drm_print.h                       |  10 +
 include/linux/dynamic_debug.h                 | 135 ++-
 kernel/module/main.c                          |   3 +
 lib/Kconfig.debug                             |  24 +-
 lib/Makefile                                  |   3 +
 lib/dynamic_debug.c                           | 436 ++++++----
 lib/test_dynamic_debug.c                      | 131 +--
 lib/test_dynamic_debug_submod.c               |  17 +
 tools/testing/selftests/Makefile              |   1 +
 .../testing/selftests/dynamic_debug/Makefile  |   9 +
 tools/testing/selftests/dynamic_debug/config  |   2 +
 .../dynamic_debug/dyndbg_selftest.sh          | 810 ++++++++++++++++++
 37 files changed, 1453 insertions(+), 363 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
Signature · 1 line
2.45.2
author maintainer
#1 lore raw

PATCH v9 1/52 docs/dyndbg: update examples \012 to \n

commit 47ea6f99d06e ("dyndbg: use ESCAPE_SPACE for cat control")

changed the control-file to display format strings with "\n" rather than "\012". Update the docs to match the new reality.

---
 Documentation/admin-guide/dynamic-debug-howto.rst | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)
Documentation/admin-guide/dynamic-debug-howto.rst +5 -5
index 0e9b48daf690..6a8ce5a34382 100644
@@ -52,12 +52,12 @@ query/commands to the control file.  Example::
   # grease the interface
   :#> alias ddcmd='echo $* > /proc/dynamic_debug/control'
 
-  :#> ddcmd '-p; module main func run* +p'
+  :#> ddcmd '-p; module main func run* +p'	# disable all, then enable main
   :#> grep =p /proc/dynamic_debug/control
-  init/main.c:1424 [main]run_init_process =p "  with arguments:\012"
-  init/main.c:1426 [main]run_init_process =p "    %s\012"
-  init/main.c:1427 [main]run_init_process =p "  with environment:\012"
-  init/main.c:1429 [main]run_init_process =p "    %s\012"
+  init/main.c:1424 [main]run_init_process =p "  with arguments:\n"
+  init/main.c:1426 [main]run_init_process =p "    %s\n"
+  init/main.c:1427 [main]run_init_process =p "  with environment:\n"
+  init/main.c:1429 [main]run_init_process =p "    %s\n"
 
 Error messages go to console/syslog::
 
Signature · 1 line
2.45.2
author maintainer
#2 lore raw

PATCH v9 2/52 test-dyndbg: fixup CLASSMAP usage error

In reply to Jim Cromie

A more careful reading of logging output from test_dynamic_debug.ko reveals:

lib/test_dynamic_debug.c:103 [test_dynamic_debug]do_cats =pmf "doing categories\n" lib/test_dynamic_debug.c:105 [test_dynamic_debug]do_cats =p "LOW msg\n" class:MID lib/test_dynamic_debug.c:106 [test_dynamic_debug]do_cats =p "MID msg\n" class:HI lib/test_dynamic_debug.c:107 [test_dynamic_debug]do_cats =_ "HI msg\n" class unknown, _id:13

107 says: HI is unknown, 105,106 have LOW/MID and MID/HI skew.

The enum's 1st val (explicitly initialized) was wrong; it must be _base, not _base+1 (a DECLARE_DYNDBG_CLASSMAP param). So the last enumeration exceeded the range of mapped class-id's, which triggered the "class unknown" report. I coded in an error, intending to verify err detection, then forgot, and missed that it was there.

So this patch fixes a bad usage of DECLARE_DYNDBG_CLASSMAP(), showing that it is too error-prone. As noted in test-mod comments:

* Using the CLASSMAP api:
* - classmaps must have corresponding enum
* - enum symbols must match/correlate with class-name strings in the map.
* - base must equal enum's 1st value
* - multiple maps must set their base to share the 0-62 class_id space !!

---
 lib/test_dynamic_debug.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
lib/test_dynamic_debug.c +1 -1
index 8dd250ad022b..a01f0193a419 100644
@@ -75,7 +75,7 @@ DD_SYS_WRAP(disjoint_bits, p);
 DD_SYS_WRAP(disjoint_bits, T);
 
 /* symbolic input, independent bits */
-enum cat_disjoint_names { LOW = 11, MID, HI };
+enum cat_disjoint_names { LOW = 10, MID, HI };
 DECLARE_DYNDBG_CLASSMAP(map_disjoint_names, DD_CLASS_TYPE_DISJOINT_NAMES, 10,
 			"LOW", "MID", "HI");
 DD_SYS_WRAP(disjoint_names, p);
Signature · 1 line
2.45.2
author maintainer
#3 lore raw

PATCH v9 3/52 dyndbg: reword "class unknown," to "class:_UNKNOWN_"

In reply to Jim Cromie

When a dyndbg classname is unknown to a kernel module (as before previous patch), the callsite is un-addressable via >control queries.

The control-file displays this condition as "class unknown," currently. That spelling is sub-optimal/too-generic, so change it to "class:_UNKNOWN_" to loudly announce the erroneous situation, and to make it exceedingly greppable.

NB: pr_debugs are only alterable via >control, and to protect class'd debug's from unintended alteration, "class name" must be given to change them. Classmaps map known classes to reserved .class_ids (the 1..64 val range per module).

---
 lib/dynamic_debug.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
lib/dynamic_debug.c +1 -1
index f2c5e7910bb1..73ccf947d4aa 100644
@@ -1154,7 +1154,7 @@ static int ddebug_proc_show(struct seq_file *m, void *p)
 		if (class)
 			seq_printf(m, " class:%s", class);
 		else
-			seq_printf(m, " class unknown, _id:%d", dp->class_id);
+			seq_printf(m, " class:_UNKNOWN_ _id:%d", dp->class_id);
 	}
 	seq_puts(m, "\n");
 
Signature · 1 line
2.45.2
author maintainer
#4 lore raw

PATCH v9 4/52 dyndbg: make ddebug_class_param union members same size

In reply to Jim Cromie

struct ddebug_class_param keeps a ref to the state-storage of the param; make both class-types use the same unsigned long storage type.

ISTM this is simpler and safer; it avoids an irrelevant difference, and if 2 users somehow get class-type mixed up (or refer to the wrong union member), at least they will both see the same value.

---
 include/linux/dynamic_debug.h | 2 +-
 lib/dynamic_debug.c           | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
include/linux/dynamic_debug.h +1 -1
index 4fcbf4d4fd0a..5231aaf361c4 100644
@@ -124,7 +124,7 @@ struct _ddebug_info {
 struct ddebug_class_param {
 	union {
 		unsigned long *bits;
-		unsigned int *lvl;
+		unsigned long *lvl;
 	};
 	char flags[8];
 	const struct ddebug_class_map *map;
lib/dynamic_debug.c +1 -1
index 73ccf947d4aa..152b04c05981 100644
@@ -799,7 +799,7 @@ int param_get_dyndbg_classes(char *buffer, const struct kernel_param *kp)
 
 	case DD_CLASS_TYPE_LEVEL_NAMES:
 	case DD_CLASS_TYPE_LEVEL_NUM:
-		return scnprintf(buffer, PAGE_SIZE, "%d\n", *dcp->lvl);
+		return scnprintf(buffer, PAGE_SIZE, "%ld\n", *dcp->lvl);
 	default:
 		return -1;
 	}
Signature · 1 line
2.45.2
author maintainer
#5 lore raw

PATCH v9 5/52 dyndbg: replace classmap list with a vector

In reply to Jim Cromie

Classmaps are stored in an elf section/array, but are individually list-linked onto dyndbg's per-module ddebug_table for operation.

This is unnecessary; even when ddebug_attach_classmap() is handling the builtin section (with classmaps for multiple builtin modules), its contents are ordered, so a module's possibly multiple classmaps will be consecutive in the section, and could be treated as a vector/block, since both start-address and subrange length are in the ddebug_info arg.

IOW, this treats classmaps similarly to _ddebugs, which are already kept as vector-refs (address+len).

So this changes:

struct ddebug_class_map drops list-head link.

struct ddebug_table drops the list-head maps, and gets: classes & num_classes for the start-address and num_classes, placed to improve struct packing.

The loading: in ddebug_attach_module_classes(), replace the for-the-modname list-add loop, with a forloop that finds the module's subrange (start,length) of matching classmaps within the possibly builtin classmaps vector, and saves those to the ddebug_table.

The reading/using: change list-foreach loops in ddebug_class_name() & ddebug_find_valid_class() to walk the array from start to length.

Also:
Move #define __outvar up, above an added use in a fn-prototype. Simplify ddebug_attach_module_classes args, ref has both address & len.

no functional changes

---
 include/linux/dynamic_debug.h |  1 -
 lib/dynamic_debug.c           | 61 ++++++++++++++++++-----------------
 2 files changed, 32 insertions(+), 30 deletions(-)
include/linux/dynamic_debug.h +0 -1
index 5231aaf361c4..b53217e4b711 100644
@@ -83,7 +83,6 @@ enum class_map_type {
 };
 
 struct ddebug_class_map {
-	struct list_head link;
 	struct module *mod;
 	const char *mod_name;	/* needed for builtins */
 	const char **class_names;
lib/dynamic_debug.c +32 -29

119 lines not on this page · raw message

Signature · 1 line
2.45.2
author maintainer
#6 lore raw

PATCH v9 6/52 dyndbg: ddebug_apply_class_bitmap - add module arg, select on it

In reply to Jim Cromie

Add param: query_module to ddebug_apply_class_bitmap(), and pass it thru to _ddebug_queries(), replacing NULL with query_module. This allows its caller to update just one module, or all (as currently).

We'll use this later to propagate drm.debug to each USEr as they're modprobed.

No functional change.

---

after modprobe i915, heres the module dependencies, though not all on drm.debug.

bash-5.2# lsmod

Module                  Size  Used by
i915                 3133440  0
drm_buddy              20480  1 i915
ttm                    90112  1 i915
i2c_algo_bit           16384  1 i915
video                  61440  1 i915
wmi                    32768  1 video
drm_display_helper    200704  1 i915
drm_kms_helper        208896  2 drm_display_helper,i915
drm                   606208  5 drm_kms_helper,drm_display_helper,drm_buddy,i915,ttm
cec                    57344  2 drm_display_helper,i915
---
 lib/dynamic_debug.c | 19 ++++++++++++-------
 1 file changed, 12 insertions(+), 7 deletions(-)
lib/dynamic_debug.c +12 -7
index 46e4cdd8e6be..a1fd2e9dbafb 100644
@@ -605,7 +605,8 @@ static int ddebug_exec_queries(char *query, const char *modname)
 
 /* apply a new bitmap to the sys-knob's current bit-state */
 static int ddebug_apply_class_bitmap(const struct ddebug_class_param *dcp,
-				     unsigned long *new_bits, unsigned long *old_bits)
+				     unsigned long *new_bits, unsigned long *old_bits,
+				     const char *query_modname)
 {
 #define QUERY_SIZE 128
 	char query[QUERY_SIZE];
@@ -613,7 +614,8 @@ static int ddebug_apply_class_bitmap(const struct ddebug_class_param *dcp,
 	int matches = 0;
 	int bi, ct;
 
-	v2pr_info("apply: 0x%lx to: 0x%lx\n", *new_bits, *old_bits);
+	v2pr_info("apply bitmap: 0x%lx to: 0x%lx for %s\n", *new_bits, *old_bits,
+		  query_modname ?: "");
 
 	for (bi = 0; bi < map->length; bi++) {
 		if (test_bit(bi, new_bits) == test_bit(bi, old_bits))
@@ -622,12 +624,15 @@ static int ddebug_apply_class_bitmap(const struct ddebug_class_param *dcp,
 		snprintf(query, QUERY_SIZE, "class %s %c%s", map->class_names[bi],
 			 test_bit(bi, new_bits) ? '+' : '-', dcp->flags);
 
-		ct = ddebug_exec_queries(query, NULL);
+		ct = ddebug_exec_queries(query, query_modname);
 		matches += ct;
 
 		v2pr_info("bit_%d: %d matches on class: %s -> 0x%lx\n", bi,
 			  ct, map->class_names[bi], *new_bits);
 	}
+	v2pr_info("applied bitmap: 0x%lx to: 0x%lx for %s\n", *new_bits, *old_bits,
+		  query_modname ?: "");
+
 	return matches;
 }
 
@@ -682,7 +687,7 @@ static int param_set_dyndbg_classnames(const char *instr, const struct kernel_pa
 				continue;
 			}
 			curr_bits ^= BIT(cls_id);
-			totct += ddebug_apply_class_bitmap(dcp, &curr_bits, dcp->bits);
+			totct += ddebug_apply_class_bitmap(dcp, &curr_bits, dcp->bits, NULL);
 			*dcp->bits = curr_bits;
 			v2pr_info("%s: changed bit %d:%s\n", KP_NAME(kp), cls_id,
 				  map->class_names[cls_id]);
@@ -692,7 +697,7 @@ static int param_set_dyndbg_classnames(const char *instr, const struct kernel_pa
 			old_bits = CLASSMAP_BITMASK(*dcp->lvl);
 			curr_bits = CLASSMAP_BITMASK(cls_id + (wanted ? 1 : 0 ));
 
-			totct += ddebug_apply_class_bitmap(dcp, &curr_bits, &old_bits);
+			totct += ddebug_apply_class_bitmap(dcp, &curr_bits, &old_bits, NULL);
 			*dcp->lvl = (cls_id + (wanted ? 1 : 0));
 			v2pr_info("%s: changed bit-%d: \"%s\" %lx->%lx\n", KP_NAME(kp), cls_id,
 				  map->class_names[cls_id], old_bits, curr_bits);
@@ -755,7 +760,7 @@ int param_set_dyndbg_classes(const char *instr, const struct kernel_param *kp)
 			inrep &= CLASSMAP_BITMASK(map->length);
 		}
 		v2pr_info("bits:%lx > %s\n", inrep, KP_NAME(kp));
-		totct += ddebug_apply_class_bitmap(dcp, &inrep, dcp->bits);
+		totct += ddebug_apply_class_bitmap(dcp, &inrep, dcp->bits, NULL);
 		*dcp->bits = inrep;
 		break;
 	case DD_CLASS_TYPE_LEVEL_NUM:
@@ -768,7 +773,7 @@ int param_set_dyndbg_classes(const char *instr, const struct kernel_param *kp)
 		old_bits = CLASSMAP_BITMASK(*dcp->lvl);
 		new_bits = CLASSMAP_BITMASK(inrep);
 		v2pr_info("lvl:%ld bits:0x%lx > %s\n", inrep, new_bits, KP_NAME(kp));
-		totct += ddebug_apply_class_bitmap(dcp, &new_bits, &old_bits);
+		totct += ddebug_apply_class_bitmap(dcp, &new_bits, &old_bits, NULL);
 		*dcp->lvl = inrep;
 		break;
 	default:
Signature · 1 line
2.45.2
author maintainer
#7 lore raw

PATCH v9 7/52 dyndbg: split param_set_dyndbg_classes to _module & wrapper fns

In reply to Jim Cromie

Split api-fn: param_set_dyndbg_classes(), adding modname param and passing NULL in from api-fn.

The new arg allows caller to specify that only one module is affected by a prdbgs update. This selectivity will be used later to narrow the scope of changes made.

no functional change.

---
 lib/dynamic_debug.c | 37 ++++++++++++++++++++++---------------
 1 file changed, 22 insertions(+), 15 deletions(-)
lib/dynamic_debug.c +22 -15
index a1fd2e9dbafb..4a48f830507f 100644
@@ -711,18 +711,9 @@ static int param_set_dyndbg_classnames(const char *instr, const struct kernel_pa
 	return 0;
 }
 
-/**
- * param_set_dyndbg_classes - class FOO >control
- * @instr: string echo>d to sysfs, input depends on map_type
- * @kp:    kp->arg has state: bits/lvl, map, map_type
- *
- * Enable/disable prdbgs by their class, as given in the arguments to
- * DECLARE_DYNDBG_CLASSMAP.  For LEVEL map-types, enforce relative
- * levels by bitpos.
- *
- * Returns: 0 or <0 if error.
- */
-int param_set_dyndbg_classes(const char *instr, const struct kernel_param *kp)
+static int param_set_dyndbg_module_classes(const char *instr,
+					   const struct kernel_param *kp,
+					   const char *modnm)
 {
 	const struct ddebug_class_param *dcp = kp->arg;
 	const struct ddebug_class_map *map = dcp->map;
@@ -759,8 +750,8 @@ int param_set_dyndbg_classes(const char *instr, const struct kernel_param *kp)
 				KP_NAME(kp), inrep, CLASSMAP_BITMASK(map->length));
 			inrep &= CLASSMAP_BITMASK(map->length);
 		}
-		v2pr_info("bits:%lx > %s\n", inrep, KP_NAME(kp));
-		totct += ddebug_apply_class_bitmap(dcp, &inrep, dcp->bits, NULL);
+		v2pr_info("bits:0x%lx > %s.%s\n", inrep, modnm ?: "*", KP_NAME(kp));
+		totct += ddebug_apply_class_bitmap(dcp, &inrep, dcp->bits, modnm);
 		*dcp->bits = inrep;
 		break;
 	case DD_CLASS_TYPE_LEVEL_NUM:
@@ -773,7 +764,7 @@ int param_set_dyndbg_classes(const char *instr, const struct kernel_param *kp)
 		old_bits = CLASSMAP_BITMASK(*dcp->lvl);
 		new_bits = CLASSMAP_BITMASK(inrep);
 		v2pr_info("lvl:%ld bits:0x%lx > %s\n", inrep, new_bits, KP_NAME(kp));
-		totct += ddebug_apply_class_bitmap(dcp, &new_bits, &old_bits, NULL);
+		totct += ddebug_apply_class_bitmap(dcp, &new_bits, &old_bits, modnm);
 		*dcp->lvl = inrep;
 		break;
 	default:
@@ -782,6 +773,22 @@ int param_set_dyndbg_classes(const char *instr, const struct kernel_param *kp)
 	vpr_info("%s: total matches: %d\n", KP_NAME(kp), totct);
 	return 0;
 }
+
+/**
+ * param_set_dyndbg_classes - class FOO >control
+ * @instr: string echo>d to sysfs, input depends on map_type
+ * @kp:    kp->arg has state: bits/lvl, map, map_type
+ *
+ * Enable/disable prdbgs by their class, as given in the arguments to
+ * DECLARE_DYNDBG_CLASSMAP.  For LEVEL map-types, enforce relative
+ * levels by bitpos.
+ *
+ * Returns: 0 or <0 if error.
+ */
+int param_set_dyndbg_classes(const char *instr, const struct kernel_param *kp)
+{
+	return param_set_dyndbg_module_classes(instr, kp, NULL);
+}
 EXPORT_SYMBOL(param_set_dyndbg_classes);
 
 /**
Signature · 1 line
2.45.2
author maintainer
#8 lore raw

PATCH v9 8/52 dyndbg: drop NUM_TYPE_ARRAY

In reply to Jim Cromie

ARRAY_SIZE works here, since array decl is complete.

no functional change

---
 include/linux/dynamic_debug.h | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
include/linux/dynamic_debug.h +1 -3
index b53217e4b711..8116d0a0d33a 100644
@@ -106,11 +106,9 @@ struct ddebug_class_map {
 		.mod_name = KBUILD_MODNAME,				\
 		.base = _base,						\
 		.map_type = _maptype,					\
-		.length = NUM_TYPE_ARGS(char*, __VA_ARGS__),		\
+		.length = ARRAY_SIZE(_var##_classnames),		\
 		.class_names = _var##_classnames,			\
 	}
-#define NUM_TYPE_ARGS(eltype, ...)				\
-        (sizeof((eltype[]){__VA_ARGS__}) / sizeof(eltype))
 
 /* encapsulate linker provided built-in (or module) dyndbg data */
 struct _ddebug_info {
Signature · 1 line
2.45.2
author maintainer
#9 lore raw

PATCH v9 9/52 dyndbg: reduce verbose/debug clutter

In reply to Jim Cromie

currently, for verbose=3, these are logged (blank lines for clarity):

dyndbg: query 0: "class DRM_UT_CORE +p" mod:*
dyndbg: split into words: "class" "DRM_UT_CORE" "+p"

dyndbg: op='+'
dyndbg: flags=0x1
dyndbg: *flagsp=0x1 *maskp=0xffffffff

dyndbg: parsed: func="" file="" module="" format="" lineno=0-0 class=...
dyndbg: no matches for query
dyndbg: no-match: func="" file="" module="" format="" lineno=0-0 class=...
dyndbg: processed 1 queries, with 0 matches, 0 errs

That is excessive, so this patch:
- shrinks 3 lines of 2nd stanza to single line
- drops 1st 2 lines of 3rd stanza
3rd line is like 1st, with result, not procedure. 2nd line is just status, retold in 4th, with more info.

New output:

dyndbg: query 0: "class DRM_UT_CORE +p" mod:*
dyndbg: split into words: "class" "DRM_UT_CORE" "+p"
dyndbg: op='+' flags=0x1 *flagsp=0x1 *maskp=0xffffffff
dyndbg: no-match: func="" file="" module="" format="" lineno=0-0 class=...
dyndbg: processed 1 queries, with 0 matches, 0 errs

no functional change.

---
 lib/dynamic_debug.c | 14 +++-----------
 1 file changed, 3 insertions(+), 11 deletions(-)
lib/dynamic_debug.c +3 -11
index 4a48f830507f..368381dbd266 100644
@@ -266,9 +266,6 @@ static int ddebug_change(const struct ddebug_query *query,
 	}
 	mutex_unlock(&ddebug_lock);
 
-	if (!nfound && verbose)
-		pr_info("no matches for query\n");
-
 	return nfound;
 }
 
@@ -501,7 +498,6 @@ static int ddebug_parse_flags(const char *str, struct flag_settings *modifiers)
 		pr_err("bad flag-op %c, at start of %s\n", *str, str);
 		return -EINVAL;
 	}
-	v3pr_info("op='%c'\n", op);
 
 	for (; *str ; ++str) {
 		for (i = ARRAY_SIZE(opt_array) - 1; i >= 0; i--) {
@@ -515,7 +511,6 @@ static int ddebug_parse_flags(const char *str, struct flag_settings *modifiers)
 			return -EINVAL;
 		}
 	}
-	v3pr_info("flags=0x%x\n", modifiers->flags);
 
 	/* calculate final flags, mask based upon op */
 	switch (op) {
@@ -531,7 +526,7 @@ static int ddebug_parse_flags(const char *str, struct flag_settings *modifiers)
 		modifiers->flags = 0;
 		break;
 	}
-	v3pr_info("*flagsp=0x%x *maskp=0x%x\n", modifiers->flags, modifiers->mask);
+	v3pr_info("op='%c' flags=0x%x maskp=0x%x\n", op, modifiers->flags, modifiers->mask);
 
 	return 0;
 }
@@ -541,7 +536,7 @@ static int ddebug_exec_query(char *query_string, const char *modname)
 	struct flag_settings modifiers = {};
 	struct ddebug_query query = {};
 #define MAXWORDS 9
-	int nwords, nfound;
+	int nwords;
 	char *words[MAXWORDS];
 
 	nwords = ddebug_tokenize(query_string, words, MAXWORDS);
@@ -559,10 +554,7 @@ static int ddebug_exec_query(char *query_string, const char *modname)
 		return -EINVAL;
 	}
 	/* actually go and implement the change */
-	nfound = ddebug_change(&query, &modifiers);
-	vpr_info_dq(&query, nfound ? "applied" : "no-match");
-
-	return nfound;
+	return ddebug_change(&query, &modifiers);
 }
 
 /* handle multiple queries in query string, continue on error, return
Signature · 1 line
2.45.2
author maintainer
#10 lore raw

PATCH v9 10/52 dyndbg: silence debugs with no-change updates

In reply to Jim Cromie

In ddebug_apply_class_bitmap(), check for actual changes to the bits before announcing them, to declutter logs.

no functional change.

---
 lib/dynamic_debug.c | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)
lib/dynamic_debug.c +7 -5
index 368381dbd266..8320cadeb251 100644
@@ -595,7 +595,7 @@ static int ddebug_exec_queries(char *query, const char *modname)
 	return nfound;
 }
 
-/* apply a new bitmap to the sys-knob's current bit-state */
+/* apply a new class-param setting */
 static int ddebug_apply_class_bitmap(const struct ddebug_class_param *dcp,
 				     unsigned long *new_bits, unsigned long *old_bits,
 				     const char *query_modname)
@@ -606,8 +606,9 @@ static int ddebug_apply_class_bitmap(const struct ddebug_class_param *dcp,
 	int matches = 0;
 	int bi, ct;
 
-	v2pr_info("apply bitmap: 0x%lx to: 0x%lx for %s\n", *new_bits, *old_bits,
-		  query_modname ?: "");
+	if (*new_bits != *old_bits)
+		v2pr_info("apply bitmap: 0x%lx to: 0x%lx for %s\n", *new_bits,
+			  *old_bits, query_modname ?: "'*'");
 
 	for (bi = 0; bi < map->length; bi++) {
 		if (test_bit(bi, new_bits) == test_bit(bi, old_bits))
@@ -622,8 +623,9 @@ static int ddebug_apply_class_bitmap(const struct ddebug_class_param *dcp,
 		v2pr_info("bit_%d: %d matches on class: %s -> 0x%lx\n", bi,
 			  ct, map->class_names[bi], *new_bits);
 	}
-	v2pr_info("applied bitmap: 0x%lx to: 0x%lx for %s\n", *new_bits, *old_bits,
-		  query_modname ?: "");
+	if (*new_bits != *old_bits)
+		v2pr_info("applied bitmap: 0x%lx to: 0x%lx for %s\n", *new_bits,
+			  *old_bits, query_modname ?: "'*'");
 
 	return matches;
 }
Signature · 1 line
2.45.2
author maintainer
#11 lore raw

PATCH v9 11/52 dyndbg: tighten ddebug_class_name() 1st arg type

In reply to Jim Cromie

Change function's 1st arg-type, and deref in the caller. The fn doesn't need any other fields in the struct.

no functional change.

---
 lib/dynamic_debug.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)
lib/dynamic_debug.c +5 -5
index 8320cadeb251..882354e1e78f 100644
@@ -1120,12 +1120,12 @@ static void *ddebug_proc_next(struct seq_file *m, void *p, loff_t *pos)
 #define class_in_range(class_id, map)					\
 	(class_id >= map->base && class_id < map->base + map->length)
 
-static const char *ddebug_class_name(struct ddebug_iter *iter, struct _ddebug *dp)
+static const char *ddebug_class_name(struct ddebug_table *dt, struct _ddebug *dp)
 {
-	struct ddebug_class_map *map = iter->table->classes;
-	int i, nc = iter->table->num_classes;
+	struct ddebug_class_map *map = dt->classes;
+	int i;
 
-	for (i = 0; i < nc; i++, map++)
+	for (i = 0; i < dt->num_classes; i++, map++)
 		if (class_in_range(dp->class_id, map))
 			return map->class_names[dp->class_id - map->base];
 
@@ -1159,7 +1159,7 @@ static int ddebug_proc_show(struct seq_file *m, void *p)
 	seq_puts(m, "\"");
 
 	if (dp->class_id != _DPRINTK_CLASS_DFLT) {
-		class = ddebug_class_name(iter, dp);
+		class = ddebug_class_name(iter->table, dp);
 		if (class)
 			seq_printf(m, " class:%s", class);
 		else
Signature · 1 line
2.45.2
author maintainer
#12 lore raw

PATCH v9 12/52 dyndbg: tighten fn-sig of ddebug_apply_class_bitmap

In reply to Jim Cromie

old_bits arg is currently a pointer to the input bits, but this could allow inadvertent changes to the input by the fn. Disallow this. And constify new_bits while here.

---
 lib/dynamic_debug.c | 21 +++++++++++----------
 1 file changed, 11 insertions(+), 10 deletions(-)
lib/dynamic_debug.c +11 -10
index 882354e1e78f..d4a0ae31d059 100644
@@ -597,7 +597,8 @@ static int ddebug_exec_queries(char *query, const char *modname)
 
 /* apply a new class-param setting */
 static int ddebug_apply_class_bitmap(const struct ddebug_class_param *dcp,
-				     unsigned long *new_bits, unsigned long *old_bits,
+				     const unsigned long *new_bits,
+				     const unsigned long old_bits,
 				     const char *query_modname)
 {
 #define QUERY_SIZE 128
@@ -606,12 +607,12 @@ static int ddebug_apply_class_bitmap(const struct ddebug_class_param *dcp,
 	int matches = 0;
 	int bi, ct;
 
-	if (*new_bits != *old_bits)
+	if (*new_bits != old_bits)
 		v2pr_info("apply bitmap: 0x%lx to: 0x%lx for %s\n", *new_bits,
-			  *old_bits, query_modname ?: "'*'");
+			  old_bits, query_modname ?: "'*'");
 
 	for (bi = 0; bi < map->length; bi++) {
-		if (test_bit(bi, new_bits) == test_bit(bi, old_bits))
+		if (test_bit(bi, new_bits) == test_bit(bi, &old_bits))
 			continue;
 
 		snprintf(query, QUERY_SIZE, "class %s %c%s", map->class_names[bi],
@@ -623,9 +624,9 @@ static int ddebug_apply_class_bitmap(const struct ddebug_class_param *dcp,
 		v2pr_info("bit_%d: %d matches on class: %s -> 0x%lx\n", bi,
 			  ct, map->class_names[bi], *new_bits);
 	}
-	if (*new_bits != *old_bits)
+	if (*new_bits != old_bits)
 		v2pr_info("applied bitmap: 0x%lx to: 0x%lx for %s\n", *new_bits,
-			  *old_bits, query_modname ?: "'*'");
+			  old_bits, query_modname ?: "'*'");
 
 	return matches;
 }
@@ -681,7 +682,7 @@ static int param_set_dyndbg_classnames(const char *instr, const struct kernel_pa
 				continue;
 			}
 			curr_bits ^= BIT(cls_id);
-			totct += ddebug_apply_class_bitmap(dcp, &curr_bits, dcp->bits, NULL);
+			totct += ddebug_apply_class_bitmap(dcp, &curr_bits, *dcp->bits, NULL);
 			*dcp->bits = curr_bits;
 			v2pr_info("%s: changed bit %d:%s\n", KP_NAME(kp), cls_id,
 				  map->class_names[cls_id]);
@@ -691,7 +692,7 @@ static int param_set_dyndbg_classnames(const char *instr, const struct kernel_pa
 			old_bits = CLASSMAP_BITMASK(*dcp->lvl);
 			curr_bits = CLASSMAP_BITMASK(cls_id + (wanted ? 1 : 0 ));
 
-			totct += ddebug_apply_class_bitmap(dcp, &curr_bits, &old_bits, NULL);
+			totct += ddebug_apply_class_bitmap(dcp, &curr_bits, old_bits, NULL);
 			*dcp->lvl = (cls_id + (wanted ? 1 : 0));
 			v2pr_info("%s: changed bit-%d: \"%s\" %lx->%lx\n", KP_NAME(kp), cls_id,
 				  map->class_names[cls_id], old_bits, curr_bits);
@@ -745,7 +746,7 @@ static int param_set_dyndbg_module_classes(const char *instr,
 			inrep &= CLASSMAP_BITMASK(map->length);
 		}
 		v2pr_info("bits:0x%lx > %s.%s\n", inrep, modnm ?: "*", KP_NAME(kp));
-		totct += ddebug_apply_class_bitmap(dcp, &inrep, dcp->bits, modnm);
+		totct += ddebug_apply_class_bitmap(dcp, &inrep, *dcp->bits, modnm);
 		*dcp->bits = inrep;
 		break;
 	case DD_CLASS_TYPE_LEVEL_NUM:
@@ -758,7 +759,7 @@ static int param_set_dyndbg_module_classes(const char *instr,
 		old_bits = CLASSMAP_BITMASK(*dcp->lvl);
 		new_bits = CLASSMAP_BITMASK(inrep);
 		v2pr_info("lvl:%ld bits:0x%lx > %s\n", inrep, new_bits, KP_NAME(kp));
-		totct += ddebug_apply_class_bitmap(dcp, &new_bits, &old_bits, modnm);
+		totct += ddebug_apply_class_bitmap(dcp, &new_bits, old_bits, modnm);
 		*dcp->lvl = inrep;
 		break;
 	default:
Signature · 1 line
2.45.2
author maintainer
#13 lore raw

PATCH v9 13/52 dyndbg: reduce verbose=3 messages in ddebug_add_module

In reply to Jim Cromie

When modprobing a module, dyndbg currently logs/says "add-module", and then "skipping" if the module has no prdbgs. Instead just check 1st and return quietly.

no functional change

---
 lib/dynamic_debug.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)
lib/dynamic_debug.c +3 -4
index d4a0ae31d059..43a8e04b8599 100644
@@ -1245,11 +1245,10 @@ static int ddebug_add_module(struct _ddebug_info *di, const char *modname)
 {
 	struct ddebug_table *dt;
 
-	v3pr_info("add-module: %s.%d sites\n", modname, di->num_descs);
-	if (!di->num_descs) {
-		v3pr_info(" skip %s\n", modname);
+	if (!di->num_descs)
 		return 0;
-	}
+
+	v3pr_info("add-module: %s %d sites\n", modname, di->num_descs);
 
 	dt = kzalloc(sizeof(*dt), GFP_KERNEL);
 	if (dt == NULL) {
Signature · 1 line
2.45.2
author maintainer
#14 lore raw

PATCH v9 14/52 dyndbg-API: remove DD_CLASS_TYPE_(DISJOINT|LEVEL)_NAMES and code

In reply to Jim Cromie

Remove the NAMED class types; these 2 classmap types accept class names at the PARAM interface, for example:

echo +DRM_UT_CORE,-DRM_UT_KMS > /sys/module/drm/parameters/debug_names

The code works, but its only used by test-dynamic-debug, and wasn't asked for by anyone else, so reduce test-surface, simplify things.

also rename enum class_map_type to enum ddebug_class_map_type.

---
 include/linux/dynamic_debug.h |  23 ++------
 lib/dynamic_debug.c           | 102 +++-------------------------------
 lib/test_dynamic_debug.c      |  26 ---------
 3 files changed, 14 insertions(+), 137 deletions(-)
include/linux/dynamic_debug.h +6 -17
index 8116d0a0d33a..dd304e231f08 100644
@@ -58,27 +58,16 @@ struct _ddebug {
 #endif
 } __attribute__((aligned(8)));
 
-enum class_map_type {
+enum ddebug_class_map_type {
 	DD_CLASS_TYPE_DISJOINT_BITS,
 	/**
-	 * DD_CLASS_TYPE_DISJOINT_BITS: classes are independent, one per bit.
-	 * expecting hex input. Built for drm.debug, basis for other types.
+	 * DD_CLASS_TYPE_DISJOINT_BITS: classes are independent, mapped to bits[0..N].
+	 * Expects hex input. Built for drm.debug, basis for other types.
 	 */
 	DD_CLASS_TYPE_LEVEL_NUM,
 	/**
-	 * DD_CLASS_TYPE_LEVEL_NUM: input is numeric level, 0-N.
-	 * N turns on just bits N-1 .. 0, so N=0 turns all bits off.
-	 */
-	DD_CLASS_TYPE_DISJOINT_NAMES,
-	/**
-	 * DD_CLASS_TYPE_DISJOINT_NAMES: input is a CSV of [+-]CLASS_NAMES,
-	 * classes are independent, like _DISJOINT_BITS.
-	 */
-	DD_CLASS_TYPE_LEVEL_NAMES,
-	/**
-	 * DD_CLASS_TYPE_LEVEL_NAMES: input is a CSV of [+-]CLASS_NAMES,
-	 * intended for names like: INFO,DEBUG,TRACE, with a module prefix
-	 * avoid EMERG,ALERT,CRIT,ERR,WARNING: they're not debug
+	 * DD_CLASS_TYPE_LEVEL_NUM: input is numeric level, 0..N.
+	 * Input N turns on bits 0..N-1
 	 */
 };
 
@@ -88,7 +77,7 @@ struct ddebug_class_map {
 	const char **class_names;
 	const int length;
 	const int base;		/* index of 1st .class_id, allows split/shared space */
-	enum class_map_type map_type;
+	enum ddebug_class_map_type map_type;
 };
 
 /**
lib/dynamic_debug.c +8 -94

125 lines not on this page · raw message

lib/test_dynamic_debug.c +0 -26
index a01f0193a419..9e950a911b6c 100644
@@ -74,13 +74,6 @@ DECLARE_DYNDBG_CLASSMAP(map_disjoint_bits, DD_CLASS_TYPE_DISJOINT_BITS, 0,
 DD_SYS_WRAP(disjoint_bits, p);
 DD_SYS_WRAP(disjoint_bits, T);
 
-/* symbolic input, independent bits */
-enum cat_disjoint_names { LOW = 10, MID, HI };
-DECLARE_DYNDBG_CLASSMAP(map_disjoint_names, DD_CLASS_TYPE_DISJOINT_NAMES, 10,
-			"LOW", "MID", "HI");
-DD_SYS_WRAP(disjoint_names, p);
-DD_SYS_WRAP(disjoint_names, T);
-
 /* numeric verbosity, V2 > V1 related */
 enum cat_level_num { V0 = 14, V1, V2, V3, V4, V5, V6, V7 };
 DECLARE_DYNDBG_CLASSMAP(map_level_num, DD_CLASS_TYPE_LEVEL_NUM, 14,
@@ -88,13 +81,6 @@ DECLARE_DYNDBG_CLASSMAP(map_level_num, DD_CLASS_TYPE_LEVEL_NUM, 14,
 DD_SYS_WRAP(level_num, p);
 DD_SYS_WRAP(level_num, T);
 
-/* symbolic verbosity */
-enum cat_level_names { L0 = 22, L1, L2, L3, L4, L5, L6, L7 };
-DECLARE_DYNDBG_CLASSMAP(map_level_names, DD_CLASS_TYPE_LEVEL_NAMES, 22,
-			"L0", "L1", "L2", "L3", "L4", "L5", "L6", "L7");
-DD_SYS_WRAP(level_names, p);
-DD_SYS_WRAP(level_names, T);
-
 /* stand-in for all pr_debug etc */
 #define prdbg(SYM) __pr_debug_cls(SYM, #SYM " msg\n")
 
@@ -102,10 +88,6 @@ static void do_cats(void)
 {
 	pr_debug("doing categories\n");
 
-	prdbg(LOW);
-	prdbg(MID);
-	prdbg(HI);
-
 	prdbg(D2_CORE);
 	prdbg(D2_DRIVER);
 	prdbg(D2_KMS);
@@ -129,14 +111,6 @@ static void do_levels(void)
 	prdbg(V5);
 	prdbg(V6);
 	prdbg(V7);
-
-	prdbg(L1);
-	prdbg(L2);
-	prdbg(L3);
-	prdbg(L4);
-	prdbg(L5);
-	prdbg(L6);
-	prdbg(L7);
 }
 
 static void do_prints(void)
Signature · 1 line
2.45.2
author maintainer
#15 lore raw

PATCH v9 15/52 dyndbg-API: fix DECLARE_DYNDBG_CLASSMAP

In reply to Jim Cromie

DECLARE_DYNDBG_CLASSMAP() has a design error; its usage fails a basic K&R rule: "define once, refer many times".

It is used across DRM core & drivers, each use re-defines the classmap understood by that module; and all must match for the modules to respond together when DRM.debug categories are enabled. This is brittle; a maintenance foot-gun.

Worse, it causes the CONFIG_DRM_USE_DYNAMIC_DEBUG=Y regression; 1st drm.ko loads, and dyndbg initializes its DRM.debug callsites, then a drm-driver loads, but too late - it missed the DRM.debug enablement.

So replace it with 2 macros:
DYNDBG_CLASSMAP_DEFINE - invoked once from core - drm.ko
DYNDBG_CLASSMAP_USE - from all drm drivers and helpers.

DYNDBG_CLASSMAP_DEFINE: it reuses a renamed DECLARE_DYNDBG_CLASSMAP to construct the struct classmap variable, but it drops the static qualifier, and exports it instead.

DYNDBG_CLASSMAP_USE: then refers to the exported var by name:
* used from drivers, helper-mods
* lets us drop the repetitive "classname" args
* fixes 2nd-defn problem
* creates a ddebug_class_user record in new __dyndbg_class_users section this allows ddebug_add_module(etal) to handle them per-module.

DECLARE_DYNDBG_CLASSMAP is preserved temporarily, to decouple DRM adaptation work and avoid compile-errs before its done. IOW, DRM gets fixed when they commit the adopt-new-api patches.

The DEFINE,USE distinction, and the separate classmap-use record, allows dyndbg to initialize the driver's & helper's DRM.debug callsites separately after each is modprobed.

Basically, the classmap init-scan repeated for classmap-users.

To review, dyndbg's existing __dyndbg_classes[] section does:

. catalogs the classmaps defined by a module (or builtin modules) . tells dyndbg the module has class'd prdbgs, allowing >control . DYNDBG_CLASSMAP_DEFINE creates classmaps in this section.

This patch adds __dyndbg_class_users[] section:

. catalogs uses/references to the classmap definitions.
. authorizes dyndbg to >control those class'd prdbgs in ref'g module. . DYNDBG_CLASSMAP_USE() creates classmap-user records in this new section.

Now ddebug_add_module(etal) can handle classmap-uses similar to (and after) classmaps; when a dependent module is loaded, if it has classmap-uses (to a classmap-def in another module), that module's kernel params are scanned to find if it has a kparam that is wired to dyndbg's param-ops, and whose classmap is the one being ref'd.

To support this, theres a few data/header changes:

new struct ddebug_class_user
contains: user-module-name, &classmap-defn
it records drm-driver's use of a classmap in the section, allowing lookup

struct ddebug_info gets 2 more fields to keep the new section with the others:
class_users, num_class_users.
set by dynamic_debug_init() for builtins.
or by kernel/module/main:load_info() for loadable modules.

vmlinux.lds.h: new BOUNDED_SECTION for __dyndbg_class_users

dynamic_debug.c has 2 changes in ddebug_add_module(), ddebug_change():

ddebug_add_module() already calls ddebug_attach_module_classes() to handle classmaps DEFINEd by a module, now it also calls ddebug_attach_user_module_classes() to handle USEd classmaps. To avoid this work when possible, 1st scan the module's descriptors and count the number of class'd pr_debugs.

ddebug_attach_user_module_classes() scans the module's class_users section, follows the refs to the parent's classmap, and calls ddebug_apply_params() on each. It also avoids work by checking the module's class-ct.

ddebug_apply_params(new fn):

It scans module's/builtin kernel-params, calls ddebug_match_apply_kparam for each to find the params/sysfs-nodes which may be wired to a classmap.

ddebug_match_apply_kparam(new fn):

1st, it tests the kernel-param.ops is dyndbg's; this guarantees that the attached arg is a struct ddebug_class_param, which has a ref to the param's state, and to the classmap defining the param's handling.

2nd, it requires that the classmap ref'd by the kparam is the one we're called for; modules can use many separate classmaps (as test_dynamic_debug does).

Then apply the "parent" kparam's setting to the dependent module, using ddebug_apply_class_bitmap().

ddebug_change(and callees) also gets adjustments:

ddebug_find_valid_class(): This does a search over the module's classmaps, looking for the class FOO echo'd to >control. So now it searches over __dyndbg_class_users[] after __dyndbg_classes[].

ddebug_class_name(): return class-names for defined AND used classes.

test_dynamic_debug.c, test_dynamic_debug_submod.c:

This demonstrates the 2 types of classmaps & sysfs-params, following the 4-part recipe:

1. define an enum for the classmap: DRM.debug has DRM_UT_{CORE,KMS,...} multiple classes must share 0-62 classid space.
2. DYNDBG_CLASSMAP_DEFINE(.. DRM_UT_{CORE,KMS,...})
3. DYNDBG_CLASSMAP_PARAM* (classmap)
4. DYNDBG_CLASSMAP_USE()
by _submod only, skipping 2,3

Move all the enum declarations together, to better explain how they share the 0..62 class-id space available to a module (non-overlapping subranges).

reorg macros 2,3 by name. This gives a tabular format, making it easy to see the pattern of repetition, and the points of change.

And extend the test to replicate the 2-module (parent & dependent) scenario which caused the CONFIG_DRM_USE_DYNAMIC_DEBUG=y regression seen in drm & drivers.

The _submod.c is a 2-line file: #define _SUBMOD, #include parent.

This gives identical complements of prdbgs in parent & _submod, and thus identical print behavior when all of: >control, >params, and parent->_submod propagation are working correctly.

It also puts all the parent/_submod declarations together in the same source, with the new ifdef _SUBMOD block invoking DYNDBG_CLASSMAP_USE for the 2 test-interfaces. I think this is clearer.

These 2 modules are both tristate, allowing 3 super/sub combos: Y/Y, Y/M, M/M (not N/N). Y/Y testing exposed a missing __align(8) in the _METADATA macro, which M/M didn't see because the module-loader memory placement constrains it instead.

DEBUG details:

``#define DEBUG`` in src enables all pr_debugs after it, including any class'd pr_debugs; its not necessarily all-or-nothing, unless you do the define in a header. Also, the only way to disable a class'd pr_debug is via the classmap-kparam or using "class foo" in control queries, to address the classes by name.

NB: this patch ignores a checkpatch do-while warning; which is wrong for declarative macros like these:

arch/powerpc/platforms/cell/spu_base.c
48:static DEFINE_SPINLOCK(spu_lock);
62:static DEFINE_SPINLOCK(spu_full_list_lock);
63:static DEFINE_MUTEX(spu_full_list_mutex);

Fixes aad0214f3026 ("dyndbg: add DECLARE_DYNDBG_CLASSMAP macro")

---
v8 - split drm parts to separate commits.
preserve DECLARE_DYNDBG_CLASSMAP to decouple DRM, no flag day. fixup block comment

v7 - previous submission-blocking bug:

missing __align(8) in DYNAMIC_DEBUG_DECLARE_METADATA on ddebug_class_user caused corrupt records, but only for builtin modules; module loader code probably pinned allocations to the right alignment naturally, hiding the bug for typical builds.

v6- get rid of WARN_ON_ONCE
v?- fix _var expanded 2x in macro

---
 MAINTAINERS                       |   2 +-
 include/asm-generic/vmlinux.lds.h |   1 +
 include/linux/dynamic_debug.h     |  62 ++++++++--
 kernel/module/main.c              |   3 +
 lib/Kconfig.debug                 |  24 +++-
 lib/Makefile                      |   3 +
 lib/dynamic_debug.c               | 184 ++++++++++++++++++++++++++----
 lib/test_dynamic_debug.c          | 111 ++++++++++++------
 lib/test_dynamic_debug_submod.c   |  10 ++
 9 files changed, 332 insertions(+), 68 deletions(-)
 create mode 100644 lib/test_dynamic_debug_submod.c
MAINTAINERS +1 -1
index 28e20975c26f..c9ed48109ff5 100644
@@ -7526,7 +7526,7 @@ M:	Jim Cromie <[email protected]>
 S:	Maintained
 F:	include/linux/dynamic_debug.h
 F:	lib/dynamic_debug.c
-F:	lib/test_dynamic_debug.c
+F:	lib/test_dynamic_debug*.c
 
 DYNAMIC INTERRUPT MODERATION
 M:	Tal Gilboa <[email protected]>
include/asm-generic/vmlinux.lds.h +1 -0
index f7749d0f2562..f1d8e64b244c 100644
@@ -365,6 +365,7 @@
 	/* implement dynamic printk debug */				\
 	. = ALIGN(8);							\
 	BOUNDED_SECTION_BY(__dyndbg_classes, ___dyndbg_classes)		\
+	BOUNDED_SECTION_BY(__dyndbg_class_users, ___dyndbg_class_users)	\
 	BOUNDED_SECTION_BY(__dyndbg, ___dyndbg)				\
 	LIKELY_PROFILE()		       				\
 	BRANCH_PROFILE()						\
include/linux/dynamic_debug.h +55 -7

86 lines not on this page · raw message

kernel/module/main.c +3 -0
index e1e8a7a9d6c1..9f7ce0f0e6e5 100644
@@ -2217,6 +2217,9 @@ static int find_module_sections(struct module *mod, struct load_info *info)
 	mod->dyndbg_info.classes = section_objs(info, "__dyndbg_classes",
 						sizeof(*mod->dyndbg_info.classes),
 						&mod->dyndbg_info.num_classes);
+	mod->dyndbg_info.class_users = section_objs(info, "__dyndbg_class_users",
+						    sizeof(*mod->dyndbg_info.class_users),
+						   &mod->dyndbg_info.num_class_users);
 #endif
 
 	return 0;
lib/Kconfig.debug +19 -5
index 291185f54ee4..16288bdaa944 100644
@@ -2797,12 +2797,26 @@ config TEST_STATIC_KEYS
 	  If unsure, say N.
 
 config TEST_DYNAMIC_DEBUG
-	tristate "Test DYNAMIC_DEBUG"
-	depends on DYNAMIC_DEBUG
+	tristate "Build test-dynamic-debug module"
+	depends on DYNAMIC_DEBUG || DYNAMIC_DEBUG_CORE
 	help
-	  This module registers a tracer callback to count enabled
-	  pr_debugs in a 'do_debugging' function, then alters their
-	  enablements, calls the function, and compares counts.
+	  This module exercises/demonstrates dyndbg's classmap API, by
+	  creating 2 classes: a DISJOINT classmap (supporting DRM.debug)
+	  and a LEVELS/VERBOSE classmap (like verbose2 > verbose1).
+
+	  If unsure, say N.
+
+config TEST_DYNAMIC_DEBUG_SUBMOD
+	tristate "Build test-dynamic-debug submodule"
+	default m
+	depends on DYNAMIC_DEBUG || DYNAMIC_DEBUG_CORE
+	depends on TEST_DYNAMIC_DEBUG
+	help
+	  This sub-module uses a classmap defined and exported by the
+	  parent module, recapitulating drm & driver's shared use of
+	  drm.debug to control enabled debug-categories.
+	  It is tristate, independent of parent, to allow testing all
+	  proper combinations of parent=y/m submod=y/m.
 
 	  If unsure, say N.
 
lib/Makefile +3 -0
index ffc6b2341b45..d3e6a48f202b 100644
@@ -82,6 +82,7 @@ obj-$(CONFIG_TEST_USER_COPY) += test_user_copy.o
 obj-$(CONFIG_TEST_STATIC_KEYS) += test_static_keys.o
 obj-$(CONFIG_TEST_STATIC_KEYS) += test_static_key_base.o
 obj-$(CONFIG_TEST_DYNAMIC_DEBUG) += test_dynamic_debug.o
+obj-$(CONFIG_TEST_DYNAMIC_DEBUG_SUBMOD) += test_dynamic_debug_submod.o
 obj-$(CONFIG_TEST_PRINTF) += test_printf.o
 obj-$(CONFIG_TEST_SCANF) += test_scanf.o
 
@@ -240,6 +241,8 @@ obj-$(CONFIG_HAVE_ARCH_TRACEHOOK) += syscall.o
 obj-$(CONFIG_DYNAMIC_DEBUG_CORE) += dynamic_debug.o
 #ensure exported functions have prototypes
 CFLAGS_dynamic_debug.o := -DDYNAMIC_DEBUG_MODULE
+CFLAGS_test_dynamic_debug.o := -DDYNAMIC_DEBUG_MODULE
+CFLAGS_test_dynamic_debug_submod.o := -DDYNAMIC_DEBUG_MODULE
 
 obj-$(CONFIG_SYMBOLIC_ERRNAME) += errname.o
 
lib/dynamic_debug.c +162 -22

285 lines not on this page · raw message

lib/test_dynamic_debug.c +78 -33

145 lines not on this page · raw message

lib/test_dynamic_debug_submod.c new file +10 -0
new file mode 100644
index 000000000000..9a893402ce1a
@@ -0,0 +1,10 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Kernel module for testing dynamic_debug
+ *
+ * Authors:
+ *      Jim Cromie	<[email protected]>
+ */
+
+#define TEST_DYNAMIC_DEBUG_SUBMOD
+#include "test_dynamic_debug.c"
Signature · 1 line
2.45.2
author maintainer
#16 lore raw

PATCH v9 16/52 selftests-dyndbg: add tools/testing/selftests/dynamic_debug/*

In reply to Jim Cromie

Add a selftest script for dynamic-debug. The config requires CONFIG_TEST_DYNAMIC_DEBUG=m (and CONFIG_TEST_DYNAMIC_DEBUG_SUBMOD=m), which tacitly requires either CONFIG_DYNAMIC_DEBUG=y or CONFIG_DYNAMIC_DEBUG_CORE=y

ATM this has just basic_tests(), it modifies pr_debug flags in a few builtins (init/main, params), counts the callsite flags changed, and verifies against expected values.

This is backported from another feature branch; the support-fns (thx Lukas) have unused features at the moment, they'll get used shortly.

The script enables simple virtme-ng testing:

  $> vng --verbose --name v6.8-32-g30d431000676 --user root \
     --cwd ../.. -a dynamic_debug.verbose=2 -p 4 \
     ./tools/testing/selftests/dynamic_debug/dyndbg_selftest.sh

virtme: waiting for virtiofsd to start
virtme: use 'microvm' QEMU architecture
...

[    4.136168] virtme-init: Setting hostname to v6.8-32-g30d431000676...
[    4.240874] virtme-init: starting script
test_dynamic_debug_submod not there
test_dynamic_debug not there
...
[    4.474435] virtme-init: script returned {0}
Powering off.
[    4.529318] ACPI: PM: Preparing to enter system sleep state S5
[    4.529991] kvm: exiting hardware virtualization
[    4.530428] reboot: Power down

And add dynamic_debug to TARGETS, so make run_tests sees it properly

for the impatient, set TARGETS explicitly:

bash-5.2# make TARGETS=dynamic_debug run_tests
make[1]: ...
TAP version 13
1..1

[   35.552922] dyndbg: read 3 bytes from userspace
[   35.553099] dyndbg: query 0: "=_" mod:*
[   35.553544] dyndbg: processed 1 queries, with 1778 matches, 0 errs

...

TLDR:

This selftest is slightly naive wrt the init state of call-site flags.

In particular, it fails if class'd pr_debugs have been set

  $ cat /etc/modprobe.d/drm-test.conf
  options drm dyndbg=class,DRM_UT_CORE,+mfslt%class,DRM_UT_KMS,+mf

By Contract, class'd pr_debugs are protected from alteration by default (only by direct "class FOO" queries), so the "=_" logged above (TAP version 13) cannot affect the DRM_UT_CORE,KMS pr_debugs.

These class'd flag-settings, added by modprobe, alter the counts of flag-matching patterns, breaking the tests' expectations.

---
 MAINTAINERS                                   |   1 +
 tools/testing/selftests/Makefile              |   1 +
 .../testing/selftests/dynamic_debug/Makefile  |   9 +
 tools/testing/selftests/dynamic_debug/config  |   2 +
 .../dynamic_debug/dyndbg_selftest.sh          | 231 ++++++++++++++++++
 5 files changed, 244 insertions(+)
 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
MAINTAINERS +1 -0
index c9ed48109ff5..e7bb7b1c44c8 100644
@@ -7527,6 +7527,7 @@ S:	Maintained
 F:	include/linux/dynamic_debug.h
 F:	lib/dynamic_debug.c
 F:	lib/test_dynamic_debug*.c
+F:	tools/testing/selftest/dynamic_debug/*
 
 DYNAMIC INTERRUPT MODERATION
 M:	Tal Gilboa <[email protected]>
tools/testing/selftests/Makefile +1 -0
index e1504833654d..84edf0bd8e80 100644
@@ -20,6 +20,7 @@ TARGETS += drivers/s390x/uvdevice
 TARGETS += drivers/net/bonding
 TARGETS += drivers/net/team
 TARGETS += dt
+TARGETS += dynamic_debug
 TARGETS += efivarfs
 TARGETS += exec
 TARGETS += fchmodat2
tools/testing/selftests/dynamic_debug/Makefile new file +9 -0
new file mode 100644
index 000000000000..6d06fa7f1040
@@ -0,0 +1,9 @@
+# SPDX-License-Identifier: GPL-2.0-only
+# borrowed from Makefile for user memory selftests
+
+# No binaries, but make sure arg-less "make" doesn't trigger "run_tests"
+all:
+
+TEST_PROGS := dyndbg_selftest.sh
+
+include ../lib.mk
tools/testing/selftests/dynamic_debug/config new file +2 -0
new file mode 100644
index 000000000000..d080da571ac0
@@ -0,0 +1,2 @@
+CONFIG_TEST_DYNAMIC_DEBUG=m
+CONFIG_TEST_DYNAMIC_DEBUG_SUBMOD=m
tools/testing/selftests/dynamic_debug/dyndbg_selftest.sh new file +231 -0

231 lines not on this page · raw message

Signature · 1 line
2.45.2
author maintainer
#17 lore raw

PATCH v9 17/52 dyndbg-API: promote DYNDBG_CLASSMAP_PARAM to API

In reply to Jim Cromie

move the DYNDBG_CLASSMAP_PARAM macro from test-dynamic-debug.c into the header, and refine it, by distinguishing the 2 use cases:

1.DYNDBG_CLASSMAP_PARAM_REF
for DRM, to pass in extern __drm_debug by name. dyndbg keeps bits in it, so drm can still use it as before

2.DYNDBG_CLASSMAP_PARAM
new user (test_dynamic_debug) doesn't need to share state, decls a static long unsigned int to store the bitvec.

__DYNDBG_CLASSMAP_PARAM
bottom layer - allocate,init a ddebug-class-param, module-param-cb.

Also clean up and improve comments in test-code, and add MODULE_DESCRIPTIONs.

---

fixup drm-print.h add PARAM_REF forwarding macros

with DYNDBG_CLASSMAP_PARAM_REF in the API, add DRM_ variant

---
 include/linux/dynamic_debug.h   | 37 ++++++++++++++++-
 lib/dynamic_debug.c             | 70 ++++++++++++++++++++++-----------
 lib/test_dynamic_debug.c        | 50 +++++++++--------------
 lib/test_dynamic_debug_submod.c |  9 ++++-
 4 files changed, 110 insertions(+), 56 deletions(-)
include/linux/dynamic_debug.h +36 -1
index 2c6944c0d6cd..19f959f9a6b4 100644
@@ -91,7 +91,7 @@ struct ddebug_class_map {
  * used to validate a "class FOO .." >control command on the module
  */
 #define __DYNDBG_CLASSMAP_DEFINE(_var, _maptype, _base, ...)		\
-	const char *_var##_classnames[] = { __VA_ARGS__ };		\
+	static const char *_var##_classnames[] = { __VA_ARGS__ };	\
 	struct ddebug_class_map __aligned(8) __used			\
 		__section("__dyndbg_classes") _var = {			\
 		.mod = THIS_MODULE,					\
@@ -164,6 +164,41 @@ struct ddebug_class_param {
 	const struct ddebug_class_map *map;
 };
 
+/**
+ * DYNDBG_CLASSMAP_PARAM - wrap a dyndbg-classmap with a controlling sys-param
+ * @_name  sysfs node name
+ * @_var   name of the struct classmap var defining the controlled classes
+ * @_flags flags to be toggled, typically just 'p'
+ *
+ * Creates a sysfs-param to control the classes defined by the
+ * classmap.  Keeps bits in a private/static
+ */
+#define DYNDBG_CLASSMAP_PARAM(_name, _var, _flags)			\
+	static unsigned long _name##_bvec;				\
+	__DYNDBG_CLASSMAP_PARAM(_name, _name##_bvec, _var, _flags)
+
+/**
+ * DYNDBG_CLASSMAP_PARAM_REF - wrap a dyndbg-classmap with a controlling sys-param
+ * @_name  sysfs node name
+ * @_bits  name of the module's unsigned long bit-vector, ex: __drm_debug
+ * @_var   name of the struct classmap var defining the controlled classes
+ * @_flags flags to be toggled, typically just 'p'
+ *
+ * Creates a sysfs-param to control the classmap, keeping bitvec in user @_bits.
+ * This lets drm use __drm_debug elsewhere too.
+ */
+#define DYNDBG_CLASSMAP_PARAM_REF(_name, _bits, _var, _flags)		\
+	__DYNDBG_CLASSMAP_PARAM(_name, _bits, _var, _flags)
+
+#define __DYNDBG_CLASSMAP_PARAM(_name, _bits, _var, _flags)		\
+	static struct ddebug_class_param _name##_##_flags = {		\
+		.bits = &(_bits),					\
+		.flags = #_flags,					\
+		.map = &(_var),						\
+	};								\
+	module_param_cb(_name, &param_ops_dyndbg_classes,		\
+			&_name##_##_flags, 0600)
+
 /*
  * pr_debug() and friends are globally enabled or modules have selectively
  * enabled them.
lib/dynamic_debug.c +47 -23

104 lines not on this page · raw message

lib/test_dynamic_debug.c +19 -31

92 lines not on this page · raw message

lib/test_dynamic_debug_submod.c +8 -1
index 9a893402ce1a..0d15f3ffe466 100644
@@ -1,6 +1,9 @@
 // SPDX-License-Identifier: GPL-2.0
 /*
- * Kernel module for testing dynamic_debug
+ * Kernel module to test/demonstrate dynamic_debug features,
+ * particularly classmaps and their support for subsystems, like DRM,
+ * which defines its drm_debug classmap in drm module, and uses it in
+ * helpers & drivers.
  *
  * Authors:
  *      Jim Cromie	<[email protected]>
@@ -8,3 +11,7 @@
 
 #define TEST_DYNAMIC_DEBUG_SUBMOD
 #include "test_dynamic_debug.c"
+
+MODULE_DESCRIPTION("test/demonstrate dynamic-debug subsystem support");
+MODULE_AUTHOR("Jim Cromie <[email protected]>");
+MODULE_LICENSE("GPL");
Signature · 1 line
2.45.2
author maintainer
#18 lore raw

PATCH v9 18/52 dyndbg-doc: add classmap info to howto

In reply to Jim Cromie

Describe the 3 API macros providing dynamic_debug's classmaps

DYNDBG_CLASSMAP_DEFINE - create, exports a module's classmap
DYNDBG_CLASSMAP_USE - refer to exported map
DYNDBG_CLASSMAP_PARAM - bind control param to the classmap DYNDBG_CLASSMAP_PARAM_REF + use module's storage - __drm_debug

---
v5 adjustments per Randy Dunlap
v7 checkpatch fixes
v8 more

---
 .../admin-guide/dynamic-debug-howto.rst       | 63 ++++++++++++++++++-
 1 file changed, 62 insertions(+), 1 deletion(-)
Documentation/admin-guide/dynamic-debug-howto.rst +62 -1
index 6a8ce5a34382..742eb4230c6e 100644
@@ -225,7 +225,6 @@ the ``p`` flag has meaning, other flags are ignored.
 Note the regexp ``^[-+=][fslmpt_]+$`` matches a flags specification.
 To clear all flags at once, use ``=_`` or ``-fslmpt``.
 
-
 Debug messages during Boot Process
 ==================================
 
@@ -375,3 +374,65 @@ just a shortcut for ``print_hex_dump(KERN_DEBUG)``.
 For ``print_hex_dump_debug()``/``print_hex_dump_bytes()``, format string is
 its ``prefix_str`` argument, if it is constant string; or ``hexdump``
 in case ``prefix_str`` is built dynamically.
+
+Dynamic Debug classmaps
+=======================
+
+Dyndbg allows selection/grouping of *prdbg* callsites using structural
+info: module, file, function, line.  Classmaps allow authors to add
+their own domain-oriented groupings using class-names.  Classmaps are
+exported, so they referencable from other modules.
+
+  # enable classes individually
+  :#> ddcmd class DRM_UT_CORE +p
+  :#> ddcmd class DRM_UT_KMS +p
+  # or more selectively
+  :#> ddcmd class DRM_UT_CORE module drm +p
+
+The "class FOO" syntax protects class'd prdbgs from generic overwrite::
+
+  # IOW this doesn't wipe any DRM.debug settings
+  :#> ddcmd -p
+
+To support the DRM.debug parameter, DYNDBG_CLASSMAP_PARAM* updates all
+classes in a classmap, mapping param-bits 0..N onto the classes:
+DRM_UT_<*> for the DRM use-case.
+
+Dynamic Debug Classmap API
+==========================
+
+DYNDBG_CLASSMAP_DEFINE - modules use this to create classmaps, naming
+each of the classes (stringified enum-symbols: "DRM_UT_<*>"), and
+type, and mapping the class-names to consecutive _class_ids.
+
+By doing so, modules tell dyndbg that they have prdbgs with those
+class_ids, and they authorize dyndbg to accept "class FOO" for the
+module defining the classmap, and its contained classnames.
+
+DYNDBG_CLASSMAP_USE - drm drivers invoke this to ref the CLASSMAP that
+drm DEFINEs.  This shares the classmap definition, and authorizes
+dyndbg to apply changes to the user module's class'd pr_debugs.  It
+also tells dyndbg how to initialize the user's prdbgs at modprobe,
+based upon the current setting of the parent's controlling param.
+
+There are 2 types of classmaps:
+
+ DD_CLASS_TYPE_DISJOINT_BITS: classes are independent, like DRM.debug
+ DD_CLASS_TYPE_LEVEL_NUM: classes are relative, ordered (V3 > V2)
+
+DYNDBG_CLASSMAP_PARAM - modelled after module_param_cb, it refers to a
+DEFINEd classmap, and associates it to the param's data-store.  This
+state is then applied to DEFINEr and USEr modules when they're modprobed.
+
+This interface also enforces the DD_CLASS_TYPE_LEVEL_NUM relation
+amongst the contained classnames; all classes are independent in the
+control parser itself.
+
+Modules or module-groups (drm & drivers) can define multiple
+classmaps, as long as they share the limited 0..62 per-module-group
+_class_id range, without overlap.
+
+``#define DEBUG`` will enable all pr_debugs in scope, including any
+class'd ones.  This won't be reflected in the PARAM readback value,
+but the class'd pr_debug callsites can be forced off by toggling the
+classmap-kparam all-on then all-off.
Signature · 1 line
2.45.2
author maintainer
#19 lore raw

PATCH v9 19/52 dyndbg: treat comma as a token separator

In reply to Jim Cromie

Treat comma as a token terminator, just like a space. This allows a user to avoid quoting hassles when spaces are otherwise needed:

:#> modprobe drm dyndbg=class,DRM_UT_CORE,+p\;class,DRM_UT_KMS,+p

or as a boot arg:

drm.dyndbg=class,DRM_UT_CORE,+p # todo: support multi-query here

Given the many ways a boot-line +args can be assembled and then passed in/down/around shell based tools, this may allow side-stepping all sorts of quoting hassles thru those layers.

existing query format:

modprobe test_dynamic_debug dyndbg="class D2_CORE +p"

new format:

modprobe test_dynamic_debug dyndbg=class,D2_CORE,+p

---
 lib/dynamic_debug.c | 17 +++++++++++++----
 1 file changed, 13 insertions(+), 4 deletions(-)
lib/dynamic_debug.c +13 -4
index e9a95b0f3757..235d85765b63 100644
@@ -290,6 +290,14 @@ static int ddebug_change(const struct ddebug_query *query,
 	return nfound;
 }
 
+static char *skip_spaces_and_commas(const char *str)
+{
+	str = skip_spaces(str);
+	while (*str == ',')
+		str = skip_spaces(++str);
+	return (char *)str;
+}
+
 /*
  * Split the buffer `buf' into space-separated words.
  * Handles simple " and ' quoting, i.e. without nested,
@@ -303,8 +311,8 @@ static int ddebug_tokenize(char *buf, char *words[], int maxwords)
 	while (*buf) {
 		char *end;
 
-		/* Skip leading whitespace */
-		buf = skip_spaces(buf);
+		/* Skip leading whitespace and comma */
+		buf = skip_spaces_and_commas(buf);
 		if (!*buf)
 			break;	/* oh, it was trailing whitespace */
 		if (*buf == '#')
@@ -320,7 +328,7 @@ static int ddebug_tokenize(char *buf, char *words[], int maxwords)
 				return -EINVAL;	/* unclosed quote */
 			}
 		} else {
-			for (end = buf; *end && !isspace(*end); end++)
+			for (end = buf; *end && !isspace(*end) && *end != ','; end++)
 				;
 			if (end == buf) {
 				pr_err("parse err after word:%d=%s\n", nwords,
@@ -592,7 +600,8 @@ static int ddebug_exec_queries(char *query, const char *modname)
 		if (split)
 			*split++ = '\0';
 
-		query = skip_spaces(query);
+		query = skip_spaces_and_commas(query);
+
 		if (!query || !*query || *query == '#')
 			continue;
 
Signature · 1 line
2.45.2
author maintainer
#20 lore raw

PATCH v9 20/52 selftests-dyndbg: add comma_terminator_tests

In reply to Jim Cromie

New fn validates parsing and effect of queries using combinations of commas and spaces to delimit the tokens.

It manipulates pr-debugs in builtin module/params, so might have deps I havent foreseen on odd configurations.

---
 .../selftests/dynamic_debug/dyndbg_selftest.sh     | 14 ++++++++++++++
 1 file changed, 14 insertions(+)
tools/testing/selftests/dynamic_debug/dyndbg_selftest.sh +14 -0
index 1be70af26a38..b4ba293ab227 100755
@@ -212,9 +212,23 @@ EOF
     ddcmd =_
 }
 
+function comma_terminator_tests {
+    echo -e "${GREEN}# COMMA_TERMINATOR_TESTS ${NC}"
+    # try combos of spaces & commas
+    check_match_ct '\[params\]' 4 -r
+    ddcmd module,params,=_		# commas as spaces
+    ddcmd module,params,+mpf		# turn on module's pr-debugs
+    check_match_ct =pmf 4
+    ddcmd ,module ,, ,  params, -p
+    check_match_ct =mf 4
+    ddcmd " , module ,,, ,  params, -m"	#
+    check_match_ct =f 4
+    ddcmd =_
+}
 
 tests_list=(
     basic_tests
+    comma_terminator_tests
 )
 
 # Run tests
Signature · 1 line
2.45.2
author maintainer
#21 lore raw

PATCH v9 21/52 dyndbg: split multi-query strings with %

In reply to Jim Cromie

Since commit
85f7f6c0edb8 ("dynamic_debug: process multiple debug-queries on a line")

Multi-query commands have been allowed:

modprobe drm dyndbg="class DRM_UT_CORE +p; class DRM_UT_KMS +p" modprobe drm dyndbg=<<EOX
class DRM_UT_CORE +p
class DRM_UT_KMS +p
EOX

More recently, the need for quoting was avoided by treating a comma like a space/token-terminator:

modprobe drm dyndbg=class,DRM_UT_CORE,+p\;class,DRM_UT_KMS,+p

That works, but it needs the escaped semicolon, which is a shell special-char (one of the bash control operators), so it is brittle when passed in/down/around scripts. In particular, it fails when passed to vng (virtme-ng).

So this patch adds '%' to the existing ';' and '\n' multi-command separators, which is more shell-friendly, so you can more fully avoid quoting and escaping hassles.

NOTE: it does break format matching on '%' patterns:

bash-5.2# ddcmd 'format "find-me: %foo" +p'

[  203.900581] dyndbg: read 26 bytes from userspace
[  203.900883] dyndbg: query 0: "format "find-me: " mod:*
[  203.901118] dyndbg: unclosed quote: find-me:
[  203.901355] dyndbg: tokenize failed
[  203.901529] dyndbg: query 1: "foo" +p" mod:*
[  203.901957] dyndbg: split into words: "foo"" "+p"
[  203.902243] dyndbg: op='+' flags=0x1 maskp=0xffffffff
[  203.902458] dyndbg: expecting pairs of match-spec <value>
[  203.902703] dyndbg: query parse failed
[  203.902871] dyndbg: processed 2 queries, with 0 matches, 2 errs

bash: echo: write error: Invalid argument

The '%' splits the input into 2 queries, and both fail. Given the limited utility of matching against the working parts of a format string "foo: %d bar %s", nothing is actually lost here.

---
 lib/dynamic_debug.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
lib/dynamic_debug.c +1 -1
index 235d85765b63..dcec7b3657bb 100644
@@ -596,7 +596,7 @@ static int ddebug_exec_queries(char *query, const char *modname)
 	int i, errs = 0, exitcode = 0, rc, nfound = 0;
 
 	for (i = 0; query; query = split) {
-		split = strpbrk(query, ";\n");
+		split = strpbrk(query, "%;\n");
 		if (split)
 			*split++ = '\0';
 
Signature · 1 line
2.45.2
author maintainer
#22 lore raw

PATCH v9 22/52 selftests-dyndbg: test_percent_splitting

In reply to Jim Cromie

This does basic testing of classmaps using '%' separated multi-queries. It modprobes test_dynamic_debug with several classes enabled, and counts to verify that the expected sites show the enablement in the control file.

---
 .../dynamic_debug/dyndbg_selftest.sh          | 21 +++++++++++++++++++
 1 file changed, 21 insertions(+)
tools/testing/selftests/dynamic_debug/dyndbg_selftest.sh +21 -0
index b4ba293ab227..996e6fdcfb52 100755
@@ -226,9 +226,30 @@ function comma_terminator_tests {
     ddcmd =_
 }
 
+    
+function test_percent_splitting {
+    echo -e "${GREEN}# TEST_PERCENT_SPLITTING - multi-command splitting on % ${NC}"
+    ifrmmod test_dynamic_debug_submod
+    ifrmmod test_dynamic_debug
+    ddcmd =_
+    modprobe test_dynamic_debug dyndbg=class,D2_CORE,+pf%class,D2_KMS,+pt%class,D2_ATOMIC,+pm
+    check_match_ct =pf 1
+    check_match_ct =pt 1
+    check_match_ct =pm 1
+    check_match_ct test_dynamic_debug 23 -r
+    # add flags to those callsites
+    ddcmd class,D2_CORE,+mf%class,D2_KMS,+lt%class,D2_ATOMIC,+ml
+    check_match_ct =pmf 1
+    check_match_ct =plt 1
+    check_match_ct =pml 1
+    check_match_ct test_dynamic_debug 23 -r
+    ifrmmod test_dynamic_debug
+}
+
 tests_list=(
     basic_tests
     comma_terminator_tests
+    test_percent_splitting
 )
 
 # Run tests
Signature · 1 line
2.45.2
author maintainer
#23 lore raw

PATCH v9 23/52 docs/dyndbg: explain new delimiters: comma, percent

In reply to Jim Cromie

Add mention of comma and percent delimiters into the respective paragraphs describing their equivalents: space and newline.

---
 .../admin-guide/dynamic-debug-howto.rst        | 18 ++++++++++--------
 1 file changed, 10 insertions(+), 8 deletions(-)
Documentation/admin-guide/dynamic-debug-howto.rst +10 -8
index 742eb4230c6e..7b570f29ae98 100644
@@ -73,16 +73,18 @@ Command Language Reference
 ==========================
 
 At the basic lexical level, a command is a sequence of words separated
-by spaces or tabs.  So these are all equivalent::
+by spaces, tabs, or commas.  So these are all equivalent::
 
   :#> ddcmd file svcsock.c line 1603 +p
   :#> ddcmd "file svcsock.c line 1603 +p"
   :#> ddcmd '  file   svcsock.c     line  1603 +p  '
+  :#> ddcmd file,svcsock.c,line,1603,+p
 
-Command submissions are bounded by a write() system call.
-Multiple commands can be written together, separated by ``;`` or ``\n``::
+Command submissions are bounded by a write() system call.  Multiple
+commands can be written together, separated by ``%``, ``;`` or ``\n``::
 
-  :#> ddcmd "func pnpacpi_get_resources +p; func pnp_assign_mem +p"
+  :#> ddcmd func foo +p % func bar +p
+  :#> ddcmd func foo +p \; func bar +p
   :#> ddcmd <<"EOC"
   func pnpacpi_get_resources +p
   func pnp_assign_mem +p
@@ -104,7 +106,6 @@ The match-spec's select *prdbgs* from the catalog, upon which to apply
 the flags-spec, all constraints are ANDed together.  An absent keyword
 is the same as keyword "*".
 
-
 A match specification is a keyword, which selects the attribute of
 the callsite to be compared, and a value to compare against.  Possible
 keywords are:::
@@ -128,7 +129,6 @@ keywords are:::
   ``line-range`` cannot contain space, e.g.
   "1-30" is valid range but "1 - 30" is not.
 
-
 The meanings of each keyword are:
 
 func
@@ -153,9 +153,11 @@ module
     The given string is compared against the module name
     of each callsite.  The module name is the string as
     seen in ``lsmod``, i.e. without the directory or the ``.ko``
-    suffix and with ``-`` changed to ``_``.  Examples::
+    suffix and with ``-`` changed to ``_``.
+
+    Examples::
 
-	module sunrpc
+	module,sunrpc	# with ',' as token separator
 	module nfsd
 	module drm*	# both drm, drm_kms_helper
 
Signature · 1 line
2.45.2
author maintainer
#24 lore raw

PATCH v9 24/52 selftests-dyndbg: add test_mod_submod

In reply to Jim Cromie

This new test-fn runs 3 module/submodule modprobe scenarios, variously using both the generic dyndbg=<queries> modprobe arg, and the test-module's classmap-params to manipulate the test-mod*'s pr_debugs. In all cases, the current flag-settings are counted and tested vs expectations.

The 3rd scenario recapitulates the DRM_USE_DYNAMIC_DEBUG=y failure.

1. 2 modprobes (super then sub), with separate dyndbg=class-settings check module specific flag settings

2. modprobe submod, supermod is auto-loaded
set supermod class-params
check expected enablements in super & submod

3. modprobe super, with param=setting (like drm.debug=0x1ef) modprobe submod
validate submod's class'd pr_debugs get properly enabled

The test uses multi-queries, with both commas and percents (to avoid spaces and quoting). This is the main reason the test wasn't earlier in the patchset, closer to the classmap patches its validating.

With some tedium, the tests could be refactored to split out early tests which avoid multi-cmds, and test only the class-params.

---
 .../dynamic_debug/dyndbg_selftest.sh          | 67 +++++++++++++++++++
 1 file changed, 67 insertions(+)
tools/testing/selftests/dynamic_debug/dyndbg_selftest.sh +67 -0
index 996e6fdcfb52..fccd2012b548 100755
@@ -246,10 +246,77 @@ function test_percent_splitting {
     ifrmmod test_dynamic_debug
 }
 
+function test_mod_submod {
+    echo -e "${GREEN}# TEST_MOD_SUBMOD ${NC}"
+    ifrmmod test_dynamic_debug_submod
+    ifrmmod test_dynamic_debug
+    ddcmd =_
+
+    # modprobe with class enablements
+    modprobe test_dynamic_debug \
+	dyndbg=class,D2_CORE,+pf%class,D2_KMS,+pt%class,D2_ATOMIC,+pm
+
+    check_match_ct '\[test_dynamic_debug\]' 23 -r
+    check_match_ct =pf 1
+    check_match_ct =pt 1
+    check_match_ct =pm 1
+
+    modprobe test_dynamic_debug_submod
+    check_match_ct test_dynamic_debug_submod 23 -r
+    check_match_ct '\[test_dynamic_debug\]' 23 -r
+    check_match_ct test_dynamic_debug 46 -r
+
+    # no enablements propagate here
+    check_match_ct =pf 1
+    check_match_ct =pt 1
+    check_match_ct =pm 1
+
+    # change classes again, this time submod too
+    ddcmd class,D2_CORE,+mf%class,D2_KMS,+lt%class,D2_ATOMIC,+ml "# add some prefixes"
+    check_match_ct =pmf 1 -v
+    check_match_ct =plt 1 -v
+    check_match_ct =pml 1 -v
+    #  submod changed too
+    check_match_ct =mf 1 -v
+    check_match_ct =lt 1 -v
+    check_match_ct =ml 1 -v
+
+    # now work the classmap-params
+    # fresh start, to clear all above flags (test-fn limits)
+    ifrmmod test_dynamic_debug_submod
+    ifrmmod test_dynamic_debug
+    modprobe test_dynamic_debug_submod # get supermod too
+
+    echo 1 > /sys/module/test_dynamic_debug/parameters/p_disjoint_bits
+    echo 4 > /sys/module/test_dynamic_debug/parameters/p_level_num
+    # 2 mods * ( V1-3 + D2_CORE )
+    check_match_ct =p 8 -v
+    echo 3 > /sys/module/test_dynamic_debug/parameters/p_disjoint_bits
+    echo 0 > /sys/module/test_dynamic_debug/parameters/p_level_num
+    # 2 mods * ( D2_CORE, D2_DRIVER )
+    check_match_ct =p 4 -v
+    echo 0x16 > /sys/module/test_dynamic_debug/parameters/p_disjoint_bits
+    echo 0 > /sys/module/test_dynamic_debug/parameters/p_level_num
+    # 2 mods * ( D2_DRIVER, D2_KMS, D2_ATOMIC )
+    check_match_ct =p 6 -v
+
+    # recap DRM_USE_DYNAMIC_DEBUG regression
+    ifrmmod test_dynamic_debug_submod
+    ifrmmod test_dynamic_debug
+    # set super-mod params
+    modprobe test_dynamic_debug p_disjoint_bits=0x16 p_level_num=5
+    check_match_ct =p 7 -v
+    modprobe test_dynamic_debug_submod
+    # see them picked up by submod
+    check_match_ct =p 14 -v
+}
+
 tests_list=(
     basic_tests
+    # these require test_dynamic_debug*.ko
     comma_terminator_tests
     test_percent_splitting
+    test_mod_submod
 )
 
 # Run tests
Signature · 1 line
2.45.2
author maintainer
#25 lore raw

PATCH v9 25/52 dyndbg-doc: explain flags parse 1st

In reply to Jim Cromie

When writing queries to >control, flags are parsed 1st, since they are the only required field. So if the flags draw an error, then keyword errors aren't reported. This can be mildly confusing/annoying, so explain it instead.

This note could be moved up to just after the grammar id's the flags, and before the match-spec is detailed. Opinions ?

---
 Documentation/admin-guide/dynamic-debug-howto.rst | 10 ++++++++++
 1 file changed, 10 insertions(+)
Documentation/admin-guide/dynamic-debug-howto.rst +10 -0
index 7b570f29ae98..ccf3704f2143 100644
@@ -106,6 +106,16 @@ The match-spec's select *prdbgs* from the catalog, upon which to apply
 the flags-spec, all constraints are ANDed together.  An absent keyword
 is the same as keyword "*".
 
+Note: because the match-spec can be empty, the flags are checked 1st,
+then the pairs of keyword values.  Flag errs will hide keyword errs:
+
+  bash-5.2# ddcmd mod bar +foo
+  dyndbg: read 13 bytes from userspace
+  dyndbg: query 0: "mod bar +foo" mod:*
+  dyndbg: unknown flag 'o'
+  dyndbg: flags parse failed
+  dyndbg: processed 1 queries, with 0 matches, 1 errs
+
 A match specification is a keyword, which selects the attribute of
 the callsite to be compared, and a value to compare against.  Possible
 keywords are:::
Signature · 1 line
2.45.2
author maintainer
#26 lore raw

PATCH v9 26/52 dyndbg: change __dynamic_func_call_cls* macros into expressions

In reply to Jim Cromie

The Xe driver's XE_IOCTL_DBG macro calls drm_dbg() from inside an if (expression). This breaks when CONFIG_DRM_USE_DYNAMIC_DEBUG=y because the invoked macro has a do-while-0 wrapper.

   if (cond && (drm_dbg("expr-form"),1)) {
      ... do some more stuff
   }

Fix it by changing __dynamic_func_call_cls{,_no_desc} macros into expressions, by replacing the do-while-0s with a ({ }) wrapper.

In C, all legal expressions are also legal statements, as converted by the trailing semi-colon in a statement-style macro invocation:

   drm_dbg("statement form");
---
 include/linux/dynamic_debug.h | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
include/linux/dynamic_debug.h +4 -4
index 19f959f9a6b4..121a66b0ca25 100644
@@ -287,20 +287,20 @@ void __dynamic_ibdev_dbg(struct _ddebug *descriptor,
  * (|_cls):	adds in _DPRINT_CLASS_DFLT as needed
  * (|_no_desc):	former gets callsite descriptor as 1st arg (for prdbgs)
  */
-#define __dynamic_func_call_cls(id, cls, fmt, func, ...) do {	\
+#define __dynamic_func_call_cls(id, cls, fmt, func, ...) ({	\
 	DEFINE_DYNAMIC_DEBUG_METADATA_CLS(id, cls, fmt);	\
 	if (DYNAMIC_DEBUG_BRANCH(id))				\
 		func(&id, ##__VA_ARGS__);			\
-} while (0)
+})
 #define __dynamic_func_call(id, fmt, func, ...)				\
 	__dynamic_func_call_cls(id, _DPRINTK_CLASS_DFLT, fmt,		\
 				func, ##__VA_ARGS__)
 
-#define __dynamic_func_call_cls_no_desc(id, cls, fmt, func, ...) do {	\
+#define __dynamic_func_call_cls_no_desc(id, cls, fmt, func, ...) ({	\
 	DEFINE_DYNAMIC_DEBUG_METADATA_CLS(id, cls, fmt);		\
 	if (DYNAMIC_DEBUG_BRANCH(id))					\
 		func(__VA_ARGS__);					\
-} while (0)
+})
 #define __dynamic_func_call_no_desc(id, fmt, func, ...)			\
 	__dynamic_func_call_cls_no_desc(id, _DPRINTK_CLASS_DFLT,	\
 					fmt, func, ##__VA_ARGS__)
Signature · 1 line
2.45.2
author maintainer
#27 lore raw

PATCH v9 27/52 selftests-dyndbg: check KCONFIG_CONFIG to avoid silly fails

In reply to Jim Cromie

Several tests are dependent upon config choices. Lets avoid failing where that is noise.

The KCONFIG_CONFIG var exists to convey the config-file around. If the var names a file, read it and extract the relevant CONFIG items, and use them to skip the dependent tests, thus avoiding the fails that would follow, and the disruption to whatever CI is running these selftests.

If the envar doesn't name a config-file, ".config" is assumed.

CONFIG_DYNAMIC_DEBUG=y:

basic-tests() and comma-terminator-tests() test for the presence of the builtin pr_debugs in module/main.c, which I deemed stable and therefore safe to count. That said, the test fails if only CONFIG_DYNAMIC_DEBUG_CORE=y is set. It could be rewritten to test against test-dynamic-debug.ko, but that just trades one config dependence for another.

CONFIG_TEST_DYNAMIC_DEBUG=m

As written, test_percent_splitting() modprobes test_dynamic_debug, enables several classes, and count them. It could be re-written to work for the builtin module also, but builtin test modules are not a common or desirable build/config.

CONFIG_TEST_DYNAMIC_DEBUG=m && CONFIG_TEST_DYNAMIC_DEBUG_SUBMOD=m

test_mod_submod() recaps the bug found in DRM-CI where drivers werent enabled by drm.debug=<bits>. It modprobes both test_dynamic_debug & test_dynamic_debug_submod, so it depends on a loadable modules config.

It could be rewritten to work in a builtin parent config; DRM=y is common enough to be pertinent, but testing that config also wouldn't really test anything more fully than all-loadable modules, since they default together.

fixup-kconfig

---
 .../dynamic_debug/dyndbg_selftest.sh          | 45 ++++++++++++++++++-
 1 file changed, 44 insertions(+), 1 deletion(-)
tools/testing/selftests/dynamic_debug/dyndbg_selftest.sh +44 -1
index fccd2012b548..d09ef26b2308 100755
@@ -11,6 +11,30 @@ CYAN="\033[0;36m"
 NC="\033[0;0m"
 error_msg=""
 
+[ -e /proc/dynamic_debug/control ] || {
+    echo -e "${RED}: this test requires CONFIG_DYNAMIC_DEBUG=y ${NC}"
+    exit 0 # nothing to test here, no good reason to fail.
+}
+
+# need info to avoid failures due to untestable configs
+
+[ -f "$KCONFIG_CONFIG" ] || KCONFIG_CONFIG=".config"
+if [ -f "$KCONFIG_CONFIG" ]; then
+    echo "# consulting KCONFIG_CONFIG: $KCONFIG_CONFIG"
+    grep -q "CONFIG_DYNAMIC_DEBUG=y" $KCONFIG_CONFIG ; LACK_DD_BUILTIN=$?
+    grep -q "CONFIG_TEST_DYNAMIC_DEBUG=m" $KCONFIG_CONFIG ; LACK_TMOD=$?
+    grep -q "CONFIG_TEST_DYNAMIC_DEBUG_SUBMOD=m" $KCONFIG_CONFIG ; LACK_TMOD_SUBMOD=$?
+    if [ $V -eq 1 ]; then
+	echo LACK_DD_BUILTIN: $LACK_DD_BUILTIN
+	echo LACK_TMOD: $LACK_TMOD
+	echo LACK_TMOD_SUBMOD: $LACK_TMOD_SUBMOD
+    fi
+else
+    LACK_DD_BUILTIN=0
+    LACK_TMOD=0
+    LACK_TMOD_SUBMOD=0
+fi
+
 function vx () {
     echo $1 > /sys/module/dynamic_debug/parameters/verbose
 }
@@ -192,6 +216,10 @@ function check_err_msg() {
 
 function basic_tests {
     echo -e "${GREEN}# BASIC_TESTS ${NC}"
+    if [ $LACK_DD_BUILTIN -eq 1 ]; then
+	echo "SKIP"
+	return
+    fi
     ddcmd =_ # zero everything (except class'd sites)
     check_match_ct =p 0
     # there are several main's :-/
@@ -214,6 +242,10 @@ EOF
 
 function comma_terminator_tests {
     echo -e "${GREEN}# COMMA_TERMINATOR_TESTS ${NC}"
+    if [ $LACK_DD_BUILTIN -eq 1 ]; then
+	echo "SKIP"
+	return
+    fi
     # try combos of spaces & commas
     check_match_ct '\[params\]' 4 -r
     ddcmd module,params,=_		# commas as spaces
@@ -226,9 +258,12 @@ function comma_terminator_tests {
     ddcmd =_
 }
 
-    
 function test_percent_splitting {
     echo -e "${GREEN}# TEST_PERCENT_SPLITTING - multi-command splitting on % ${NC}"
+    if [ $LACK_TMOD -eq 1 ]; then
+	echo "SKIP"
+	return
+    fi
     ifrmmod test_dynamic_debug_submod
     ifrmmod test_dynamic_debug
     ddcmd =_
@@ -248,6 +283,14 @@ function test_percent_splitting {
 
 function test_mod_submod {
     echo -e "${GREEN}# TEST_MOD_SUBMOD ${NC}"
+    if [ $LACK_TMOD -eq 1 ]; then
+	echo "SKIP"
+	return
+    fi
+    if [ $LACK_TMOD_SUBMOD -eq 1 ]; then
+	echo "SKIP"
+	return
+    fi
     ifrmmod test_dynamic_debug_submod
     ifrmmod test_dynamic_debug
     ddcmd =_
Signature · 1 line
2.45.2
#28 lore raw

Re: [PATCH v9 27/52] selftests-dyndbg: check KCONFIG_CONFIG to avoid silly fails

Quoted 22 lines · Jim Cromie

Several tests are dependent upon config choices. Lets avoid failing where that is noise.

The KCONFIG_CONFIG var exists to convey the config-file around. If the var names a file, read it and extract the relevant CONFIG items, and use them to skip the dependent tests, thus avoiding the fails that would follow, and the disruption to whatever CI is running these selftests.

If the envar doesn't name a config-file, ".config" is assumed.

CONFIG_DYNAMIC_DEBUG=y:

basic-tests() and comma-terminator-tests() test for the presence of the builtin pr_debugs in module/main.c, which I deemed stable and therefore safe to count. That said, the test fails if only CONFIG_DYNAMIC_DEBUG_CORE=y is set. It could be rewritten to test against test-dynamic-debug.ko, but that just trades one config dependence for another.

CONFIG_TEST_DYNAMIC_DEBUG=m

Quoted 8 lines

As written, test_percent_splitting() modprobes test_dynamic_debug, enables several classes, and count them. It could be re-written to work for the builtin module also, but builtin test modules are not a common or desirable build/config.

CONFIG_TEST_DYNAMIC_DEBUG=m && CONFIG_TEST_DYNAMIC_DEBUG_SUBMOD=m

test_mod_submod() recaps the bug found in DRM-CI where drivers werent

If this fixes any but listed in drm/ci/xfails folder, please update it too.

Regards,
Helen

Quoted 101 lines

enabled by drm.debug=<bits>. It modprobes both test_dynamic_debug & test_dynamic_debug_submod, so it depends on a loadable modules config.

It could be rewritten to work in a builtin parent config; DRM=y is common enough to be pertinent, but testing that config also wouldn't really test anything more fully than all-loadable modules, since they default together.

fixup-kconfig

---
  .../dynamic_debug/dyndbg_selftest.sh          | 45 ++++++++++++++++++-
  1 file changed, 44 insertions(+), 1 deletion(-)
tools/testing/selftests/dynamic_debug/dyndbg_selftest.sh +44 -1
index fccd2012b548..d09ef26b2308 100755
@@ -11,6 +11,30 @@ CYAN="\033[0;36m"
  NC="\033[0;0m"
  error_msg=""
 
+[ -e /proc/dynamic_debug/control ] || {
+    echo -e "${RED}: this test requires CONFIG_DYNAMIC_DEBUG=y ${NC}"
+    exit 0 # nothing to test here, no good reason to fail.
+}
+
+# need info to avoid failures due to untestable configs
+
+[ -f "$KCONFIG_CONFIG" ] || KCONFIG_CONFIG=".config"
+if [ -f "$KCONFIG_CONFIG" ]; then
+    echo "# consulting KCONFIG_CONFIG: $KCONFIG_CONFIG"
+    grep -q "CONFIG_DYNAMIC_DEBUG=y" $KCONFIG_CONFIG ; LACK_DD_BUILTIN=$?
+    grep -q "CONFIG_TEST_DYNAMIC_DEBUG=m" $KCONFIG_CONFIG ; LACK_TMOD=$?
+    grep -q "CONFIG_TEST_DYNAMIC_DEBUG_SUBMOD=m" $KCONFIG_CONFIG ; LACK_TMOD_SUBMOD=$?
+    if [ $V -eq 1 ]; then
+	echo LACK_DD_BUILTIN: $LACK_DD_BUILTIN
+	echo LACK_TMOD: $LACK_TMOD
+	echo LACK_TMOD_SUBMOD: $LACK_TMOD_SUBMOD
+    fi
+else
+    LACK_DD_BUILTIN=0
+    LACK_TMOD=0
+    LACK_TMOD_SUBMOD=0
+fi
+
  function vx () {
      echo $1 > /sys/module/dynamic_debug/parameters/verbose
  }
@@ -192,6 +216,10 @@ function check_err_msg() {
 
  function basic_tests {
      echo -e "${GREEN}# BASIC_TESTS ${NC}"
+    if [ $LACK_DD_BUILTIN -eq 1 ]; then
+	echo "SKIP"
+	return
+    fi
      ddcmd =_ # zero everything (except class'd sites)
      check_match_ct =p 0
      # there are several main's :-/
@@ -214,6 +242,10 @@ EOF
 
  function comma_terminator_tests {
      echo -e "${GREEN}# COMMA_TERMINATOR_TESTS ${NC}"
+    if [ $LACK_DD_BUILTIN -eq 1 ]; then
+	echo "SKIP"
+	return
+    fi
      # try combos of spaces & commas
      check_match_ct '\[params\]' 4 -r
      ddcmd module,params,=_		# commas as spaces
@@ -226,9 +258,12 @@ function comma_terminator_tests {
      ddcmd =_
  }
 
-
  function test_percent_splitting {
      echo -e "${GREEN}# TEST_PERCENT_SPLITTING - multi-command splitting on % ${NC}"
+    if [ $LACK_TMOD -eq 1 ]; then
+	echo "SKIP"
+	return
+    fi
      ifrmmod test_dynamic_debug_submod
      ifrmmod test_dynamic_debug
      ddcmd =_
@@ -248,6 +283,14 @@ function test_percent_splitting {
 
  function test_mod_submod {
      echo -e "${GREEN}# TEST_MOD_SUBMOD ${NC}"
+    if [ $LACK_TMOD -eq 1 ]; then
+	echo "SKIP"
+	return
+    fi
+    if [ $LACK_TMOD_SUBMOD -eq 1 ]; then
+	echo "SKIP"
+	return
+    fi
      ifrmmod test_dynamic_debug_submod
      ifrmmod test_dynamic_debug
      ddcmd =_
author maintainer
#29 lore raw

Re: [PATCH v9 27/52] selftests-dyndbg: check KCONFIG_CONFIG to avoid silly fails

Quoted 7 lines · Helen Koike
Quoted 3 lines · Jim Cromie

Several tests are dependent upon config choices. Lets avoid failing where that is noise.

...

Quoted 7 lines
Quoted 2 lines

test_mod_submod() recaps the bug found in DRM-CI where drivers werent

If this fixes any but listed in drm/ci/xfails folder, please update it too.

Regards,
Helen

This looks like a good avenue to follow, thanks for the hint

author maintainer
#30 lore raw

PATCH v9 28/52 dyndbg-selftest: reduce default verbosity

In reply to Jim Cromie

Remove the '-v' arg from the tests in test_mod_submod(). Setting V=1 in the environment turns it back on, for all tests.

---
 .../dynamic_debug/dyndbg_selftest.sh          | 23 +++++++++----------
 1 file changed, 11 insertions(+), 12 deletions(-)
tools/testing/selftests/dynamic_debug/dyndbg_selftest.sh +11 -12
index d09ef26b2308..b3d7155cb45c 100755
@@ -168,7 +168,6 @@ function error_log_ref {
 }
 
 function ifrmmod {
-    lsmod | grep $1 2>&1>/dev/null || echo $1 not there
     lsmod | grep $1 2>&1>/dev/null && rmmod $1
 }
 
@@ -316,13 +315,13 @@ function test_mod_submod {
 
     # change classes again, this time submod too
     ddcmd class,D2_CORE,+mf%class,D2_KMS,+lt%class,D2_ATOMIC,+ml "# add some prefixes"
-    check_match_ct =pmf 1 -v
-    check_match_ct =plt 1 -v
-    check_match_ct =pml 1 -v
+    check_match_ct =pmf 1
+    check_match_ct =plt 1
+    check_match_ct =pml 1
     #  submod changed too
-    check_match_ct =mf 1 -v
-    check_match_ct =lt 1 -v
-    check_match_ct =ml 1 -v
+    check_match_ct =mf 1
+    check_match_ct =lt 1
+    check_match_ct =ml 1
 
     # now work the classmap-params
     # fresh start, to clear all above flags (test-fn limits)
@@ -333,25 +332,25 @@ function test_mod_submod {
     echo 1 > /sys/module/test_dynamic_debug/parameters/p_disjoint_bits
     echo 4 > /sys/module/test_dynamic_debug/parameters/p_level_num
     # 2 mods * ( V1-3 + D2_CORE )
-    check_match_ct =p 8 -v
+    check_match_ct =p 8
     echo 3 > /sys/module/test_dynamic_debug/parameters/p_disjoint_bits
     echo 0 > /sys/module/test_dynamic_debug/parameters/p_level_num
     # 2 mods * ( D2_CORE, D2_DRIVER )
-    check_match_ct =p 4 -v
+    check_match_ct =p 4
     echo 0x16 > /sys/module/test_dynamic_debug/parameters/p_disjoint_bits
     echo 0 > /sys/module/test_dynamic_debug/parameters/p_level_num
     # 2 mods * ( D2_DRIVER, D2_KMS, D2_ATOMIC )
-    check_match_ct =p 6 -v
+    check_match_ct =p 6
 
     # recap DRM_USE_DYNAMIC_DEBUG regression
     ifrmmod test_dynamic_debug_submod
     ifrmmod test_dynamic_debug
     # set super-mod params
     modprobe test_dynamic_debug p_disjoint_bits=0x16 p_level_num=5
-    check_match_ct =p 7 -v
+    check_match_ct =p 7
     modprobe test_dynamic_debug_submod
     # see them picked up by submod
-    check_match_ct =p 14 -v
+    check_match_ct =p 14
 }
 
 tests_list=(
Signature · 1 line
2.45.2
author maintainer
#31 lore raw

PATCH v9 29/52 drm: use correct ccflags-y spelling

In reply to Jim Cromie

Incorrectly spelled CFLAGS- failed to add -DDYNAMIC_DEBUG_MODULE, which broke builds with:

CONFIG_DRM_USE_DYNAMIC_DEBUG=y
CONFIG_DYNAMIC_DEBUG_CORE=y
CONFIG_DYNAMIC_DEBUG=n

Also add subdir-ccflags so that all drivers pick up the addition.

Fixes 84ec67288c10 ("drm_print: wrap drm_*_dbg in dyndbg descriptor factory macro")
---
 drivers/gpu/drm/Makefile | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/gpu/drm/Makefile +2 -1
index 104b42df2e95..313516fc2ad5 100644
@@ -3,7 +3,8 @@
 # Makefile for the drm device driver.  This driver provides support for the
 # Direct Rendering Infrastructure (DRI) in XFree86 4.1.0 and higher.
 
-CFLAGS-$(CONFIG_DRM_USE_DYNAMIC_DEBUG)	+= -DDYNAMIC_DEBUG_MODULE
+ccflags-$(CONFIG_DRM_USE_DYNAMIC_DEBUG)		+= -DDYNAMIC_DEBUG_MODULE
+subdir-ccflags-$(CONFIG_DRM_USE_DYNAMIC_DEBUG)	+= -DDYNAMIC_DEBUG_MODULE
 
 drm-y := \
 	drm_aperture.o \
Signature · 1 line
2.45.2
author maintainer
#32 lore raw

PATCH v9 30/52 drm-dyndbg: adapt drm core to use dyndbg classmaps-v2

In reply to Jim Cromie

dyndbg's CLASSMAP-v1 api was broken; DECLARE_DYNDBG_CLASSMAP tried to do too much. Its replaced by DRM_CLASSMAP_DEFINE, which creates & EXPORTs the classmap when CONFIG_DRM_USE_DYNAMIC_DEBUG=y, for direct reference by drivers.

The drivers still use DECLARE_DYNDBG_CLASSMAP for now, so they still redundantly re-declare the classmap, but we can convert the drivers later to DYNDBG_CLASSMAP_USE

---
 drivers/gpu/drm/drm_print.c | 25 +++++++++++++------------
 include/drm/drm_print.h     |  8 ++++++++
 2 files changed, 21 insertions(+), 12 deletions(-)
drivers/gpu/drm/drm_print.c +13 -12
index 699b7dbffd7b..4a5f2317229b 100644
@@ -55,18 +55,19 @@ MODULE_PARM_DESC(debug, "Enable debug output, where each bit enables a debug cat
 #if !defined(CONFIG_DRM_USE_DYNAMIC_DEBUG)
 module_param_named(debug, __drm_debug, ulong, 0600);
 #else
-/* classnames must match vals of enum drm_debug_category */
-DECLARE_DYNDBG_CLASSMAP(drm_debug_classes, DD_CLASS_TYPE_DISJOINT_BITS, 0,
-			"DRM_UT_CORE",
-			"DRM_UT_DRIVER",
-			"DRM_UT_KMS",
-			"DRM_UT_PRIME",
-			"DRM_UT_ATOMIC",
-			"DRM_UT_VBL",
-			"DRM_UT_STATE",
-			"DRM_UT_LEASE",
-			"DRM_UT_DP",
-			"DRM_UT_DRMRES");
+/* classnames must match value-symbols of enum drm_debug_category */
+DRM_CLASSMAP_DEFINE(drm_debug_classes, DD_CLASS_TYPE_DISJOINT_BITS,
+		    DRM_UT_CORE,
+		    "DRM_UT_CORE",
+		    "DRM_UT_DRIVER",
+		    "DRM_UT_KMS",
+		    "DRM_UT_PRIME",
+		    "DRM_UT_ATOMIC",
+		    "DRM_UT_VBL",
+		    "DRM_UT_STATE",
+		    "DRM_UT_LEASE",
+		    "DRM_UT_DP",
+		    "DRM_UT_DRMRES");
 
 static struct ddebug_class_param drm_debug_bitmap = {
 	.bits = &__drm_debug,
include/drm/drm_print.h +8 -0
index 9cc473e5d353..905fc25bf65a 100644
@@ -140,6 +140,14 @@ enum drm_debug_category {
 	DRM_UT_DRMRES
 };
 
+#ifdef CONFIG_DRM_USE_DYNAMIC_DEBUG
+#define DRM_CLASSMAP_DEFINE(...) DYNDBG_CLASSMAP_DEFINE(__VA_ARGS__)
+#define DRM_CLASSMAP_USE(name)   DYNDBG_CLASSMAP_USE(name)
+#else
+#define DRM_CLASSMAP_DEFINE(...)
+#define DRM_CLASSMAP_USE(name)
+#endif
+
 static inline bool drm_debug_enabled_raw(enum drm_debug_category category)
 {
 	return unlikely(__drm_debug & BIT(category));
Signature · 1 line
2.45.2
#33 lore raw

Re: [PATCH v9 30/52] drm-dyndbg: adapt drm core to use dyndbg classmaps-v2

Quoted 38 lines · Jim Cromie

dyndbg's CLASSMAP-v1 api was broken; DECLARE_DYNDBG_CLASSMAP tried to do too much. Its replaced by DRM_CLASSMAP_DEFINE, which creates & EXPORTs the classmap when CONFIG_DRM_USE_DYNAMIC_DEBUG=y, for direct reference by drivers.

The drivers still use DECLARE_DYNDBG_CLASSMAP for now, so they still redundantly re-declare the classmap, but we can convert the drivers later to DYNDBG_CLASSMAP_USE

---
 drivers/gpu/drm/drm_print.c | 25 +++++++++++++------------
 include/drm/drm_print.h     |  8 ++++++++
 2 files changed, 21 insertions(+), 12 deletions(-)
drivers/gpu/drm/drm_print.c +3 -12
index 699b7dbffd7b..4a5f2317229b 100644
@@ -55,18 +55,19 @@ MODULE_PARM_DESC(debug, "Enable debug output, where each bit enables a debug cat
 #if !defined(CONFIG_DRM_USE_DYNAMIC_DEBUG)
 module_param_named(debug, __drm_debug, ulong, 0600);
 #else
-/* classnames must match vals of enum drm_debug_category */
-DECLARE_DYNDBG_CLASSMAP(drm_debug_classes, DD_CLASS_TYPE_DISJOINT_BITS, 0,
-			"DRM_UT_CORE",
-			"DRM_UT_DRIVER",
-			"DRM_UT_KMS",
-			"DRM_UT_PRIME",
-			"DRM_UT_ATOMIC",
-			"DRM_UT_VBL",
-			"DRM_UT_STATE",
-			"DRM_UT_LEASE",
-			"DRM_UT_DP",
-			"DRM_UT_DRMRES");
+/* classnames must match value-symbols of enum drm_debug_category */
+DRM_CLASSMAP_DEFINE(drm_debug_classes, DD_CLASS_TYPE_DISJOINT_BITS,
+		    DRM_UT_CORE,

drivers/gpu/drm/drm_print.c MODULE_PARM_DESC(debug, "Enable debug output, where each bit enables a debug cat · line 70

Quoted 10 lines
drivers/gpu/drm/drm_print.c +10 -0
+		    "DRM_UT_CORE",
+		    "DRM_UT_DRIVER",
+		    "DRM_UT_KMS",
+		    "DRM_UT_PRIME",
+		    "DRM_UT_ATOMIC",
+		    "DRM_UT_VBL",
+		    "DRM_UT_STATE",
+		    "DRM_UT_LEASE",
+		    "DRM_UT_DP",
+		    "DRM_UT_DRMRES");

Looks like this stuff just ends up in an array, so presumably it should be possible to use designated initializers to make this less fragile?

Signature · 2 lines
Ville Syrjälä
Intel
author maintainer
#34 lore raw

Re: [PATCH v9 30/52] drm-dyndbg: adapt drm core to use dyndbg classmaps-v2

Quoted 46 lines · Ville Syrjälä
Quoted 44 lines · Jim Cromie

dyndbg's CLASSMAP-v1 api was broken; DECLARE_DYNDBG_CLASSMAP tried to do too much. Its replaced by DRM_CLASSMAP_DEFINE, which creates & EXPORTs the classmap when CONFIG_DRM_USE_DYNAMIC_DEBUG=y, for direct reference by drivers.

The drivers still use DECLARE_DYNDBG_CLASSMAP for now, so they still redundantly re-declare the classmap, but we can convert the drivers later to DYNDBG_CLASSMAP_USE

---
 drivers/gpu/drm/drm_print.c | 25 +++++++++++++------------
 include/drm/drm_print.h     |  8 ++++++++
 2 files changed, 21 insertions(+), 12 deletions(-)
drivers/gpu/drm/drm_print.c +9 -12
index 699b7dbffd7b..4a5f2317229b 100644
@@ -55,18 +55,19 @@ MODULE_PARM_DESC(debug, "Enable debug output, where each bit enables a debug cat
 #if !defined(CONFIG_DRM_USE_DYNAMIC_DEBUG)
 module_param_named(debug, __drm_debug, ulong, 0600);
 #else
-/* classnames must match vals of enum drm_debug_category */
-DECLARE_DYNDBG_CLASSMAP(drm_debug_classes, DD_CLASS_TYPE_DISJOINT_BITS, 0,
-                     "DRM_UT_CORE",
-                     "DRM_UT_DRIVER",
-                     "DRM_UT_KMS",
-                     "DRM_UT_PRIME",
-                     "DRM_UT_ATOMIC",
-                     "DRM_UT_VBL",
-                     "DRM_UT_STATE",
-                     "DRM_UT_LEASE",
-                     "DRM_UT_DP",
-                     "DRM_UT_DRMRES");
+/* classnames must match value-symbols of enum drm_debug_category */
+DRM_CLASSMAP_DEFINE(drm_debug_classes, DD_CLASS_TYPE_DISJOINT_BITS,
+                 DRM_UT_CORE,
+                 "DRM_UT_CORE",
+                 "DRM_UT_DRIVER",
+                 "DRM_UT_KMS",
+                 "DRM_UT_PRIME",
+                 "DRM_UT_ATOMIC",
+                 "DRM_UT_VBL",
Quoted 8 lines

drivers/gpu/drm/drm_print.c MODULE_PARM_DESC(debug, "Enable debug output, where each bit enables a debug cat · line 70

Quoted 4 lines
drivers/gpu/drm/drm_print.c +4 -0
+                 "DRM_UT_STATE",
+                 "DRM_UT_LEASE",
+                 "DRM_UT_DP",
+                 "DRM_UT_DRMRES");

Looks like this stuff just ends up in an array, so presumably it should be possible to use designated initializers to make this less fragile?

Im not sure I got your whole point, but:

the fragility is the repetitive re-statement of the map, in those un-modified DECLARE_s,
once replaced, the USEs just ref the struct built by the _DEFINE (once, and exported)

I dont really like the _DEFINEs restatement of the enum-values: DRM_UT_* especially as "strings".
I can automate the stringification with an APPLY_FN_(__stringify, ...) but the enum-list DRM_UT_* (w.o quotes) is still needed as args.

unless there is something C can do thats like Enum.values() ?

Quoted 4 lines

--
Ville Syrjälä
Intel

#35 lore raw

Re: [PATCH v9 30/52] drm-dyndbg: adapt drm core to use dyndbg classmaps-v2

Quoted 57 lines · On Tue, Jul 02, 2024 at 08:34:39PM -0600, [email protected] wrote:
Quoted 46 lines · Ville Syrjälä
Quoted 44 lines · Jim Cromie

dyndbg's CLASSMAP-v1 api was broken; DECLARE_DYNDBG_CLASSMAP tried to do too much. Its replaced by DRM_CLASSMAP_DEFINE, which creates & EXPORTs the classmap when CONFIG_DRM_USE_DYNAMIC_DEBUG=y, for direct reference by drivers.

The drivers still use DECLARE_DYNDBG_CLASSMAP for now, so they still redundantly re-declare the classmap, but we can convert the drivers later to DYNDBG_CLASSMAP_USE

---
 drivers/gpu/drm/drm_print.c | 25 +++++++++++++------------
 include/drm/drm_print.h     |  8 ++++++++
 2 files changed, 21 insertions(+), 12 deletions(-)
drivers/gpu/drm/drm_print.c +9 -12
index 699b7dbffd7b..4a5f2317229b 100644
@@ -55,18 +55,19 @@ MODULE_PARM_DESC(debug, "Enable debug output, where each bit enables a debug cat
 #if !defined(CONFIG_DRM_USE_DYNAMIC_DEBUG)
 module_param_named(debug, __drm_debug, ulong, 0600);
 #else
-/* classnames must match vals of enum drm_debug_category */
-DECLARE_DYNDBG_CLASSMAP(drm_debug_classes, DD_CLASS_TYPE_DISJOINT_BITS, 0,
-                     "DRM_UT_CORE",
-                     "DRM_UT_DRIVER",
-                     "DRM_UT_KMS",
-                     "DRM_UT_PRIME",
-                     "DRM_UT_ATOMIC",
-                     "DRM_UT_VBL",
-                     "DRM_UT_STATE",
-                     "DRM_UT_LEASE",
-                     "DRM_UT_DP",
-                     "DRM_UT_DRMRES");
+/* classnames must match value-symbols of enum drm_debug_category */
+DRM_CLASSMAP_DEFINE(drm_debug_classes, DD_CLASS_TYPE_DISJOINT_BITS,
+                 DRM_UT_CORE,
+                 "DRM_UT_CORE",
+                 "DRM_UT_DRIVER",
+                 "DRM_UT_KMS",
+                 "DRM_UT_PRIME",
+                 "DRM_UT_ATOMIC",
+                 "DRM_UT_VBL",
Quoted 8 lines

drivers/gpu/drm/drm_print.c MODULE_PARM_DESC(debug, "Enable debug output, where each bit enables a debug cat · line 70

Quoted 4 lines
drivers/gpu/drm/drm_print.c +4 -0
+                 "DRM_UT_STATE",
+                 "DRM_UT_LEASE",
+                 "DRM_UT_DP",
+                 "DRM_UT_DRMRES");

Looks like this stuff just ends up in an array, so presumably it should be possible to use designated initializers to make this less fragile?

Quoted 1 line

Im not sure I got your whole point, but:

I mean using
[DRM_UT_CORE] = "DRM_UT_CORE"
instead of
"DRM_UT_CORE"
so there is no chance of screwing up the order.
Or maybe the order doesn't even matter here?

Could also stringify to avoid accidental of typos.

Quoted 19 lines

the fragility is the repetitive re-statement of the map, in those un-modified DECLARE_s,
once replaced, the USEs just ref the struct built by the _DEFINE (once, and exported)

I dont really like the _DEFINEs restatement of the enum-values: DRM_UT_* especially as "strings".
I can automate the stringification with an APPLY_FN_(__stringify, ...) but the enum-list DRM_UT_* (w.o quotes) is still needed as args.

unless there is something C can do thats like Enum.values() ?

Quoted 4 lines

--
Ville Syrjälä
Intel

Signature · 2 lines
Ville Syrjälä
Intel
author maintainer
#36 lore raw

Re: [PATCH v9 30/52] drm-dyndbg: adapt drm core to use dyndbg classmaps-v2

Got it.
I had some mental block about passing designated intializers as macro args. it just worked, I needed to eyeball the .i file just to be sure. thanks.
I have a fixup patch.
whats the best thing to do with it, squash it in for later ? send in reply here ?

Quoted 93 lines · Ville Syrjälä
Quoted 57 lines · On Tue, Jul 02, 2024 at 08:34:39PM -0600, [email protected] wrote:
Quoted 46 lines · Ville Syrjälä
Quoted 44 lines · Jim Cromie

dyndbg's CLASSMAP-v1 api was broken; DECLARE_DYNDBG_CLASSMAP tried to do too much. Its replaced by DRM_CLASSMAP_DEFINE, which creates & EXPORTs the classmap when CONFIG_DRM_USE_DYNAMIC_DEBUG=y, for direct reference by drivers.

The drivers still use DECLARE_DYNDBG_CLASSMAP for now, so they still redundantly re-declare the classmap, but we can convert the drivers later to DYNDBG_CLASSMAP_USE

---
 drivers/gpu/drm/drm_print.c | 25 +++++++++++++------------
 include/drm/drm_print.h     |  8 ++++++++
 2 files changed, 21 insertions(+), 12 deletions(-)
drivers/gpu/drm/drm_print.c +9 -12
index 699b7dbffd7b..4a5f2317229b 100644
@@ -55,18 +55,19 @@ MODULE_PARM_DESC(debug, "Enable debug output, where each bit enables a debug cat
 #if !defined(CONFIG_DRM_USE_DYNAMIC_DEBUG)
 module_param_named(debug, __drm_debug, ulong, 0600);
 #else
-/* classnames must match vals of enum drm_debug_category */
-DECLARE_DYNDBG_CLASSMAP(drm_debug_classes, DD_CLASS_TYPE_DISJOINT_BITS, 0,
-                     "DRM_UT_CORE",
-                     "DRM_UT_DRIVER",
-                     "DRM_UT_KMS",
-                     "DRM_UT_PRIME",
-                     "DRM_UT_ATOMIC",
-                     "DRM_UT_VBL",
-                     "DRM_UT_STATE",
-                     "DRM_UT_LEASE",
-                     "DRM_UT_DP",
-                     "DRM_UT_DRMRES");
+/* classnames must match value-symbols of enum drm_debug_category */
+DRM_CLASSMAP_DEFINE(drm_debug_classes, DD_CLASS_TYPE_DISJOINT_BITS,
+                 DRM_UT_CORE,
+                 "DRM_UT_CORE",
+                 "DRM_UT_DRIVER",
+                 "DRM_UT_KMS",
+                 "DRM_UT_PRIME",
+                 "DRM_UT_ATOMIC",
+                 "DRM_UT_VBL",
Quoted 8 lines

drivers/gpu/drm/drm_print.c MODULE_PARM_DESC(debug, "Enable debug output, where each bit enables a debug cat · line 70

Quoted 4 lines
drivers/gpu/drm/drm_print.c +4 -0
+                 "DRM_UT_STATE",
+                 "DRM_UT_LEASE",
+                 "DRM_UT_DP",
+                 "DRM_UT_DRMRES");

Looks like this stuff just ends up in an array, so presumably it should be possible to use designated initializers to make this less fragile?

Quoted 1 line

Im not sure I got your whole point, but:

I mean using
[DRM_UT_CORE] = "DRM_UT_CORE"
instead of
"DRM_UT_CORE"
so there is no chance of screwing up the order.
Or maybe the order doesn't even matter here?

Could also stringify to avoid accidental of typos.

Quoted 6 lines

the fragility is the repetitive re-statement of the map, in those un-modified DECLARE_s,
once replaced, the USEs just ref the struct built by the _DEFINE (once, and exported)

Quoted 13 lines

I dont really like the _DEFINEs restatement of the enum-values: DRM_UT_* especially as "strings".
I can automate the stringification with an APPLY_FN_(__stringify, ...) but the enum-list DRM_UT_* (w.o quotes) is still needed as args.

unless there is something C can do thats like Enum.values() ?

Quoted 4 lines

--
Ville Syrjälä
Intel

--
Ville Syrjälä
Intel

author maintainer
#37 lore raw

Re: [PATCH v9 30/52] drm-dyndbg: adapt drm core to use dyndbg classmaps-v2

Quoted 9 lines · On Wed, Jul 3, 2024 at 10:11 AM <[email protected]> wrote:

Got it.
I had some mental block about passing designated intializers as macro args. it just worked, I needed to eyeball the .i file just to be sure. thanks.
I have a fixup patch.
whats the best thing to do with it, squash it in for later ? send in reply here ?

I have to retract on designated-initializers into DYNDBG_CLASSMAP_DEFINE

While it works for DRM, and looks good, and self-documenting, it only works cuz DRM_UT_CORE = 0,
and breaks when I used it 2x in test-dynamic-debug.ko. the 2nd _DEFINE needs a _base > DRM_UT_LAST.

With designated-init exprs passed in thru the macro, I get:

1st classmap below is bad - the length should be 8, but is 28 cuz
init started at 20.

    (gdb) p *di->classes@di->num_classes
    $2 = {{mod = 0xffffffffc0203740, mod_name = 0xffffffffc0206220
"test_dynamic_debug",
        class_names = 0xffffffffc0203080, length = 28, base = 20,
map_type = DD_CLASS_TYPE_LEVEL_NUM}, {
        mod = 0xffffffffc0203740, mod_name = 0xffffffffc0206220
"test_dynamic_debug",
        class_names = 0xffffffffc0203160, length = 10, base = 0,
map_type = DD_CLASS_TYPE_DISJOINT_BITS}}
    (gdb)

    so 1st 20 classnames are empty, and classnames -> index -> classid

translation fails later.

    (gdb) p *di->classes[0]->class_names@di->classes[0]->length
    $4 = {0x0 <fixed_percpu_data> <repeats 20 times>,
0xffffffffc0206356 "V0", 0xffffffffc0206359 "V1",
      0xffffffffc020635c "V2", 0xffffffffc020635f "V3",
0xffffffffc0206362 "V4", 0xffffffffc0206365 "V5",
      0xffffffffc0206368 "V6", 0xffffffffc020636b "V7"}
    (gdb)

Basically, when designated-inits are passed in, the _base param is redundant, and the once guaranteed contiguous 0-based classnames list is now guaranteed sparse.

the macro could be altered to expect designated-inits, but I couldnt distinguish between the 2 different uses, so theres a mis-use potential either way.

Id prefer to keep the _DEFINE the way it is,
and better kdoc & howto this to explain away the potential.

BTW: Im aware I failed to delete some v9*patch files before git send-email, Im considering my penance, will resend soon.

author maintainer
#38 lore raw

PATCH v9 31/52 drm-dyndbg: adapt DRM to invoke DYNDBG_CLASSMAP_PARAM

In reply to Jim Cromie

Invoke DYNDBG_CLASSMAP_PARAM to hook drm.debug (__drm_debug) to the DRM_UT_* classmap, replacing the ad-hoc wiring previously doing it.

---
 drivers/gpu/drm/drm_print.c | 8 ++------
 include/drm/drm_print.h     | 6 ++++--
 2 files changed, 6 insertions(+), 8 deletions(-)
drivers/gpu/drm/drm_print.c +2 -6
index 4a5f2317229b..efdf82f8cbbb 100644
@@ -69,12 +69,8 @@ DRM_CLASSMAP_DEFINE(drm_debug_classes, DD_CLASS_TYPE_DISJOINT_BITS,
 		    "DRM_UT_DP",
 		    "DRM_UT_DRMRES");
 
-static struct ddebug_class_param drm_debug_bitmap = {
-	.bits = &__drm_debug,
-	.flags = "p",
-	.map = &drm_debug_classes,
-};
-module_param_cb(debug, &param_ops_dyndbg_classes, &drm_debug_bitmap, 0600);
+DRM_CLASSMAP_PARAM_REF(debug, __drm_debug, drm_debug_classes, p);
+
 #endif
 
 void __drm_puts_coredump(struct drm_printer *p, const char *str)
include/drm/drm_print.h +4 -2
index 905fc25bf65a..95c667934bbb 100644
@@ -141,11 +141,13 @@ enum drm_debug_category {
 };
 
 #ifdef CONFIG_DRM_USE_DYNAMIC_DEBUG
-#define DRM_CLASSMAP_DEFINE(...) DYNDBG_CLASSMAP_DEFINE(__VA_ARGS__)
-#define DRM_CLASSMAP_USE(name)   DYNDBG_CLASSMAP_USE(name)
+#define DRM_CLASSMAP_DEFINE(...)    DYNDBG_CLASSMAP_DEFINE(__VA_ARGS__)
+#define DRM_CLASSMAP_USE(name)      DYNDBG_CLASSMAP_USE(name)
+#define DRM_CLASSMAP_PARAM_REF(...) DYNDBG_CLASSMAP_PARAM_REF(__VA_ARGS__)
 #else
 #define DRM_CLASSMAP_DEFINE(...)
 #define DRM_CLASSMAP_USE(name)
+#define DRM_CLASSMAP_PARAM_REF(...)
 #endif
 
 static inline bool drm_debug_enabled_raw(enum drm_debug_category category)
Signature · 1 line
2.45.2
author maintainer
#39 lore raw

PATCH v9 32/53 DRM-CLASSMAP-USE in drm-drv.c

In reply to Jim Cromie
---
 drivers/gpu/drm/drm_drv.c | 3 +++
 1 file changed, 3 insertions(+)
drivers/gpu/drm/drm_drv.c +3 -0
index 243cacb3575c..f511d40f577a 100644
@@ -56,6 +56,9 @@ MODULE_LICENSE("GPL and additional rights");
 static DEFINE_SPINLOCK(drm_minor_lock);
 static struct idr drm_minors_idr;
 
+/* single ref for all clients ? */
+DRM_CLASSMAP_USE(drm_debug_classes);
+
 /*
  * If the drm core fails to init for whatever reason,
  * we should prevent any drivers from registering with it.
Signature · 1 line
2.45.2
author maintainer
#40 lore raw

Re: [PATCH v9 32/53] DRM-CLASSMAP-USE in drm-drv.c

Quoted 10 lines · Jim Cromie
---
 drivers/gpu/drm/drm_drv.c | 3 +++
 1 file changed, 3 insertions(+)
drivers/gpu/drm/drm_drv.c +0 -0
index 243cacb3575c..f511d40f577a 100644

drivers/gpu/drm/drm_drv.c MODULE_LICENSE("GPL and additional rights"); · line 59

Quoted 4 lines
drivers/gpu/drm/drm_drv.c +1 -0
@@ -56,6 +56,9 @@ MODULE_LICENSE("GPL and additional rights");
 static DEFINE_SPINLOCK(drm_minor_lock);
 static struct idr drm_minors_idr;
 
+/* single ref for all clients ? */

So this was my attempt to try a single USE from the client-side of drm core / driver interface.

I didnt find it to work, and meant to rebase it away.

Quoted 8 lines
drivers/gpu/drm/drm_drv.c +2 -1
+DRM_CLASSMAP_USE(drm_debug_classes);
+
 /*
  * If the drm core fails to init for whatever reason,
  * we should prevent any drivers from registering with it.
--

2.45.2

author maintainer
#41 lore raw

PATCH v9 32/52 drm-dyndbg: DRM_CLASSMAP_USE in amdgpu driver

In reply to Jim Cromie

Following the dyndbg-api-fix, replace DECLARE_DYNDBG_CLASSMAP with DRM_CLASSMAP_USE. This refs the defined & exported classmap, rather than re-declaring it redundantly, and error-prone-ly.

This resolves the appearance of "class:_UNKNOWN_" in the control file for the driver's drm_dbg()s.

Fixes f158936b60a7 ("drm: POC drm on dyndbg - use in core, 2 helpers, 3 drivers.")
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c | 12 +-----------
 1 file changed, 1 insertion(+), 11 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c +1 -11
index e4277298cf1a..b287f0cfd8fa 100644
@@ -217,17 +217,7 @@ int amdgpu_damage_clips = -1; /* auto */
 
 static void amdgpu_drv_delayed_reset_work_handler(struct work_struct *work);
 
-DECLARE_DYNDBG_CLASSMAP(drm_debug_classes, DD_CLASS_TYPE_DISJOINT_BITS, 0,
-			"DRM_UT_CORE",
-			"DRM_UT_DRIVER",
-			"DRM_UT_KMS",
-			"DRM_UT_PRIME",
-			"DRM_UT_ATOMIC",
-			"DRM_UT_VBL",
-			"DRM_UT_STATE",
-			"DRM_UT_LEASE",
-			"DRM_UT_DP",
-			"DRM_UT_DRMRES");
+DRM_CLASSMAP_USE(drm_debug_classes);
 
 struct amdgpu_mgpu_info mgpu_info = {
 	.mutex = __MUTEX_INITIALIZER(mgpu_info.mutex),
Signature · 1 line
2.45.2
author maintainer
#42 lore raw

PATCH v9 33/53 drm-dyndbg: DRM_CLASSMAP_USE in amdgpu driver

In reply to Jim Cromie

Following the dyndbg-api-fix, replace DECLARE_DYNDBG_CLASSMAP with DRM_CLASSMAP_USE. This refs the defined & exported classmap, rather than re-declaring it redundantly, and error-prone-ly.

This resolves the appearance of "class:_UNKNOWN_" in the control file for the driver's drm_dbg()s.

Fixes f158936b60a7 ("drm: POC drm on dyndbg - use in core, 2 helpers, 3 drivers.")
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c | 12 +-----------
 1 file changed, 1 insertion(+), 11 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c +1 -11
index e4277298cf1a..b287f0cfd8fa 100644
@@ -217,17 +217,7 @@ int amdgpu_damage_clips = -1; /* auto */
 
 static void amdgpu_drv_delayed_reset_work_handler(struct work_struct *work);
 
-DECLARE_DYNDBG_CLASSMAP(drm_debug_classes, DD_CLASS_TYPE_DISJOINT_BITS, 0,
-			"DRM_UT_CORE",
-			"DRM_UT_DRIVER",
-			"DRM_UT_KMS",
-			"DRM_UT_PRIME",
-			"DRM_UT_ATOMIC",
-			"DRM_UT_VBL",
-			"DRM_UT_STATE",
-			"DRM_UT_LEASE",
-			"DRM_UT_DP",
-			"DRM_UT_DRMRES");
+DRM_CLASSMAP_USE(drm_debug_classes);
 
 struct amdgpu_mgpu_info mgpu_info = {
 	.mutex = __MUTEX_INITIALIZER(mgpu_info.mutex),
Signature · 1 line
2.45.2
author maintainer
#43 lore raw

PATCH v9 33/52 drm-dyndbg: DRM_CLASSMAP_USE in i915 driver

In reply to Jim Cromie

Following the dyndbg-api-fix, replace DECLARE_DYNDBG_CLASSMAP with DRM_CLASSMAP_USE. This refs the defined & exported classmap, rather than re-declaring it redundantly, and error-prone-ly.

This resolves the appearance of "class:_UNKNOWN_" in the control file for the driver's drm_dbg()s.

Fixes f158936b60a7 ("drm: POC drm on dyndbg - use in core, 2 helpers, 3 drivers.")
---
 drivers/gpu/drm/i915/i915_params.c | 12 +-----------
 1 file changed, 1 insertion(+), 11 deletions(-)
drivers/gpu/drm/i915/i915_params.c +1 -11
index de43048543e8..dccf12d05105 100644
@@ -29,17 +29,7 @@
 #include "i915_params.h"
 #include "i915_drv.h"
 
-DECLARE_DYNDBG_CLASSMAP(drm_debug_classes, DD_CLASS_TYPE_DISJOINT_BITS, 0,
-			"DRM_UT_CORE",
-			"DRM_UT_DRIVER",
-			"DRM_UT_KMS",
-			"DRM_UT_PRIME",
-			"DRM_UT_ATOMIC",
-			"DRM_UT_VBL",
-			"DRM_UT_STATE",
-			"DRM_UT_LEASE",
-			"DRM_UT_DP",
-			"DRM_UT_DRMRES");
+DRM_CLASSMAP_USE(drm_debug_classes);
 
 #define i915_param_named(name, T, perm, desc) \
 	module_param_named(name, i915_modparams.name, T, perm); \
Signature · 1 line
2.45.2
author maintainer
#44 lore raw

PATCH v9 34/52 drm-dyndbg: DRM_CLASSMAP_USE in drm_crtc_helper

In reply to Jim Cromie

Following the dyndbg-api-fix, replace DECLARE_DYNDBG_CLASSMAP with DRM_CLASSMAP_USE. This refs the defined & exported classmap, rather than re-declaring it redundantly, and error-prone-ly.

This resolves the appearance of "class:_UNKNOWN_" in the control file for the driver's drm_dbg()s.

Fixes f158936b60a7 ("drm: POC drm on dyndbg - use in core, 2 helpers, 3 drivers.")
---
 drivers/gpu/drm/drm_crtc_helper.c | 12 +-----------
 1 file changed, 1 insertion(+), 11 deletions(-)
drivers/gpu/drm/drm_crtc_helper.c +1 -11
index 2dafc39a27cb..e9d229a393f4 100644
@@ -50,17 +50,7 @@
 
 #include "drm_crtc_helper_internal.h"
 
-DECLARE_DYNDBG_CLASSMAP(drm_debug_classes, DD_CLASS_TYPE_DISJOINT_BITS, 0,
-			"DRM_UT_CORE",
-			"DRM_UT_DRIVER",
-			"DRM_UT_KMS",
-			"DRM_UT_PRIME",
-			"DRM_UT_ATOMIC",
-			"DRM_UT_VBL",
-			"DRM_UT_STATE",
-			"DRM_UT_LEASE",
-			"DRM_UT_DP",
-			"DRM_UT_DRMRES");
+DRM_CLASSMAP_USE(drm_debug_classes);
 
 /**
  * DOC: overview
Signature · 1 line
2.45.2
author maintainer
#45 lore raw

PATCH v9 34/53 drm-dyndbg: DRM_CLASSMAP_USE in i915 driver

In reply to Jim Cromie

Following the dyndbg-api-fix, replace DECLARE_DYNDBG_CLASSMAP with DRM_CLASSMAP_USE. This refs the defined & exported classmap, rather than re-declaring it redundantly, and error-prone-ly.

This resolves the appearance of "class:_UNKNOWN_" in the control file for the driver's drm_dbg()s.

Fixes f158936b60a7 ("drm: POC drm on dyndbg - use in core, 2 helpers, 3 drivers.")
---
 drivers/gpu/drm/i915/i915_params.c | 12 +-----------
 1 file changed, 1 insertion(+), 11 deletions(-)
drivers/gpu/drm/i915/i915_params.c +1 -11
index de43048543e8..dccf12d05105 100644
@@ -29,17 +29,7 @@
 #include "i915_params.h"
 #include "i915_drv.h"
 
-DECLARE_DYNDBG_CLASSMAP(drm_debug_classes, DD_CLASS_TYPE_DISJOINT_BITS, 0,
-			"DRM_UT_CORE",
-			"DRM_UT_DRIVER",
-			"DRM_UT_KMS",
-			"DRM_UT_PRIME",
-			"DRM_UT_ATOMIC",
-			"DRM_UT_VBL",
-			"DRM_UT_STATE",
-			"DRM_UT_LEASE",
-			"DRM_UT_DP",
-			"DRM_UT_DRMRES");
+DRM_CLASSMAP_USE(drm_debug_classes);
 
 #define i915_param_named(name, T, perm, desc) \
 	module_param_named(name, i915_modparams.name, T, perm); \
Signature · 1 line
2.45.2
author maintainer
#46 lore raw

PATCH v9 35/53 drm-dyndbg: DRM_CLASSMAP_USE in drm_crtc_helper

In reply to Jim Cromie

Following the dyndbg-api-fix, replace DECLARE_DYNDBG_CLASSMAP with DRM_CLASSMAP_USE. This refs the defined & exported classmap, rather than re-declaring it redundantly, and error-prone-ly.

This resolves the appearance of "class:_UNKNOWN_" in the control file for the driver's drm_dbg()s.

Fixes f158936b60a7 ("drm: POC drm on dyndbg - use in core, 2 helpers, 3 drivers.")
---
 drivers/gpu/drm/drm_crtc_helper.c | 12 +-----------
 1 file changed, 1 insertion(+), 11 deletions(-)
drivers/gpu/drm/drm_crtc_helper.c +1 -11
index 2dafc39a27cb..e9d229a393f4 100644
@@ -50,17 +50,7 @@
 
 #include "drm_crtc_helper_internal.h"
 
-DECLARE_DYNDBG_CLASSMAP(drm_debug_classes, DD_CLASS_TYPE_DISJOINT_BITS, 0,
-			"DRM_UT_CORE",
-			"DRM_UT_DRIVER",
-			"DRM_UT_KMS",
-			"DRM_UT_PRIME",
-			"DRM_UT_ATOMIC",
-			"DRM_UT_VBL",
-			"DRM_UT_STATE",
-			"DRM_UT_LEASE",
-			"DRM_UT_DP",
-			"DRM_UT_DRMRES");
+DRM_CLASSMAP_USE(drm_debug_classes);
 
 /**
  * DOC: overview
Signature · 1 line
2.45.2
author maintainer
#47 lore raw

PATCH v9 35/52 drm-dyndbg: DRM_CLASSMAP_USE in drm_dp_helper

In reply to Jim Cromie

Following the dyndbg-api-fix, replace DECLARE_DYNDBG_CLASSMAP with DRM_CLASSMAP_USE. This refs the defined & exported classmap, rather than re-declaring it redundantly, and error-prone-ly.

This resolves the appearance of "class:_UNKNOWN_" in the control file for the driver's drm_dbg()s.

Fixes f158936b60a7 ("drm: POC drm on dyndbg - use in core, 2 helpers, 3 drivers.")
---
 drivers/gpu/drm/display/drm_dp_helper.c | 12 +-----------
 1 file changed, 1 insertion(+), 11 deletions(-)
drivers/gpu/drm/display/drm_dp_helper.c +1 -11
index f5d4be897866..d3a7df09846f 100644
@@ -41,17 +41,7 @@
 
 #include "drm_dp_helper_internal.h"
 
-DECLARE_DYNDBG_CLASSMAP(drm_debug_classes, DD_CLASS_TYPE_DISJOINT_BITS, 0,
-			"DRM_UT_CORE",
-			"DRM_UT_DRIVER",
-			"DRM_UT_KMS",
-			"DRM_UT_PRIME",
-			"DRM_UT_ATOMIC",
-			"DRM_UT_VBL",
-			"DRM_UT_STATE",
-			"DRM_UT_LEASE",
-			"DRM_UT_DP",
-			"DRM_UT_DRMRES");
+DRM_CLASSMAP_USE(drm_debug_classes);
 
 struct dp_aux_backlight {
 	struct backlight_device *base;
Signature · 1 line
2.45.2
author maintainer
#48 lore raw

PATCH v9 36/53 drm-dyndbg: DRM_CLASSMAP_USE in drm_dp_helper

In reply to Jim Cromie

Following the dyndbg-api-fix, replace DECLARE_DYNDBG_CLASSMAP with DRM_CLASSMAP_USE. This refs the defined & exported classmap, rather than re-declaring it redundantly, and error-prone-ly.

This resolves the appearance of "class:_UNKNOWN_" in the control file for the driver's drm_dbg()s.

Fixes f158936b60a7 ("drm: POC drm on dyndbg - use in core, 2 helpers, 3 drivers.")
---
 drivers/gpu/drm/display/drm_dp_helper.c | 12 +-----------
 1 file changed, 1 insertion(+), 11 deletions(-)
drivers/gpu/drm/display/drm_dp_helper.c +1 -11
index f5d4be897866..d3a7df09846f 100644
@@ -41,17 +41,7 @@
 
 #include "drm_dp_helper_internal.h"
 
-DECLARE_DYNDBG_CLASSMAP(drm_debug_classes, DD_CLASS_TYPE_DISJOINT_BITS, 0,
-			"DRM_UT_CORE",
-			"DRM_UT_DRIVER",
-			"DRM_UT_KMS",
-			"DRM_UT_PRIME",
-			"DRM_UT_ATOMIC",
-			"DRM_UT_VBL",
-			"DRM_UT_STATE",
-			"DRM_UT_LEASE",
-			"DRM_UT_DP",
-			"DRM_UT_DRMRES");
+DRM_CLASSMAP_USE(drm_debug_classes);
 
 struct dp_aux_backlight {
 	struct backlight_device *base;
Signature · 1 line
2.45.2
author maintainer
#49 lore raw

PATCH v9 36/52 drm-dyndbg: DRM_CLASSMAP_USE in nouveau

In reply to Jim Cromie

Following the dyndbg-api-fix, replace DECLARE_DYNDBG_CLASSMAP with DRM_CLASSMAP_USE. This refs the defined & exported classmap, rather than re-declaring it redundantly, and error-prone-ly.

This resolves the appearance of "class:_UNKNOWN_" in the control file for the driver's drm_dbg()s.

Fixes f158936b60a7 ("drm: POC drm on dyndbg - use in core, 2 helpers, 3 drivers.")
---
 drivers/gpu/drm/nouveau/nouveau_drm.c | 12 +-----------
 1 file changed, 1 insertion(+), 11 deletions(-)
drivers/gpu/drm/nouveau/nouveau_drm.c +1 -11
index a947e1d5f309..27995c0c9b31 100644
@@ -72,17 +72,7 @@
 #include "nouveau_uvmm.h"
 #include "nouveau_sched.h"
 
-DECLARE_DYNDBG_CLASSMAP(drm_debug_classes, DD_CLASS_TYPE_DISJOINT_BITS, 0,
-			"DRM_UT_CORE",
-			"DRM_UT_DRIVER",
-			"DRM_UT_KMS",
-			"DRM_UT_PRIME",
-			"DRM_UT_ATOMIC",
-			"DRM_UT_VBL",
-			"DRM_UT_STATE",
-			"DRM_UT_LEASE",
-			"DRM_UT_DP",
-			"DRM_UT_DRMRES");
+DRM_CLASSMAP_USE(drm_debug_classes);
 
 MODULE_PARM_DESC(config, "option string to pass to driver core");
 static char *nouveau_config;
Signature · 1 line
2.45.2
author maintainer
#50 lore raw

PATCH v9 37/53 drm-dyndbg: DRM_CLASSMAP_USE in nouveau

In reply to Jim Cromie

Following the dyndbg-api-fix, replace DECLARE_DYNDBG_CLASSMAP with DRM_CLASSMAP_USE. This refs the defined & exported classmap, rather than re-declaring it redundantly, and error-prone-ly.

This resolves the appearance of "class:_UNKNOWN_" in the control file for the driver's drm_dbg()s.

Fixes f158936b60a7 ("drm: POC drm on dyndbg - use in core, 2 helpers, 3 drivers.")
---
 drivers/gpu/drm/nouveau/nouveau_drm.c | 12 +-----------
 1 file changed, 1 insertion(+), 11 deletions(-)
drivers/gpu/drm/nouveau/nouveau_drm.c +1 -11
index a947e1d5f309..27995c0c9b31 100644
@@ -72,17 +72,7 @@
 #include "nouveau_uvmm.h"
 #include "nouveau_sched.h"
 
-DECLARE_DYNDBG_CLASSMAP(drm_debug_classes, DD_CLASS_TYPE_DISJOINT_BITS, 0,
-			"DRM_UT_CORE",
-			"DRM_UT_DRIVER",
-			"DRM_UT_KMS",
-			"DRM_UT_PRIME",
-			"DRM_UT_ATOMIC",
-			"DRM_UT_VBL",
-			"DRM_UT_STATE",
-			"DRM_UT_LEASE",
-			"DRM_UT_DP",
-			"DRM_UT_DRMRES");
+DRM_CLASSMAP_USE(drm_debug_classes);
 
 MODULE_PARM_DESC(config, "option string to pass to driver core");
 static char *nouveau_config;
Signature · 1 line
2.45.2
author maintainer
#51 lore raw

PATCH v9 37/52 drm-print: workaround unused variable compiler meh

In reply to Jim Cromie

With CONFIG_DRM_USE_DYNAMIC_DEBUG=y, I'm getting an unused variable warning/error on 'category', though the usage follows immediately, in drm_debug_enabled().

This drops the local var and refs the field directly in the macro-call, which avoids the warning. For static-key optimized dyndbg, the macro doesn't actually check the category, since the static-key patches in the proper state. This is also likely why the auto var appears to be unused by the compiler.

commit 9fd6f61a297e ("drm/print: add drm_dbg_printer() for drm device specific printer")

---
 drivers/gpu/drm/drm_print.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/gpu/drm/drm_print.c +1 -2
index efdf82f8cbbb..c400441cd77e 100644
@@ -183,11 +183,10 @@ void __drm_printfn_dbg(struct drm_printer *p, struct va_format *vaf)
 {
 	const struct drm_device *drm = p->arg;
 	const struct device *dev = drm ? drm->dev : NULL;
-	enum drm_debug_category category = p->category;
 	const char *prefix = p->prefix ?: "";
 	const char *prefix_pad = p->prefix ? " " : "";
 
-	if (!__drm_debug_enabled(category))
+	if (!__drm_debug_enabled(p->category))
 		return;
 
 	/* Note: __builtin_return_address(0) is useless here. */
Signature · 1 line
2.45.2
author maintainer
#52 lore raw

PATCH v9 38/52 drm-dyndbg: add DRM_CLASSMAP_USE to Xe driver

In reply to Jim Cromie

Invoke DRM_CLASSMAP_USE from xe_drm_client.c. When built with CONFIG_DRM_USE_DYNAMIC_DEBUG=y, this tells dydnbg that Xe uses has drm.debug calls.

---
 drivers/gpu/drm/xe/xe_drm_client.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/gpu/drm/xe/xe_drm_client.c +2 -0
index 87c10bd7958b..c61163d0d945 100644
@@ -15,6 +15,8 @@
 #include "xe_drm_client.h"
 #include "xe_trace.h"
 
+DRM_CLASSMAP_USE(drm_debug_classes);
+
 /**
  * xe_drm_client_alloc() - Allocate drm client
  * @void: No arg
Signature · 1 line
2.45.2
author maintainer
#53 lore raw

PATCH v9 38/53 drm-print: workaround unused variable compiler meh

In reply to Jim Cromie

With CONFIG_DRM_USE_DYNAMIC_DEBUG=y, I'm getting an unused variable warning/error on 'category', though the usage follows immediately, in drm_debug_enabled().

This drops the local var and refs the field directly in the macro-call, which avoids the warning. For static-key optimized dyndbg, the macro doesn't actually check the category, since the static-key patches in the proper state. This is also likely why the auto var appears to be unused by the compiler.

commit 9fd6f61a297e ("drm/print: add drm_dbg_printer() for drm device specific printer")

---
 drivers/gpu/drm/drm_print.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/gpu/drm/drm_print.c +1 -2
index efdf82f8cbbb..c400441cd77e 100644
@@ -183,11 +183,10 @@ void __drm_printfn_dbg(struct drm_printer *p, struct va_format *vaf)
 {
 	const struct drm_device *drm = p->arg;
 	const struct device *dev = drm ? drm->dev : NULL;
-	enum drm_debug_category category = p->category;
 	const char *prefix = p->prefix ?: "";
 	const char *prefix_pad = p->prefix ? " " : "";
 
-	if (!__drm_debug_enabled(category))
+	if (!__drm_debug_enabled(p->category))
 		return;
 
 	/* Note: __builtin_return_address(0) is useless here. */
Signature · 1 line
2.45.2
author maintainer
#54 lore raw

PATCH v9 39/52 drm-dyndbg: add DRM_CLASSMAP_USE to virtio_gpu

In reply to Jim Cromie

virtio_gpu has 10 DRM_UT_CORE debugs, make them controllable when CONFIG_DRM_USE_DYNAMIC_DEBUG=y by telling dyndbg that the module has class'd debugs.

---
 drivers/gpu/drm/virtio/virtgpu_drv.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/gpu/drm/virtio/virtgpu_drv.c +2 -0
index 9539aa28937f..bb3a3e042264 100644
@@ -44,6 +44,8 @@ static const struct drm_driver driver;
 
 static int virtio_gpu_modeset = -1;
 
+DRM_CLASSMAP_USE(drm_debug_classes);
+
 MODULE_PARM_DESC(modeset, "Disable/Enable modesetting");
 module_param_named(modeset, virtio_gpu_modeset, int, 0400);
 
Signature · 1 line
2.45.2
author maintainer
#55 lore raw

PATCH v9 39/53 drm-dyndbg: add DRM_CLASSMAP_USE to Xe driver

In reply to Jim Cromie

Invoke DRM_CLASSMAP_USE from xe_drm_client.c. When built with CONFIG_DRM_USE_DYNAMIC_DEBUG=y, this tells dydnbg that Xe uses has drm.debug calls.

---
 drivers/gpu/drm/xe/xe_drm_client.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/gpu/drm/xe/xe_drm_client.c +2 -0
index 87c10bd7958b..c61163d0d945 100644
@@ -15,6 +15,8 @@
 #include "xe_drm_client.h"
 #include "xe_trace.h"
 
+DRM_CLASSMAP_USE(drm_debug_classes);
+
 /**
  * xe_drm_client_alloc() - Allocate drm client
  * @void: No arg
Signature · 1 line
2.45.2
author maintainer
#56 lore raw

PATCH v9 40/52 drm-dyndbg: add DRM_CLASSMAP_USE to simpledrm

In reply to Jim Cromie

tiny/simpledrm has 3 DRM_UT_DRIVER debugs, make them controllable when CONFIG_DRM_USE_DYNAMIC_DEBUG=y by telling dyndbg that the module has class'd debugs.

---
 drivers/gpu/drm/tiny/simpledrm.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/gpu/drm/tiny/simpledrm.c +2 -0
index 7ce1c4617675..9cab48bd0581 100644
@@ -33,6 +33,8 @@
 #define DRIVER_MAJOR	1
 #define DRIVER_MINOR	0
 
+DRM_CLASSMAP_USE(drm_debug_classes);
+
 /*
  * Helpers for simplefb
  */
Signature · 1 line
2.45.2
author maintainer
#57 lore raw

PATCH v9 40/53 drm-dyndbg: add DRM_CLASSMAP_USE to virtio_gpu

In reply to Jim Cromie

virtio_gpu has 10 DRM_UT_CORE debugs, make them controllable when CONFIG_DRM_USE_DYNAMIC_DEBUG=y by telling dyndbg that the module has class'd debugs.

---
 drivers/gpu/drm/virtio/virtgpu_drv.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/gpu/drm/virtio/virtgpu_drv.c +2 -0
index 9539aa28937f..bb3a3e042264 100644
@@ -44,6 +44,8 @@ static const struct drm_driver driver;
 
 static int virtio_gpu_modeset = -1;
 
+DRM_CLASSMAP_USE(drm_debug_classes);
+
 MODULE_PARM_DESC(modeset, "Disable/Enable modesetting");
 module_param_named(modeset, virtio_gpu_modeset, int, 0400);
 
Signature · 1 line
2.45.2
author maintainer
#58 lore raw

PATCH v9 41/52 drm-dyndbg: add DRM_CLASSMAP_USE to bochs

In reply to Jim Cromie

tiny/bochs has 5 DRM_UT_* debugs, make them controllable when CONFIG_DRM_USE_DYNAMIC_DEBUG=y by telling dyndbg that the module has class'd debugs.

---
 drivers/gpu/drm/tiny/bochs.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/gpu/drm/tiny/bochs.c +2 -0
index c23c9f0cf49c..ee98fab5597e 100644
@@ -54,6 +54,8 @@ static int bochs_modeset = -1;
 static int defx = 1024;
 static int defy = 768;
 
+DRM_CLASSMAP_USE(drm_debug_classes);
+
 module_param_named(modeset, bochs_modeset, int, 0444);
 MODULE_PARM_DESC(modeset, "enable/disable kernel modesetting");
 
Signature · 1 line
2.45.2
author maintainer
#59 lore raw

PATCH v9 41/53 drm-dyndbg: add DRM_CLASSMAP_USE to simpledrm

In reply to Jim Cromie

tiny/simpledrm has 3 DRM_UT_DRIVER debugs, make them controllable when CONFIG_DRM_USE_DYNAMIC_DEBUG=y by telling dyndbg that the module has class'd debugs.

---
 drivers/gpu/drm/tiny/simpledrm.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/gpu/drm/tiny/simpledrm.c +2 -0
index 7ce1c4617675..9cab48bd0581 100644
@@ -33,6 +33,8 @@
 #define DRIVER_MAJOR	1
 #define DRIVER_MINOR	0
 
+DRM_CLASSMAP_USE(drm_debug_classes);
+
 /*
  * Helpers for simplefb
  */
Signature · 1 line
2.45.2
author maintainer
#60 lore raw

PATCH v9 42/53 drm-dyndbg: add DRM_CLASSMAP_USE to bochs

In reply to Jim Cromie

tiny/bochs has 5 DRM_UT_* debugs, make them controllable when CONFIG_DRM_USE_DYNAMIC_DEBUG=y by telling dyndbg that the module has class'd debugs.

---
 drivers/gpu/drm/tiny/bochs.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/gpu/drm/tiny/bochs.c +2 -0
index c23c9f0cf49c..ee98fab5597e 100644
@@ -54,6 +54,8 @@ static int bochs_modeset = -1;
 static int defx = 1024;
 static int defy = 768;
 
+DRM_CLASSMAP_USE(drm_debug_classes);
+
 module_param_named(modeset, bochs_modeset, int, 0444);
 MODULE_PARM_DESC(modeset, "enable/disable kernel modesetting");
 
Signature · 1 line
2.45.2
author maintainer
#61 lore raw

PATCH v9 42/52 drm-dyndbg: add DRM_CLASSMAP_USE to etnaviv

In reply to Jim Cromie

etnaviv has 5 DRM_UT_CORE debugs, make them controllable when CONFIG_DRM_USE_DYNAMIC_DEBUG=y by telling dyndbg that the module has class'd debugs as well as plain-old pr_debug()s

---
 drivers/gpu/drm/etnaviv/etnaviv_drv.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/gpu/drm/etnaviv/etnaviv_drv.c +2 -0
index 6500f3999c5f..1d1ddbedcb5a 100644
@@ -25,6 +25,8 @@
 #include "etnaviv_mmu.h"
 #include "etnaviv_perfmon.h"
 
+DRM_CLASSMAP_USE(drm_debug_classes);
+
 /*
  * DRM operations:
  */
Signature · 1 line
2.45.2
author maintainer
#62 lore raw

PATCH v9 43/53 drm-dyndbg: add DRM_CLASSMAP_USE to etnaviv

In reply to Jim Cromie

etnaviv has 5 DRM_UT_CORE debugs, make them controllable when CONFIG_DRM_USE_DYNAMIC_DEBUG=y by telling dyndbg that the module has class'd debugs as well as plain-old pr_debug()s

---
 drivers/gpu/drm/etnaviv/etnaviv_drv.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/gpu/drm/etnaviv/etnaviv_drv.c +2 -0
index 6500f3999c5f..1d1ddbedcb5a 100644
@@ -25,6 +25,8 @@
 #include "etnaviv_mmu.h"
 #include "etnaviv_perfmon.h"
 
+DRM_CLASSMAP_USE(drm_debug_classes);
+
 /*
  * DRM operations:
  */
Signature · 1 line
2.45.2
author maintainer
#63 lore raw

PATCH v9 43/52 drm-dyndbg: add DRM_CLASSMAP_USE to gma500 driver

In reply to Jim Cromie

The gma500 has 126 DRM_UT_* debugs, make them controllable when CONFIG_DRM_USE_DYNAMIC_DEBUG=y by telling dyndbg that the module has class'd debugs.

---
 drivers/gpu/drm/gma500/psb_drv.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/gpu/drm/gma500/psb_drv.c +2 -0
index 8b64f61ffaf9..5e03ac7ff433 100644
@@ -39,6 +39,8 @@
 static const struct drm_driver driver;
 static int psb_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent);
 
+DRM_CLASSMAP_USE(drm_debug_classes);
+
 /*
  * The table below contains a mapping of the PCI vendor ID and the PCI Device ID
  * to the different groups of PowerVR 5-series chip designs
Signature · 1 line
2.45.2
author maintainer
#64 lore raw

PATCH v9 44/53 drm-dyndbg: add DRM_CLASSMAP_USE to gma500 driver

In reply to Jim Cromie

The gma500 has 126 DRM_UT_* debugs, make them controllable when CONFIG_DRM_USE_DYNAMIC_DEBUG=y by telling dyndbg that the module has class'd debugs.

---
 drivers/gpu/drm/gma500/psb_drv.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/gpu/drm/gma500/psb_drv.c +2 -0
index 8b64f61ffaf9..5e03ac7ff433 100644
@@ -39,6 +39,8 @@
 static const struct drm_driver driver;
 static int psb_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent);
 
+DRM_CLASSMAP_USE(drm_debug_classes);
+
 /*
  * The table below contains a mapping of the PCI vendor ID and the PCI Device ID
  * to the different groups of PowerVR 5-series chip designs
Signature · 1 line
2.45.2
author maintainer
#65 lore raw

PATCH v9 44/52 drm-dyndbg: add DRM_CLASSMAP_USE to radeon

In reply to Jim Cromie

radeon has some DRM_UT_* debugs, make them controllable when CONFIG_DRM_USE_DYNAMIC_DEBUG=y by telling dyndbg about its use of the class'd debugs.

---
 drivers/gpu/drm/radeon/radeon_drv.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/gpu/drm/radeon/radeon_drv.c +2 -0
index 7bf08164140e..d22308328c76 100644
@@ -247,6 +247,8 @@ int radeon_cik_support = 1;
 MODULE_PARM_DESC(cik_support, "CIK support (1 = enabled (default), 0 = disabled)");
 module_param_named(cik_support, radeon_cik_support, int, 0444);
 
+DRM_CLASSMAP_USE(drm_debug_classes);
+
 static struct pci_device_id pciidlist[] = {
 	radeon_PCI_IDS
 };
Signature · 1 line
2.45.2
author maintainer
#66 lore raw

PATCH v9 45/53 drm-dyndbg: add DRM_CLASSMAP_USE to radeon

In reply to Jim Cromie

radeon has some DRM_UT_* debugs, make them controllable when CONFIG_DRM_USE_DYNAMIC_DEBUG=y by telling dyndbg about its use of the class'd debugs.

---
 drivers/gpu/drm/radeon/radeon_drv.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/gpu/drm/radeon/radeon_drv.c +2 -0
index 7bf08164140e..d22308328c76 100644
@@ -247,6 +247,8 @@ int radeon_cik_support = 1;
 MODULE_PARM_DESC(cik_support, "CIK support (1 = enabled (default), 0 = disabled)");
 module_param_named(cik_support, radeon_cik_support, int, 0444);
 
+DRM_CLASSMAP_USE(drm_debug_classes);
+
 static struct pci_device_id pciidlist[] = {
 	radeon_PCI_IDS
 };
Signature · 1 line
2.45.2
author maintainer
#67 lore raw

PATCH v9 45/52 drm-dyndbg: add DRM_CLASSMAP_USE to vmwgfx driver

In reply to Jim Cromie

The vmwgfx driver has a number of DRM_UT_* debugs, make them controllable when CONFIG_DRM_USE_DYNAMIC_DEBUG=y by telling dyndbg that the module uses them.

---
 drivers/gpu/drm/vmwgfx/vmwgfx_drv.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/gpu/drm/vmwgfx/vmwgfx_drv.c +2 -0
index 58fb40c93100..c159f4d186a3 100644
@@ -275,6 +275,8 @@ static int vmw_probe(struct pci_dev *, const struct pci_device_id *);
 static int vmwgfx_pm_notifier(struct notifier_block *nb, unsigned long val,
 			      void *ptr);
 
+DRM_CLASSMAP_USE(drm_debug_classes);
+
 MODULE_PARM_DESC(restrict_iommu, "Try to limit IOMMU usage for TTM pages");
 module_param_named(restrict_iommu, vmw_restrict_iommu, int, 0600);
 MODULE_PARM_DESC(force_coherent, "Force coherent TTM pages");
Signature · 1 line
2.45.2
author maintainer
#68 lore raw

PATCH v9 46/52 drm-dyndbg: add DRM_CLASSMAP_USE to vkms driver

In reply to Jim Cromie

The vkms driver has a number of DRM_UT_* debugs, make them controllable when CONFIG_DRM_USE_DYNAMIC_DEBUG=y by telling dyndbg that the module uses them.

---
 drivers/gpu/drm/vkms/vkms_drv.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/gpu/drm/vkms/vkms_drv.c +2 -0
index dd0af086e7fa..086797c4b82b 100644
@@ -39,6 +39,8 @@
 
 static struct vkms_config *default_config;
 
+DRM_CLASSMAP_USE(drm_debug_classes);
+
 static bool enable_cursor = true;
 module_param_named(enable_cursor, enable_cursor, bool, 0444);
 MODULE_PARM_DESC(enable_cursor, "Enable/Disable cursor support");
Signature · 1 line
2.45.2
author maintainer
#69 lore raw

PATCH v9 46/53 drm-dyndbg: add DRM_CLASSMAP_USE to vmwgfx driver

In reply to Jim Cromie

The vmwgfx driver has a number of DRM_UT_* debugs, make them controllable when CONFIG_DRM_USE_DYNAMIC_DEBUG=y by telling dyndbg that the module uses them.

---
 drivers/gpu/drm/vmwgfx/vmwgfx_drv.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/gpu/drm/vmwgfx/vmwgfx_drv.c +2 -0
index 58fb40c93100..c159f4d186a3 100644
@@ -275,6 +275,8 @@ static int vmw_probe(struct pci_dev *, const struct pci_device_id *);
 static int vmwgfx_pm_notifier(struct notifier_block *nb, unsigned long val,
 			      void *ptr);
 
+DRM_CLASSMAP_USE(drm_debug_classes);
+
 MODULE_PARM_DESC(restrict_iommu, "Try to limit IOMMU usage for TTM pages");
 module_param_named(restrict_iommu, vmw_restrict_iommu, int, 0600);
 MODULE_PARM_DESC(force_coherent, "Force coherent TTM pages");
Signature · 1 line
2.45.2
author maintainer
#70 lore raw

PATCH v9 47/52 drm-dyndbg: add DRM_CLASSMAP_USE to udl driver

In reply to Jim Cromie

The udl driver has a number of DRM_UT_* debugs, make them controllable when CONFIG_DRM_USE_DYNAMIC_DEBUG=y by telling dyndbg that the module uses them.

---
 drivers/gpu/drm/udl/udl_main.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/gpu/drm/udl/udl_main.c +2 -0
index 3ebe2ce55dfd..ba57c14454e5 100644
@@ -19,6 +19,8 @@
 
 #define NR_USB_REQUEST_CHANNEL 0x12
 
+DRM_CLASSMAP_USE(drm_debug_classes);
+
 #define MAX_TRANSFER (PAGE_SIZE*16 - BULK_SIZE)
 #define WRITES_IN_FLIGHT (20)
 #define MAX_VENDOR_DESCRIPTOR_SIZE 256
Signature · 1 line
2.45.2
author maintainer
#71 lore raw

PATCH v9 47/53 drm-dyndbg: add DRM_CLASSMAP_USE to vkms driver

In reply to Jim Cromie

The vkms driver has a number of DRM_UT_* debugs, make them controllable when CONFIG_DRM_USE_DYNAMIC_DEBUG=y by telling dyndbg that the module uses them.

---
 drivers/gpu/drm/vkms/vkms_drv.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/gpu/drm/vkms/vkms_drv.c +2 -0
index dd0af086e7fa..086797c4b82b 100644
@@ -39,6 +39,8 @@
 
 static struct vkms_config *default_config;
 
+DRM_CLASSMAP_USE(drm_debug_classes);
+
 static bool enable_cursor = true;
 module_param_named(enable_cursor, enable_cursor, bool, 0444);
 MODULE_PARM_DESC(enable_cursor, "Enable/Disable cursor support");
Signature · 1 line
2.45.2
author maintainer
#72 lore raw

PATCH v9 48/52 drm-dyndbg: add DRM_CLASSMAP_USE to mgag200 driver

In reply to Jim Cromie

The mgag200 driver has a number of DRM_UT_* debugs, make them controllable when CONFIG_DRM_USE_DYNAMIC_DEBUG=y by telling dyndbg that the module uses them.

---
 drivers/gpu/drm/mgag200/mgag200_drv.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/gpu/drm/mgag200/mgag200_drv.c +2 -0
index 573dbe256aa8..88c5e24cc894 100644
@@ -25,6 +25,8 @@ static int mgag200_modeset = -1;
 MODULE_PARM_DESC(modeset, "Disable/Enable modesetting");
 module_param_named(modeset, mgag200_modeset, int, 0400);
 
+DRM_CLASSMAP_USE(drm_debug_classes);
+
 int mgag200_init_pci_options(struct pci_dev *pdev, u32 option, u32 option2)
 {
 	struct device *dev = &pdev->dev;
Signature · 1 line
2.45.2
author maintainer
#73 lore raw

PATCH v9 48/53 drm-dyndbg: add DRM_CLASSMAP_USE to udl driver

In reply to Jim Cromie

The udl driver has a number of DRM_UT_* debugs, make them controllable when CONFIG_DRM_USE_DYNAMIC_DEBUG=y by telling dyndbg that the module uses them.

---
 drivers/gpu/drm/udl/udl_main.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/gpu/drm/udl/udl_main.c +2 -0
index 3ebe2ce55dfd..ba57c14454e5 100644
@@ -19,6 +19,8 @@
 
 #define NR_USB_REQUEST_CHANNEL 0x12
 
+DRM_CLASSMAP_USE(drm_debug_classes);
+
 #define MAX_TRANSFER (PAGE_SIZE*16 - BULK_SIZE)
 #define WRITES_IN_FLIGHT (20)
 #define MAX_VENDOR_DESCRIPTOR_SIZE 256
Signature · 1 line
2.45.2
author maintainer
#74 lore raw

PATCH v9 49/53 drm-dyndbg: add DRM_CLASSMAP_USE to mgag200 driver

In reply to Jim Cromie

The mgag200 driver has a number of DRM_UT_* debugs, make them controllable when CONFIG_DRM_USE_DYNAMIC_DEBUG=y by telling dyndbg that the module uses them.

---
 drivers/gpu/drm/mgag200/mgag200_drv.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/gpu/drm/mgag200/mgag200_drv.c +2 -0
index 573dbe256aa8..88c5e24cc894 100644
@@ -25,6 +25,8 @@ static int mgag200_modeset = -1;
 MODULE_PARM_DESC(modeset, "Disable/Enable modesetting");
 module_param_named(modeset, mgag200_modeset, int, 0400);
 
+DRM_CLASSMAP_USE(drm_debug_classes);
+
 int mgag200_init_pci_options(struct pci_dev *pdev, u32 option, u32 option2)
 {
 	struct device *dev = &pdev->dev;
Signature · 1 line
2.45.2
author maintainer
#75 lore raw

PATCH v9 49/52 drm-dyndbg: add DRM_CLASSMAP_USE to the gud driver

In reply to Jim Cromie

The gud driver has a number of DRM_UT_* debugs, make them controllable when CONFIG_DRM_USE_DYNAMIC_DEBUG=y by telling dyndbg that the module uses them.

---
 drivers/gpu/drm/gud/gud_drv.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/gpu/drm/gud/gud_drv.c +2 -0
index 9d7bf8ee45f1..5b555045fce4 100644
@@ -31,6 +31,8 @@
 
 #include "gud_internal.h"
 
+DRM_CLASSMAP_USE(drm_debug_classes);
+
 /* Only used internally */
 static const struct drm_format_info gud_drm_format_r1 = {
 	.format = GUD_DRM_FORMAT_R1,
Signature · 1 line
2.45.2
author maintainer
#76 lore raw

PATCH v9 50/53 drm-dyndbg: add DRM_CLASSMAP_USE to the gud driver

In reply to Jim Cromie

The gud driver has a number of DRM_UT_* debugs, make them controllable when CONFIG_DRM_USE_DYNAMIC_DEBUG=y by telling dyndbg that the module uses them.

---
 drivers/gpu/drm/gud/gud_drv.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/gpu/drm/gud/gud_drv.c +2 -0
index 9d7bf8ee45f1..5b555045fce4 100644
@@ -31,6 +31,8 @@
 
 #include "gud_internal.h"
 
+DRM_CLASSMAP_USE(drm_debug_classes);
+
 /* Only used internally */
 static const struct drm_format_info gud_drm_format_r1 = {
 	.format = GUD_DRM_FORMAT_R1,
Signature · 1 line
2.45.2
author maintainer
#77 lore raw

PATCH v9 50/52 drm-dyndbg: add DRM_CLASSMAP_USE to the qxl driver

In reply to Jim Cromie

The qxl driver has a number of DRM_UT_* debugs, make them controllable when CONFIG_DRM_USE_DYNAMIC_DEBUG=y by telling dyndbg that the module uses them.

---
 drivers/gpu/drm/qxl/qxl_drv.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/gpu/drm/qxl/qxl_drv.c +2 -0
index beee5563031a..1971bfa8a8a6 100644
@@ -65,6 +65,8 @@ module_param_named(modeset, qxl_modeset, int, 0400);
 MODULE_PARM_DESC(num_heads, "Number of virtual crtcs to expose (default 4)");
 module_param_named(num_heads, qxl_num_crtc, int, 0400);
 
+DRM_CLASSMAP_USE(drm_debug_classes);
+
 static struct drm_driver qxl_driver;
 static struct pci_driver qxl_pci_driver;
 
Signature · 1 line
2.45.2
author maintainer
#78 lore raw

PATCH v9 51/52 drm-dyndbg: add DRM_CLASSMAP_USE to the drm_gem_shmem_helper driver

In reply to Jim Cromie

The drm_gem_shmem_helper driver has a number of DRM_UT_* debugs, make them controllable when CONFIG_DRM_USE_DYNAMIC_DEBUG=y by telling dyndbg that the module uses them.

---
 drivers/gpu/drm/drm_gem_shmem_helper.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/gpu/drm/drm_gem_shmem_helper.c +2 -0
index e435f986cd13..066d906e3199 100644
@@ -23,6 +23,8 @@
 #include <drm/drm_prime.h>
 #include <drm/drm_print.h>
 
+DRM_CLASSMAP_USE(drm_debug_classes);
+
 MODULE_IMPORT_NS(DMA_BUF);
 
 /**
Signature · 1 line
2.45.2
author maintainer
#79 lore raw

PATCH v9 51/53 drm-dyndbg: add DRM_CLASSMAP_USE to the qxl driver

In reply to Jim Cromie

The qxl driver has a number of DRM_UT_* debugs, make them controllable when CONFIG_DRM_USE_DYNAMIC_DEBUG=y by telling dyndbg that the module uses them.

---
 drivers/gpu/drm/qxl/qxl_drv.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/gpu/drm/qxl/qxl_drv.c +2 -0
index beee5563031a..1971bfa8a8a6 100644
@@ -65,6 +65,8 @@ module_param_named(modeset, qxl_modeset, int, 0400);
 MODULE_PARM_DESC(num_heads, "Number of virtual crtcs to expose (default 4)");
 module_param_named(num_heads, qxl_num_crtc, int, 0400);
 
+DRM_CLASSMAP_USE(drm_debug_classes);
+
 static struct drm_driver qxl_driver;
 static struct pci_driver qxl_pci_driver;
 
Signature · 1 line
2.45.2
author maintainer
#80 lore raw

PATCH v9 52/53 drm-dyndbg: add DRM_CLASSMAP_USE to the drm_gem_shmem_helper driver

In reply to Jim Cromie

The drm_gem_shmem_helper driver has a number of DRM_UT_* debugs, make them controllable when CONFIG_DRM_USE_DYNAMIC_DEBUG=y by telling dyndbg that the module uses them.

---
 drivers/gpu/drm/drm_gem_shmem_helper.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/gpu/drm/drm_gem_shmem_helper.c +2 -0
index e435f986cd13..066d906e3199 100644
@@ -23,6 +23,8 @@
 #include <drm/drm_prime.h>
 #include <drm/drm_print.h>
 
+DRM_CLASSMAP_USE(drm_debug_classes);
+
 MODULE_IMPORT_NS(DMA_BUF);
 
 /**
Signature · 1 line
2.45.2
author maintainer
#81 lore raw

PATCH v9 52/52 drm: restore CONFIG_DRM_USE_DYNAMIC_DEBUG un-BROKEN

In reply to Jim Cromie

end of official submission.

Time for some quality CI

---
 drivers/gpu/drm/Kconfig | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/gpu/drm/Kconfig +1 -2
index 5a0c476361c3..b2ea73ae48f0 100644
@@ -54,8 +54,7 @@ config DRM_DEBUG_MM
 
 config DRM_USE_DYNAMIC_DEBUG
 	bool "use dynamic debug to implement drm.debug"
-	default n
-	depends on BROKEN
+	default y
 	depends on DRM
 	depends on DYNAMIC_DEBUG || DYNAMIC_DEBUG_CORE
 	depends on JUMP_LABEL
Signature · 1 line
2.45.2
author maintainer
#82 lore raw

PATCH v9 53/53 drm: restore CONFIG_DRM_USE_DYNAMIC_DEBUG un-BROKEN

In reply to Jim Cromie

end of official submission.

Time for some quality CI

---
 drivers/gpu/drm/Kconfig | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/gpu/drm/Kconfig +1 -2
index 5a0c476361c3..b2ea73ae48f0 100644
@@ -54,8 +54,7 @@ config DRM_DEBUG_MM
 
 config DRM_USE_DYNAMIC_DEBUG
 	bool "use dynamic debug to implement drm.debug"
-	default n
-	depends on BROKEN
+	default y
 	depends on DRM
 	depends on DYNAMIC_DEBUG || DYNAMIC_DEBUG_CORE
 	depends on JUMP_LABEL
Signature · 1 line
2.45.2
maintainer
#83 lore raw
In reply to Jim Cromie
Quoted 19 lines · Jim Cromie

This fixes dynamic-debug support for DRM.debug, added via classmaps. commit bb2ff6c27bc9 (drm: Disable dynamic debug as broken)

CONFIG_DRM_USE_DYNAMIC_DEBUG=y was marked broken because drm.debug=val was applied when drm.ko was modprobed; too early for the yet-to-load drivers, which thus missed the enablement. My testing with /etc/modprobe.d/ entries and modprobes with dyndbg=$querycmd options obscured this omission.

The fix is to replace invocations of DECLARE_DYNDBG_CLASSMAP with DYNDBG_CLASSMAP_DEFINE for core, and DYNDBG_CLASSMAP_USE for drivers. The distinction allows dyndbg to also handle the users properly.

DRM is the only current classmaps user, and is not really using it, so if you think DRM could benefit from zero-off-cost debugs based on static-keys, please test.

HISTORY

Quoted 7 lines

9/4/22 - ee879be38bc8..ace7c4bbb240 commited - classmaps-v1 dyndbg parts 9/11/22 - 0406faf25fb1..16deeb8e18ca commited - classmaps-v1 drm parts

https://lore.kernel.org/lkml/[email protected]/
greg k-h says:
This should go through the drm tree now. The rest probably should also go that way and not through my tree as well.

Can't this just be defined as a coccinelle smpl patch? Must easier to read than 53 patches?

Luis

author maintainer
#84 lore raw
Quoted 24 lines · Luis Chamberlain
Quoted 22 lines · Jim Cromie

This fixes dynamic-debug support for DRM.debug, added via classmaps. commit bb2ff6c27bc9 (drm: Disable dynamic debug as broken)

CONFIG_DRM_USE_DYNAMIC_DEBUG=y was marked broken because drm.debug=val was applied when drm.ko was modprobed; too early for the yet-to-load drivers, which thus missed the enablement. My testing with /etc/modprobe.d/ entries and modprobes with dyndbg=$querycmd options obscured this omission.

The fix is to replace invocations of DECLARE_DYNDBG_CLASSMAP with DYNDBG_CLASSMAP_DEFINE for core, and DYNDBG_CLASSMAP_USE for drivers. The distinction allows dyndbg to also handle the users properly.

DRM is the only current classmaps user, and is not really using it, so if you think DRM could benefit from zero-off-cost debugs based on static-keys, please test.

HISTORY

9/4/22 - ee879be38bc8..ace7c4bbb240 commited - classmaps-v1 dyndbg parts 9/11/22 - 0406faf25fb1..16deeb8e18ca commited - classmaps-v1 drm parts

Quoted 8 lines
Quoted 4 lines

https://lore.kernel.org/lkml/[email protected]/
greg k-h says:
This should go through the drm tree now. The rest probably should also go that way and not through my tree as well.

Can't this just be defined as a coccinelle smpl patch? Must easier to read than 53 patches?

perhaps it could - Im not sure that would be easier to review than a file-scoped struct declaration or reference per driver

Also, I did it hoping to solicit more Tested-by:s with drm.debug=0x1ff

Jim

Quoted 2 lines

Luis

#85 lore raw
Quoted 35 lines · On Wed, Jul 3, 2024 at 12:14 AM <[email protected]> wrote:
Quoted 24 lines · Luis Chamberlain
Quoted 22 lines · Jim Cromie

This fixes dynamic-debug support for DRM.debug, added via classmaps. commit bb2ff6c27bc9 (drm: Disable dynamic debug as broken)

CONFIG_DRM_USE_DYNAMIC_DEBUG=y was marked broken because drm.debug=val was applied when drm.ko was modprobed; too early for the yet-to-load drivers, which thus missed the enablement. My testing with /etc/modprobe.d/ entries and modprobes with dyndbg=$querycmd options obscured this omission.

The fix is to replace invocations of DECLARE_DYNDBG_CLASSMAP with DYNDBG_CLASSMAP_DEFINE for core, and DYNDBG_CLASSMAP_USE for drivers. The distinction allows dyndbg to also handle the users properly.

DRM is the only current classmaps user, and is not really using it, so if you think DRM could benefit from zero-off-cost debugs based on static-keys, please test.

HISTORY

9/4/22 - ee879be38bc8..ace7c4bbb240 commited - classmaps-v1 dyndbg parts 9/11/22 - 0406faf25fb1..16deeb8e18ca commited - classmaps-v1 drm parts

Quoted 8 lines
Quoted 4 lines

https://lore.kernel.org/lkml/[email protected]/
greg k-h says:
This should go through the drm tree now. The rest probably should also go that way and not through my tree as well.

Can't this just be defined as a coccinelle smpl patch? Must easier to read than 53 patches?

Quoted 7 lines

perhaps it could - Im not sure that would be easier to review than a file-scoped struct declaration or reference per driver

Also, I did it hoping to solicit more Tested-by:s with drm.debug=0x1ff

Jim

Jim,

When testing different combinations of Y/M for TEST_DYNAMIC_DEBUG and TEST_DYNAMIC_DEBUG_SUBMOD in virtme-ng I spotted test failures:

When the TEST_DYNAMIC_DEBUG=M and TEST_DYNAMIC_DEBUG_SUBMOD=M - BASIC_TESTS, COMMA_TERMINATOR_TESTS, TEST_PERCENT_SPLITTING, TEST_MOD_SUBMOD selftests passed
When the TEST_DYNAMIC_DEBUG=Y and TEST_DYNAMIC_DEBUG_SUBMOD=M - BASIC_TESTS, COMMA_TERMINATOR_TESTS selftests passed, however TEST_PERCENT_SPLITTING selftest fails with ": ./dyndbg_selftest.sh:270 check failed expected 1 on =pf, got 0"
When the TEST_DYNAMIC_DEBUG=Y and TEST_DYNAMIC_DEBUG_SUBMOD=Y - BASIC_TESTS, COMMA_TERMINATOR_TESTS selftests passed, however TEST_PERCENT_SPLITTING selftest fails also with ":
./dyndbg_selftest.sh:270 check failed expected 1 on =pf, got 0"

Have I missed something ?

Thanks,
Lukasz

Quoted 2 lines
Quoted 2 lines

Luis

author maintainer
#86 lore raw
Quoted 62 lines · Łukasz Bartosik
Quoted 35 lines · On Wed, Jul 3, 2024 at 12:14 AM <[email protected]> wrote:
Quoted 24 lines · Luis Chamberlain
Quoted 22 lines · Jim Cromie

This fixes dynamic-debug support for DRM.debug, added via classmaps. commit bb2ff6c27bc9 (drm: Disable dynamic debug as broken)

CONFIG_DRM_USE_DYNAMIC_DEBUG=y was marked broken because drm.debug=val was applied when drm.ko was modprobed; too early for the yet-to-load drivers, which thus missed the enablement. My testing with /etc/modprobe.d/ entries and modprobes with dyndbg=$querycmd options obscured this omission.

The fix is to replace invocations of DECLARE_DYNDBG_CLASSMAP with DYNDBG_CLASSMAP_DEFINE for core, and DYNDBG_CLASSMAP_USE for drivers. The distinction allows dyndbg to also handle the users properly.

DRM is the only current classmaps user, and is not really using it, so if you think DRM could benefit from zero-off-cost debugs based on static-keys, please test.

HISTORY

9/4/22 - ee879be38bc8..ace7c4bbb240 commited - classmaps-v1 dyndbg parts 9/11/22 - 0406faf25fb1..16deeb8e18ca commited - classmaps-v1 drm parts

Quoted 8 lines
Quoted 4 lines

https://lore.kernel.org/lkml/[email protected]/
greg k-h says:
This should go through the drm tree now. The rest probably should also go that way and not through my tree as well.

Can't this just be defined as a coccinelle smpl patch? Must easier to read than 53 patches?

Quoted 7 lines

perhaps it could - Im not sure that would be easier to review than a file-scoped struct declaration or reference per driver

Also, I did it hoping to solicit more Tested-by:s with drm.debug=0x1ff

Jim

Jim,

When testing different combinations of Y/M for TEST_DYNAMIC_DEBUG and TEST_DYNAMIC_DEBUG_SUBMOD in virtme-ng I spotted test failures:

When the TEST_DYNAMIC_DEBUG=M and TEST_DYNAMIC_DEBUG_SUBMOD=M - BASIC_TESTS, COMMA_TERMINATOR_TESTS, TEST_PERCENT_SPLITTING, TEST_MOD_SUBMOD selftests passed
When the TEST_DYNAMIC_DEBUG=Y and TEST_DYNAMIC_DEBUG_SUBMOD=M - BASIC_TESTS, COMMA_TERMINATOR_TESTS selftests passed, however TEST_PERCENT_SPLITTING selftest fails with ": ./dyndbg_selftest.sh:270 check failed expected 1 on =pf, got 0"
When the TEST_DYNAMIC_DEBUG=Y and TEST_DYNAMIC_DEBUG_SUBMOD=Y - BASIC_TESTS, COMMA_TERMINATOR_TESTS selftests passed, however TEST_PERCENT_SPLITTING selftest fails also with ":
./dyndbg_selftest.sh:270 check failed expected 1 on =pf, got 0"

Quoted 2 lines

Have I missed something ?

I am not seeing those 2 failures on those 2 configs.

most of my recent testing has been on x86-defconfig + minimals, built and run using/inside virtme-ng

the last kernel I installed on this hw was june 16, I will repeat that, and report soon if I see the failure outside the vm

I'll also send you my script, to maybe speed isolation of the differences.

Quoted 5 lines

Thanks,
Lukasz

Quoted 2 lines
Quoted 2 lines

Luis

#87 lore raw
Quoted 69 lines · On Sat, Jul 13, 2024 at 11:45 PM <[email protected]> wrote:
Quoted 62 lines · Łukasz Bartosik
Quoted 35 lines · On Wed, Jul 3, 2024 at 12:14 AM <[email protected]> wrote:
Quoted 24 lines · Luis Chamberlain
Quoted 22 lines · Jim Cromie

This fixes dynamic-debug support for DRM.debug, added via classmaps. commit bb2ff6c27bc9 (drm: Disable dynamic debug as broken)

CONFIG_DRM_USE_DYNAMIC_DEBUG=y was marked broken because drm.debug=val was applied when drm.ko was modprobed; too early for the yet-to-load drivers, which thus missed the enablement. My testing with /etc/modprobe.d/ entries and modprobes with dyndbg=$querycmd options obscured this omission.

The fix is to replace invocations of DECLARE_DYNDBG_CLASSMAP with DYNDBG_CLASSMAP_DEFINE for core, and DYNDBG_CLASSMAP_USE for drivers. The distinction allows dyndbg to also handle the users properly.

DRM is the only current classmaps user, and is not really using it, so if you think DRM could benefit from zero-off-cost debugs based on static-keys, please test.

HISTORY

9/4/22 - ee879be38bc8..ace7c4bbb240 commited - classmaps-v1 dyndbg parts 9/11/22 - 0406faf25fb1..16deeb8e18ca commited - classmaps-v1 drm parts

Quoted 8 lines
Quoted 4 lines

https://lore.kernel.org/lkml/[email protected]/
greg k-h says:
This should go through the drm tree now. The rest probably should also go that way and not through my tree as well.

Can't this just be defined as a coccinelle smpl patch? Must easier to read than 53 patches?

Quoted 7 lines

perhaps it could - Im not sure that would be easier to review than a file-scoped struct declaration or reference per driver

Also, I did it hoping to solicit more Tested-by:s with drm.debug=0x1ff

Jim

Jim,

When testing different combinations of Y/M for TEST_DYNAMIC_DEBUG and TEST_DYNAMIC_DEBUG_SUBMOD in virtme-ng I spotted test failures:

When the TEST_DYNAMIC_DEBUG=M and TEST_DYNAMIC_DEBUG_SUBMOD=M - BASIC_TESTS, COMMA_TERMINATOR_TESTS, TEST_PERCENT_SPLITTING, TEST_MOD_SUBMOD selftests passed
When the TEST_DYNAMIC_DEBUG=Y and TEST_DYNAMIC_DEBUG_SUBMOD=M - BASIC_TESTS, COMMA_TERMINATOR_TESTS selftests passed, however TEST_PERCENT_SPLITTING selftest fails with ": ./dyndbg_selftest.sh:270 check failed expected 1 on =pf, got 0"
When the TEST_DYNAMIC_DEBUG=Y and TEST_DYNAMIC_DEBUG_SUBMOD=Y - BASIC_TESTS, COMMA_TERMINATOR_TESTS selftests passed, however TEST_PERCENT_SPLITTING selftest fails also with ":
./dyndbg_selftest.sh:270 check failed expected 1 on =pf, got 0"

Quoted 2 lines

Have I missed something ?

I am not seeing those 2 failures on those 2 configs.

Quoted 8 lines

most of my recent testing has been on x86-defconfig + minimals, built and run using/inside virtme-ng

the last kernel I installed on this hw was june 16, I will repeat that, and report soon if I see the failure outside the vm

I'll also send you my script, to maybe speed isolation of the differences.

Jim,

I know why I saw these failures.
I ran dyndbg_selftest.sh directly in thw directory tools/testing/selftests/dynamic_debug/.

All works as expected when I run it from the top kernel directory. Here are the results:

When the TEST_DYNAMIC_DEBUG=M and TEST_DYNAMIC_DEBUG_SUBMOD=M - BASIC_TESTS, COMMA_TERMINATOR_TESTS, TEST_PERCENT_SPLITTING, TEST_MOD_SUBMOD selftests passed

When the TEST_DYNAMIC_DEBUG=Y and TEST_DYNAMIC_DEBUG_SUBMOD=M - BASIC_TESTS and COMMA_TERMINATOR_TESTS selftests passed, TEST_PERCENT_SPLITTING and TEST_PERCENT_SPLITTING selftests were skipped

When the TEST_DYNAMIC_DEBUG=Y and TEST_DYNAMIC_DEBUG_SUBMOD=Y - BASIC_TESTS and COMMA_TERMINATOR_TESTS selftests passed, TEST_PERCENT_SPLITTING and TEST_PERCENT_SPLITTING selftests were skipped

Based on that maybe it would be worth it for the script to fail when it doesn't find a .config with an error message something like this:
"Kernel .config not found. Are you running the script from the kernel's top directory?"

What do you think ?

Thanks,
Lukasz

Quoted 5 lines
Quoted 5 lines

Thanks,
Lukasz

Quoted 2 lines
Quoted 2 lines

Luis

author maintainer
#88 lore raw
Quoted 77 lines · Łukasz Bartosik
Quoted 75 lines · On Sat, Jul 13, 2024 at 11:45 PM <[email protected]> wrote:
Quoted 62 lines · Łukasz Bartosik
Quoted 35 lines · On Wed, Jul 3, 2024 at 12:14 AM <[email protected]> wrote:
Quoted 24 lines · Luis Chamberlain
Quoted 22 lines · Jim Cromie

This fixes dynamic-debug support for DRM.debug, added via classmaps. commit bb2ff6c27bc9 (drm: Disable dynamic debug as broken)

CONFIG_DRM_USE_DYNAMIC_DEBUG=y was marked broken because drm.debug=val was applied when drm.ko was modprobed; too early for the yet-to-load drivers, which thus missed the enablement. My testing with /etc/modprobe.d/ entries and modprobes with dyndbg=$querycmd options obscured this omission.

The fix is to replace invocations of DECLARE_DYNDBG_CLASSMAP with DYNDBG_CLASSMAP_DEFINE for core, and DYNDBG_CLASSMAP_USE for drivers. The distinction allows dyndbg to also handle the users properly.

DRM is the only current classmaps user, and is not really using it, so if you think DRM could benefit from zero-off-cost debugs based on static-keys, please test.

HISTORY

9/4/22 - ee879be38bc8..ace7c4bbb240 commited - classmaps-v1 dyndbg parts 9/11/22 - 0406faf25fb1..16deeb8e18ca commited - classmaps-v1 drm parts

Quoted 8 lines
Quoted 4 lines

https://lore.kernel.org/lkml/[email protected]/
greg k-h says:
This should go through the drm tree now. The rest probably should also go that way and not through my tree as well.

Can't this just be defined as a coccinelle smpl patch? Must easier to read than 53 patches?

Quoted 7 lines

perhaps it could - Im not sure that would be easier to review than a file-scoped struct declaration or reference per driver

Also, I did it hoping to solicit more Tested-by:s with drm.debug=0x1ff

Jim

Jim,

When testing different combinations of Y/M for TEST_DYNAMIC_DEBUG and TEST_DYNAMIC_DEBUG_SUBMOD in virtme-ng I spotted test failures:

When the TEST_DYNAMIC_DEBUG=M and TEST_DYNAMIC_DEBUG_SUBMOD=M - BASIC_TESTS, COMMA_TERMINATOR_TESTS, TEST_PERCENT_SPLITTING, TEST_MOD_SUBMOD selftests passed
When the TEST_DYNAMIC_DEBUG=Y and TEST_DYNAMIC_DEBUG_SUBMOD=M - BASIC_TESTS, COMMA_TERMINATOR_TESTS selftests passed, however TEST_PERCENT_SPLITTING selftest fails with ": ./dyndbg_selftest.sh:270 check failed expected 1 on =pf, got 0"
When the TEST_DYNAMIC_DEBUG=Y and TEST_DYNAMIC_DEBUG_SUBMOD=Y - BASIC_TESTS, COMMA_TERMINATOR_TESTS selftests passed, however TEST_PERCENT_SPLITTING selftest fails also with ":
./dyndbg_selftest.sh:270 check failed expected 1 on =pf, got 0"

Quoted 2 lines

Have I missed something ?

I am not seeing those 2 failures on those 2 configs.

most of my recent testing has been on x86-defconfig + minimals, built and run using/inside virtme-ng

the last kernel I installed on this hw was june 16, I will repeat that, and report soon if I see the failure outside the vm

Quoted 8 lines
Quoted 2 lines

I'll also send you my script, to maybe speed isolation of the differences.

Jim,

I know why I saw these failures.
I ran dyndbg_selftest.sh directly in thw directory tools/testing/selftests/dynamic_debug/.

thats odd.
I mostly run it from src-root,
also whereever make selftest target is/works (I forgot)

I went into that subdir and ran it there
I got no test differences / failures.

IIRC, the failure was on line 270, just after a modprobe. can you further isolate it ?

Quoted 12 lines

All works as expected when I run it from the top kernel directory. Here are the results:

When the TEST_DYNAMIC_DEBUG=M and TEST_DYNAMIC_DEBUG_SUBMOD=M - BASIC_TESTS, COMMA_TERMINATOR_TESTS, TEST_PERCENT_SPLITTING, TEST_MOD_SUBMOD selftests passed

When the TEST_DYNAMIC_DEBUG=Y and TEST_DYNAMIC_DEBUG_SUBMOD=M - BASIC_TESTS and COMMA_TERMINATOR_TESTS selftests passed, TEST_PERCENT_SPLITTING and TEST_PERCENT_SPLITTING selftests were skipped

Quoted 4 lines

When the TEST_DYNAMIC_DEBUG=Y and TEST_DYNAMIC_DEBUG_SUBMOD=Y - BASIC_TESTS and COMMA_TERMINATOR_TESTS selftests passed, TEST_PERCENT_SPLITTING and TEST_PERCENT_SPLITTING selftests were skipped

thank you for running these config-combo tests.

are you doing these in a VM ?
and since Im asking, Ive done these combos on virtme-ng builds, also installed & running on 2 x86 boxen.

could you add DRM=m and a driver too,
and boot with drm.debug=0x1ff, dynamic_debug.verbose=3 the debug output should show all the class-work on modprobe, for your easy inspection/grading ;-)

Quoted 3 lines

Based on that maybe it would be worth it for the script to fail when it doesn't find a .config with an error message something like this:

if no config - they get to see more errors now.
if the solution isnt obvious to them, we can find out more ?

Quoted 4 lines

"Kernel .config not found. Are you running the script from the kernel's top directory?"

What do you think ?

the -rc0 window is open, Id rather not fiddle with this now.

Im gonna rebase onto 6.10, resend,
copy and rebase onto drm-mumble-next
then try to get into the DRM-CI river, see where that takes me.

thanks Lukas,
Jim

Quoted 9 lines

Thanks,
Lukasz

Quoted 5 lines
Quoted 5 lines

Thanks,
Lukasz

Quoted 2 lines
Quoted 2 lines

Luis

#89 lore raw
Quoted 88 lines · On Mon, Jul 15, 2024 at 8:00 PM <[email protected]> wrote:
Quoted 77 lines · Łukasz Bartosik
Quoted 75 lines · On Sat, Jul 13, 2024 at 11:45 PM <[email protected]> wrote:
Quoted 62 lines · Łukasz Bartosik
Quoted 35 lines · On Wed, Jul 3, 2024 at 12:14 AM <[email protected]> wrote:
Quoted 24 lines · Luis Chamberlain
Quoted 22 lines · Jim Cromie

This fixes dynamic-debug support for DRM.debug, added via classmaps. commit bb2ff6c27bc9 (drm: Disable dynamic debug as broken)

CONFIG_DRM_USE_DYNAMIC_DEBUG=y was marked broken because drm.debug=val was applied when drm.ko was modprobed; too early for the yet-to-load drivers, which thus missed the enablement. My testing with /etc/modprobe.d/ entries and modprobes with dyndbg=$querycmd options obscured this omission.

The fix is to replace invocations of DECLARE_DYNDBG_CLASSMAP with DYNDBG_CLASSMAP_DEFINE for core, and DYNDBG_CLASSMAP_USE for drivers. The distinction allows dyndbg to also handle the users properly.

DRM is the only current classmaps user, and is not really using it, so if you think DRM could benefit from zero-off-cost debugs based on static-keys, please test.

HISTORY

9/4/22 - ee879be38bc8..ace7c4bbb240 commited - classmaps-v1 dyndbg parts 9/11/22 - 0406faf25fb1..16deeb8e18ca commited - classmaps-v1 drm parts

Quoted 8 lines
Quoted 4 lines

https://lore.kernel.org/lkml/[email protected]/
greg k-h says:
This should go through the drm tree now. The rest probably should also go that way and not through my tree as well.

Can't this just be defined as a coccinelle smpl patch? Must easier to read than 53 patches?

Quoted 7 lines

perhaps it could - Im not sure that would be easier to review than a file-scoped struct declaration or reference per driver

Also, I did it hoping to solicit more Tested-by:s with drm.debug=0x1ff

Jim

Jim,

When testing different combinations of Y/M for TEST_DYNAMIC_DEBUG and TEST_DYNAMIC_DEBUG_SUBMOD in virtme-ng I spotted test failures:

When the TEST_DYNAMIC_DEBUG=M and TEST_DYNAMIC_DEBUG_SUBMOD=M - BASIC_TESTS, COMMA_TERMINATOR_TESTS, TEST_PERCENT_SPLITTING, TEST_MOD_SUBMOD selftests passed
When the TEST_DYNAMIC_DEBUG=Y and TEST_DYNAMIC_DEBUG_SUBMOD=M - BASIC_TESTS, COMMA_TERMINATOR_TESTS selftests passed, however TEST_PERCENT_SPLITTING selftest fails with ": ./dyndbg_selftest.sh:270 check failed expected 1 on =pf, got 0"
When the TEST_DYNAMIC_DEBUG=Y and TEST_DYNAMIC_DEBUG_SUBMOD=Y - BASIC_TESTS, COMMA_TERMINATOR_TESTS selftests passed, however TEST_PERCENT_SPLITTING selftest fails also with ":
./dyndbg_selftest.sh:270 check failed expected 1 on =pf, got 0"

Quoted 2 lines

Have I missed something ?

I am not seeing those 2 failures on those 2 configs.

most of my recent testing has been on x86-defconfig + minimals, built and run using/inside virtme-ng

the last kernel I installed on this hw was june 16, I will repeat that, and report soon if I see the failure outside the vm

Quoted 8 lines
Quoted 2 lines

I'll also send you my script, to maybe speed isolation of the differences.

Jim,

I know why I saw these failures.
I ran dyndbg_selftest.sh directly in thw directory tools/testing/selftests/dynamic_debug/.

Quoted 7 lines

thats odd.
I mostly run it from src-root,
also whereever make selftest target is/works (I forgot)

I went into that subdir and ran it there
I got no test differences / failures.

Jim,

The dyndbg_selftest.sh checks the location of kernel .config if it is configured and
if not it sets it to the current dir.

[ -f "$KCONFIG_CONFIG" ] || KCONFIG_CONFIG=".config" if [ -f "$KCONFIG_CONFIG" ]; then

If it does not find the .config it will set the variables to:

    LACK_DD_BUILTIN=0
    LACK_TMOD=0
    LACK_TMOD_SUBMOD=0

and run all selftests no matter what the values (Y/M) of TEST_DYNAMIC_DEBUG and TEST_DYNAMIC_DEBUG_SUBMOD are.

Quoted 21 lines

IIRC, the failure was on line 270, just after a modprobe. can you further isolate it ?

Quoted 12 lines

All works as expected when I run it from the top kernel directory. Here are the results:

When the TEST_DYNAMIC_DEBUG=M and TEST_DYNAMIC_DEBUG_SUBMOD=M - BASIC_TESTS, COMMA_TERMINATOR_TESTS, TEST_PERCENT_SPLITTING, TEST_MOD_SUBMOD selftests passed

When the TEST_DYNAMIC_DEBUG=Y and TEST_DYNAMIC_DEBUG_SUBMOD=M - BASIC_TESTS and COMMA_TERMINATOR_TESTS selftests passed, TEST_PERCENT_SPLITTING and TEST_PERCENT_SPLITTING selftests were skipped

Quoted 4 lines

When the TEST_DYNAMIC_DEBUG=Y and TEST_DYNAMIC_DEBUG_SUBMOD=Y - BASIC_TESTS and COMMA_TERMINATOR_TESTS selftests passed, TEST_PERCENT_SPLITTING and TEST_PERCENT_SPLITTING selftests were skipped

Quoted 6 lines

thank you for running these config-combo tests.

are you doing these in a VM ?
and since Im asking, Ive done these combos on virtme-ng builds, also installed & running on 2 x86 boxen.

Sorry I forgot to mention that I tested it using virtme-ng.

Quoted 5 lines

could you add DRM=m and a driver too,
and boot with drm.debug=0x1ff, dynamic_debug.verbose=3 the debug output should show all the class-work on modprobe, for your easy inspection/grading ;-)

I will retest with your patchset v9.

Thanks,
Lukasz

Quoted 30 lines
Quoted 3 lines

Based on that maybe it would be worth it for the script to fail when it doesn't find a .config with an error message something like this:

if no config - they get to see more errors now.
if the solution isnt obvious to them, we can find out more ?

Quoted 4 lines

"Kernel .config not found. Are you running the script from the kernel's top directory?"

What do you think ?

the -rc0 window is open, Id rather not fiddle with this now.

Im gonna rebase onto 6.10, resend,
copy and rebase onto drm-mumble-next
then try to get into the DRM-CI river, see where that takes me.

thanks Lukas,
Jim

Quoted 9 lines

Thanks,
Lukasz

Quoted 5 lines
Quoted 5 lines

Thanks,
Lukasz

Quoted 2 lines
Quoted 2 lines

Luis

#90 lore raw

✗ Fi.CI.BUILD: failure for fix CONFIG_DRM_USE_DYNAMIC_DEBUG=y

In reply to Jim Cromie
== Series Details ==

== Series Details ==

Series: fix CONFIG_DRM_USE_DYNAMIC_DEBUG=y
URL : https://patchwork.freedesktop.org/series/135705/
State : failure

== Summary ==

Error: patch https://patchwork.freedesktop.org/api/1.0/series/135705/revisions/1/mbox/ not applied
Applying: docs/dyndbg: update examples \012 to \n
Applying: test-dyndbg: fixup CLASSMAP usage error
Applying: dyndbg: reword "class unknown, " to "class:_UNKNOWN_"
Applying: dyndbg: make ddebug_class_param union members same size
Applying: dyndbg: replace classmap list with a vector
Applying: dyndbg: ddebug_apply_class_bitmap - add module arg, select on it
Applying: dyndbg: split param_set_dyndbg_classes to _module & wrapper fns
Applying: dyndbg: drop NUM_TYPE_ARRAY
Applying: dyndbg: reduce verbose/debug clutter
Applying: dyndbg: silence debugs with no-change updates
Applying: dyndbg: tighten ddebug_class_name() 1st arg type
Applying: dyndbg: tighten fn-sig of ddebug_apply_class_bitmap
Applying: dyndbg: reduce verbose=3 messages in ddebug_add_module
Applying: dyndbg-API: remove DD_CLASS_TYPE_(DISJOINT|LEVEL)_NAMES and code
Applying: dyndbg-API: fix DECLARE_DYNDBG_CLASSMAP
error: sha1 information is lacking or useless (include/linux/dynamic_debug.h).
error: could not build fake ancestor
hint: Use 'git am --show-current-patch=diff' to see the failed patch
Patch failed at 0015 dyndbg-API: fix DECLARE_DYNDBG_CLASSMAP
When you have resolved this problem, run "git am --continue".
If you prefer to skip this patch, run "git am --skip" instead.
To restore the original branch and stop patching, run "git am --abort".
Build failed, no error log produced