fix DRM_USE_DYNAMIC_DEBUG regression
Subsystems (17)
Jim Cromie
maintainerv4 cover fix DRM_USE_DYNAMIC_DEBUG regression
hi Jason, Daniel, Greg, etal
Heres another run at the regression, adequately explained in V3 here:
https://lore.kernel.org/lkml/[email protected]/
https://patchwork.freedesktop.org/series/113363/
V3 exposed an init-ordering issue with jump-label, fixed by Jason with 7deabd674988 ("dyndbg: use the module notifier callbacks")
These patches are against v6.4, they apply cleanly to drm-next-2023-07-07 Also at https://github.com/jimc/linux.git (dd-fix-2k2, dd-fix-2k-on-drm)
The bulk of the work is in the 2nd of the dyndbg-API commits, it probably requires the most scrutiny. It splits the confused double-duty job of DECLARE_DYNDBG_CLASSMAP into DYNDBG_CLASSMAP_DEFINE and DYNDBG_CLASSMAP_USE.
The other dyndbg-API patches could stand a wider review, since they make new API. Bikeshed on names, now while its easy. Fresh eyes see inconsistencies better.
I considered s/class_map/classmap/, since theres also CLASSMAP, and also PeterZ's new CLASS macros (which I should generally stay away from). Or is that just churn ? catmap ?? And maybe *param* fn-names too.
I yanked the NAME class-types, since there are no users except the test-module, we could have it back later if anyone wants it.
theres also an RFC s/__LINE__/__COUNTER__/ in __UNIQUE_ID fallback.
Jim Cromie (21):
drm: use correct ccflags-y syntax
test-dyndbg: fixup CLASSMAP usage error
dyndbg: make ddebug_class_param union members same size
dyndbg: replace classmap list with a vector
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-API: remove DD_CLASS_TYPE_(DISJOINT|LEVEL)_NAMES and code
dyndbg-API: fix DECLARE_DYNDBG_CLASSMAP & CONFIG_DRM_USE_DYNAMIC_DEBUG
dyndbg: refactor ddebug_classparam_clamp_input
dyndbg-API: promote DYNDBG_CLASSMAP_PARAM to API
dyndbg-test: make it build with just CONFIG_DYNAMIC_DEBUG_CORE
drm: restore CONFIG_DRM_USE_DYNAMIC_DEBUG un-BROKEN compiler.h: RFC - s/__LINE__/__COUNTER__/ in __UNIQUE_ID fallback
drm-drivers: DRM_CLASSMAP_USE in 2nd batch of drivers, helpers config TEST_DYNAMIC_DEBUG default m
dyndbg-doc: add classmap info to howto
.../admin-guide/dynamic-debug-howto.rst | 60 +++ 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 | 35 +- 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/udl/udl_main.c | 2 + drivers/gpu/drm/vkms/vkms_drv.c | 2 + drivers/gpu/drm/vmwgfx/vmwgfx_drv.c | 2 + include/asm-generic/vmlinux.lds.h | 1 + include/drm/drm_print.h | 12 +- include/linux/compiler.h | 4 +- include/linux/dynamic_debug.h | 112 +++-- kernel/module/main.c | 3 + lib/Kconfig.debug | 13 +- lib/Makefile | 4 +- lib/dynamic_debug.c | 399 +++++++++++------- lib/test_dynamic_debug.c | 127 +++--- lib/test_dynamic_debug_submod.c | 10 + 27 files changed, 522 insertions(+), 340 deletions(-) create mode 100644 lib/test_dynamic_debug_submod.c
Signature · 1 line
2.41.0
Jim Cromie
maintainerPATCH v4 1/21 drm: use correct ccflags-y syntax
Incorrect CFLAGS- usage failed to add -DDYNAMIC_DEBUG_MODULE, which broke builds with:
CONFIG_DRM_USE_DYNAMIC_DEBUG=yCONFIG_DYNAMIC_DEBUG_CORE=y
but without DYNAMIC_DEBUG
Nobody noticed because a larger regression emerged.
Also add subdir-ccflags so that all drivers pick up the addition.
--- drivers/gpu/drm/Makefile | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/gpu/drm/Makefile +2 -1
@@ -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.41.0
Jim Cromie
maintainerPATCH v4 2/21 test-dyndbg: fixup CLASSMAP usage error
In reply to Jim Cromiemore careful reading of test output 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
That last line is wrong, the HI class is declared.
But the enum's 1st val (explicitly initialized) was wrong; it must be _base, not _base+1 (a DECLARE_DYNDBG_CLASSMAP[1] param). So the last enumeration exceeded the range of mapped class-id's, which triggered the "class unknown" report. I intentionally coded in an error, but forgot to verify its detection and remove it.
RFC:
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 !!
* (build-bug-on tips welcome)
Those shortcomings could largely be fixed with a __stringify_list (which doesn't exist,) used in DECLARE_DYNDBG_CLASSMAP to stringify __VA_ARGS__. Then, API would accept DRM_UT_* values literally; all the categories, in order, and not their stringifications, which created all the usage complications above.
[1] name changes later to DYNDBG_CLASSMAP_DEFINE
--- lib/test_dynamic_debug.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
lib/test_dynamic_debug.c +1 -1
@@ -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.41.0
Jim Cromie
maintainerPATCH v4 3/21 dyndbg: make ddebug_class_param union members same size
In reply to Jim Cromiestruct ddebug_class_param keeps a ref to the state-storage of the param, make both flavors use the same unsigned long under-type. ISTM this is simpler and safer.
--- 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
@@ -122,7 +122,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
@@ -795,7 +795,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.41.0
Jim Cromie
maintainerPATCH v4 4/21 dyndbg: replace classmap list with a vector
In reply to Jim CromieClassmaps are stored/linked in a section/array, but are each added to the module's ddebug_table.maps list-head.
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-addy and subrange length are in the ddebug_info arg.
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-addy 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 addy,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
@@ -81,7 +81,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.41.0
Jim Cromie
maintainerPATCH v4 5/21 dyndbg: ddebug_apply_class_bitmap - add module arg, select on it
In reply to Jim CromieAdd query_module param to ddebug_apply_class_bitmap(). 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
@@ -600,7 +600,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 128char query[QUERY_SIZE ];
@@ -608,7 +609,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))
@@ -617,12 +619,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; }
@@ -678,7 +683,7 @@ static int param_set_dyndbg_classnames(const char *instr, const struct kernel_pacontinue ; } 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]);
@@ -688,7 +693,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);
@@ -751,7 +756,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 :
@@ -764,7 +769,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.41.0
Jim Cromie
maintainerPATCH v4 6/21 dyndbg: split param_set_dyndbg_classes to module/wrapper fns
In reply to Jim Cromierename param_set_dyndbg_classes: add _module_ name & arg, old name is wrapper to new. New arg allows caller to specify that only one module is affected by a prdbgs update.
Outer fn preserves kernel_param interface, passing NULL to inner fn. This selectivity will be used later to narrow the scope of changes made.
no functional change.
--- lib/dynamic_debug.c | 36 +++++++++++++++++++++--------------- 1 file changed, 21 insertions(+), 15 deletions(-)
lib/dynamic_debug.c +21 -15
@@ -707,18 +707,9 @@ static int param_set_dyndbg_classnames(const char *instr, const struct kernel_pareturn 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;
@@ -755,8 +746,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 :
@@ -769,7 +760,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 :
@@ -778,6 +769,21 @@ 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.41.0
Jim Cromie
maintainerPATCH v4 7/21 dyndbg: drop NUM_TYPE_ARRAY
In reply to Jim CromieARRAY_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
@@ -104,11 +104,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.41.0
Jim Cromie
maintainerPATCH v4 8/21 dyndbg: reduce verbose/debug clutter
In reply to Jim Cromiecurrently, 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=DRM_UT_CORE
dyndbg: no matches for query
dyndbg: no-match: func="" file="" module="" format="" lineno=0-0 class=DRM_UT_CORE
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 is like 1st, with result, not procedure. 2nd is just status, retold in 4th, with more info.
--- lib/dynamic_debug.c | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-)
lib/dynamic_debug.c +3 -11
@@ -265,9 +265,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; }
@@ -496,7 +493,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--) {
@@ -510,7 +506,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) {
@@ -526,7 +521,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 ; }
@@ -536,7 +531,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 );
@@ -554,10 +549,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.41.0
Jim Cromie
maintainerPATCH v4 9/21 dyndbg: silence debugs with no-change updates
In reply to Jim Cromiecheck for actual changes before announcing them, declutter logs.
--- lib/dynamic_debug.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-)
lib/dynamic_debug.c +7 -5
@@ -590,7 +590,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)
@@ -601,8 +601,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))
@@ -617,8 +618,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.41.0
Jim Cromie
maintainerPATCH v4 10/21 dyndbg: tighten ddebug_class_name() 1st arg type
In reply to Jim CromieChange 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
@@ -1112,12 +1112,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];
@@ -1151,7 +1151,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.41.0
Jim Cromie
maintainerPATCH v4 11/21 dyndbg: tighten fn-sig of ddebug_apply_class_bitmap
In reply to Jim Cromieold_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
@@ -592,7 +592,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
@@ -601,12 +602,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],
@@ -618,9 +619,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; }
@@ -677,7 +678,7 @@ static int param_set_dyndbg_classnames(const char *instr, const struct kernel_pacontinue ; } 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]);
@@ -687,7 +688,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);
@@ -741,7 +742,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 :
@@ -754,7 +755,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.41.0
Jim Cromie
maintainerPATCH v4 12/21 dyndbg-API: remove DD_CLASS_TYPE_(DISJOINT|LEVEL)_NAMES and code
In reply to Jim CromieRemove 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 simplify things for now.
--- include/linux/dynamic_debug.h | 19 ++----- lib/dynamic_debug.c | 104 +++------------------------------- lib/test_dynamic_debug.c | 12 ---- 3 files changed, 13 insertions(+), 122 deletions(-)
include/linux/dynamic_debug.h +4 -15
@@ -59,24 +59,13 @@ struct _ddebug {enum 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 */ };
lib/dynamic_debug.c +9 -95
127 lines not on this page · raw message
lib/test_dynamic_debug.c +0 -12
@@ -102,10 +102,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 +125,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.41.0
Jim Cromie
maintainerPATCH v4 13/21 dyndbg-API: fix DECLARE_DYNDBG_CLASSMAP & CONFIG_DRM_USE_DYNAMIC_DEBUG
In reply to Jim CromieDECLARE_DYNDBG_CLASSMAP() has a design error; it fails a basic K&R
rule: "define once, refer many times".
When DRM_USE_DYNAMIC_DEBUG=y, DECLARE_DYNDBG_CLASSMAP() is used across DRM core & drivers; they all repeat the same classmap-defn args, which must match for the modules to respond together when DRM.debug categories are enabled.
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 that make the distinction:
DYNDBG_CLASSMAP_DEFINE - invoked once from core - drm.ko
DYNDBG_CLASSMAP_USE - from all drm drivers and helpers.
DYNDBG_CLASSMAP_DEFINE: based on DECLARE_DYNDBG_CLASSMAP, but now it drops the static on the constructed classmap variable, 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_refs section this allows ddebug_add_module(etal) to handle them per-module.
The distinction, and the usage record, allows dyndbg to initialize the driver's DRM.debug callsites separately after it is modprobed.
Since DRM now needs updates to use the new macros, it also gets 2
wrappers: DRM_CLASSMAP_DEFINE, DRM_CLASSMAP_USE which declutter the users by hiding the ifdef CONFIG_DRM_USE_DYNAMIC_DEBUG.
To review, dyndbg's existing __dyndbg_classes[] section does:
. catalogs the classmaps defined by the module (or builtin modules) . authorizes dyndbg to >control those class'd prdbgs for the module. . DYNDBG_CLASSMAP_DEFINE(and old one) 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 section.
Now ddebug_add_module(etal) can handle classmap-uses like (and after) classmaps; when a dependent module is loaded, its parent's kernel params are scanned to find the param wired to dyndbg-param-ops, whose classmap matches the one ref'd by the client.
To support this, 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 new fields to encapsulate the new section:
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 changes in 2 areas: ddebug_add_module(), ddebug_change().
ddebug_add_module() previously called ddebug_attach_module_classes() to handle classmap DEFINEd by a module, now it also calls ddebug_attach_client_module_classes() to handle USEd classmaps.
ddebug_attach_client_module_classes() scans the client module's class_users section, follows the refs to the parent's classmap, and calls ddebug_apply_params() on each.
ddebug_apply_params(new fn):
It scans module's/builtin kernel-params, calls ddebug_match_attach_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 (already) 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.
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 its a one-file-module with DEBUG at the top.
If a CLASSMAP_PARAM is defined on a classmap, its readback value cannot describe the set of enablements. The param is basically write-only; it cannot know if echo $cmd >control was done since.
To know the exact pr-debug state with certainty, toggle to both:
echo 0x3ff > /sys/module/drm/parameters/debug
echo 0 > /sys/module/drm/parameters/debug
Ref: bb2ff6c27bc9 ("drm: Disable dynamic debug as broken")
--- 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_print.c | 25 ++-- drivers/gpu/drm/i915/i915_params.c | 12 +- drivers/gpu/drm/nouveau/nouveau_drm.c | 12 +- include/asm-generic/vmlinux.lds.h | 1 + include/drm/drm_print.h | 10 +- include/linux/dynamic_debug.h | 53 ++++++-- kernel/module/main.c | 3 + lib/Makefile | 2 +- lib/dynamic_debug.c | 172 ++++++++++++++++++++---- lib/test_dynamic_debug.c | 127 ++++++++++------- lib/test_dynamic_debug_submod.c | 10 ++ 14 files changed, 314 insertions(+), 149 deletions(-) create mode 100644 lib/test_dynamic_debug_submod.c
drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c +1 -11
@@ -194,17 +194,7 @@ int amdgpu_sg_display = -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),
drivers/gpu/drm/display/drm_dp_helper.c +1 -11
@@ -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;
drivers/gpu/drm/drm_crtc_helper.c +1 -11
@@ -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
drivers/gpu/drm/drm_print.c +13 -12
@@ -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,
drivers/gpu/drm/i915/i915_params.c +1 -11
@@ -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); \
drivers/gpu/drm/nouveau/nouveau_drm.c +1 -11
@@ -69,17 +69,7 @@#include "nouveau_svm.h" #include "nouveau_dmem.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;
include/asm-generic/vmlinux.lds.h +1 -0
@@ -373,6 +373,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/drm/drm_print.h +9 -1
@@ -276,7 +276,7 @@ static inline struct drm_printer drm_err_printer(const char *prefix)* */ enum drm_debug_category { -/* These names must match those in DYNAMIC_DEBUG_CLASSBITS */ +/* Keep DRM_CLASSMAP_DEFINE args in sync with any changes here */ /** * @DRM_UT_CORE: Used in the generic drm code: drm_ioctl.c, drm_mm.c, * drm_memory.c, ...
@@ -321,6 +321,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));
include/linux/dynamic_debug.h +41 -12
86 lines not on this page · raw message
kernel/module/main.c +3 -0
@@ -2213,6 +2213,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/Makefile +1 -1
@@ -79,7 +79,7 @@ obj-$(CONFIG_TEST_SORT) += test_sort.o 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) += test_dynamic_debug.o test_dynamic_debug_submod.o obj-$(CONFIG_TEST_PRINTF) += test_printf.o obj-$(CONFIG_TEST_SCANF) += test_scanf.o obj-$(CONFIG_TEST_BITMAP) += test_bitmap.o
lib/dynamic_debug.c +149 -23
273 lines not on this page · raw message
lib/test_dynamic_debug.c +82 -45
163 lines not on this page · raw message
lib/test_dynamic_debug_submod.c new file +10 -0
@@ -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.41.0
Jim Cromie
maintainerPATCH v4 14/21 dyndbg: refactor ddebug_classparam_clamp_input
In reply to Jim CromieExtract input validation code, from param_set_dyndbg_module_classes() (the sys-node >handler) to new: ddebug_classparam_clamp_input(kp), call it from former. It takes kernel-param arg, so it can complain about "foo: bad input".
Reuse ddparam_clamp_input(kp) in ddebug_sync_classbits(), to validate inputs from parent's params, just like our own. To support that reuse, alter ddebug_sync_classbits() and caller to pass kp instead of kp->arg.
--- lib/dynamic_debug.c | 66 ++++++++++++++++++++++++++++++--------------- 1 file changed, 45 insertions(+), 21 deletions(-)
lib/dynamic_debug.c +45 -21
@@ -649,6 +649,30 @@ static int ddebug_apply_class_bitmap(const struct ddebug_class_param *dcp,#define CLASSMAP_BITMASK (width) ((1UL << (width)) - 1) +static void ddebug_class_param_clamp_input (unsigned long *inrep,const struct kernel_param *kp) +{ +const struct ddebug_class_param *dcp = kp->arg; +const struct ddebug_class_map *map = dcp->map; + +switch (map->map_type) { +case DD_CLASS_TYPE_DISJOINT_BITS : +/* expect bits. mask and warn if too many */ +if (*inrep & ~CLASSMAP_BITMASK (map->length)) { +pr_warn ("%s: input: 0x%lx exceeds mask: 0x%lx, masking\n" , +KP_NAME (kp), *inrep,CLASSMAP_BITMASK (map->length)); + *inrep &=CLASSMAP_BITMASK (map->length); + } +break ; +case DD_CLASS_TYPE_LEVEL_NUM : +/* input is bitpos, of highest verbosity to be enabled */ +if (*inrep > map->length) { +pr_warn ("%s: level:%ld exceeds max:%d, clamping\n" , +KP_NAME (kp), *inrep, map->length); + *inrep = map->length; + } +break ; + } +}static int param_set_dyndbg_module_classes (const char *instr,const struct kernel_param *kp,const char *modnm)
@@ -668,26 +692,15 @@ static int param_set_dyndbg_module_classes(const char *instr,pr_err ("expecting numeric input, not: %s > %s\n" , instr,KP_NAME (kp));return -EINVAL ; } +ddebug_class_param_clamp_input (&inrep, kp);switch (map->map_type) {case DD_CLASS_TYPE_DISJOINT_BITS : -/* expect bits. mask and warn if too many */ -if (inrep & ~CLASSMAP_BITMASK (map->length)) { -pr_warn ("%s: input: 0x%lx exceeds mask: 0x%lx, masking\n" , -KP_NAME (kp), inrep,CLASSMAP_BITMASK (map->length)); - 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); *dcp->bits = inrep;break ;case DD_CLASS_TYPE_LEVEL_NUM : -/* input is bitpos, of highest verbosity to be enabled */ -if (inrep > map->length) { -pr_warn ("%s: level:%ld exceeds max:%d, clamping\n" , -KP_NAME (kp), inrep, map->length); - inrep = map->length; - } 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));
@@ -1147,16 +1160,27 @@ static const char* ddebug_classmap_typenames[] = { v2pr_info(_msg " module:%s base:%d len:%d type:%s\n", ##__VA_ARGS__, \ cm->mod_name, cm->base, cm->length, ddebug_classmap_typenames[cm->map_type]) -static void ddebug_sync_classbits (const struct ddebug_class_param *dcp,const char *modname) +static void ddebug_sync_classbits (const struct kernel_param *kp,const char *modname) { -/* clamp initial bitvec, mask off hi-bits */ -if (*dcp->bits & ~CLASSMAP_BITMASK (dcp->map->length)) { - *dcp->bits &=CLASSMAP_BITMASK (dcp->map->length); -v2pr_info ("preset classbits: %lx\n" , *dcp->bits); +struct ddebug_class_param *dcp = kp->arg; +unsigned long new_bits; + +ddebug_class_param_clamp_input (dcp->bits, kp); + +switch (dcp->map->map_type) { +case DD_CLASS_TYPE_DISJOINT_BITS : +v2pr_info ("%s: classbits: 0x%lx\n" ,KP_NAME (kp), *dcp->bits); +ddebug_apply_class_bitmap (dcp, dcp->bits,0UL , modname); +break ; +case DD_CLASS_TYPE_LEVEL_NUM : + new_bits =CLASSMAP_BITMASK (*dcp->lvl); +v2pr_info ("%s: lvl:%ld bits:0x%lx \n" ,KP_NAME (kp), *dcp->lvl, new_bits); +ddebug_apply_class_bitmap (dcp, &new_bits,0UL , modname); +break ; +default : +pr_err ("bad map type %d\n" , dcp->map->map_type); +return ; } -/* force class'd prdbgs (in USEr module) to match (DEFINEr module) class-param */ -ddebug_apply_class_bitmap (dcp, dcp->bits, ~0 , modname); -ddebug_apply_class_bitmap (dcp, dcp->bits,0 , modname); }static void ddebug_match_apply_kparam (const struct kernel_param *kp,const struct ddebug_class_map *map,const char *modnm)
@@ -1171,7 +1195,7 @@ static void ddebug_match_apply_kparam(const struct kernel_param *kp, const strucif (map == dcp->map) {v2pr_info ("found kp:%s =0x%lx" , kp->name, *dcp->bits);vpr_cm_info (map,"mapped to:" ); -ddebug_sync_classbits (dcp, modnm); +ddebug_sync_classbits (kp, modnm); } }
Signature · 1 line
2.41.0
Jim Cromie
maintainerPATCH v4 15/21 dyndbg-API: promote DYNDBG_CLASSMAP_PARAM to API
In reply to Jim Cromiemove macro from test-dynamic-debug.c into header, and refine it.
Distinguish the 2 use cases of DYNDBG_CLASSMAP_PARAM*
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/remaining.
2.DYNDBG_CLASSMAP_PARAM
new user (test_dynamic_debug) doesnt need to share state, decls,inits a static long unsigned int to store the bitvec.
__DYNDBG_CLASSMAP_PARAM
bottom layer - allocate,init a ddebug-class-param, module-param-cb.
1. doesnt initialize bits properly.
macro seems to lose type of previously decl'd extern, then whines about type mistmatch
punt now - following commit trys to fix it, draws warning.
2. init seems to work
maybe masked by sync-bits
not validated
--- drivers/gpu/drm/drm_print.c | 8 ++----- include/drm/drm_print.h | 6 ++++-- include/linux/dynamic_debug.h | 39 +++++++++++++++++++++++++++++++++-- lib/test_dynamic_debug.c | 22 +++----------------- 4 files changed, 46 insertions(+), 29 deletions(-)
drivers/gpu/drm/drm_print.c +2 -6
@@ -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, ¶m_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
@@ -322,11 +322,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)
include/linux/dynamic_debug.h +37 -2
@@ -90,7 +90,7 @@ struct ddebug_class_map {* module, and to validate inputs to DD_CLASS_TYPE_*_NAMES typed params. */ #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, \
@@ -118,7 +118,7 @@ struct ddebug_class_user { DYNDBG_CLASSMAP_USE_(_var, __UNIQUE_ID(ddebug_class_user))#define DYNDBG_CLASSMAP_USE_ (_var, _uname) \ extern struct ddebug_class_map _var; \ - struct ddebug_class_user __used \ + static struct ddebug_class_user __used \ __section("__dyndbg_class_users") _uname = { \ .user_mod_name = KBUILD_MODNAME, \ .map = &_var, \
@@ -143,6 +143,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, ¶m_ops_dyndbg_classes, \ + &_name##_##_flags, 0600) +/* * pr_debug() and friends are globally enabled or modules have selectively * enabled them.
lib/test_dynamic_debug.c +3 -19
@@ -35,22 +35,6 @@ module_param_cb(do_prints, ¶m_ops_do_prints, NULL, 0600);#define CLASSMAP_BITMASK (width, base) (((1UL << (width)) - 1) << base) -/* sysfs param wrapper, proto-API */ -#define DYNDBG_CLASSMAP_PARAM_ (_model, _flags, _init) \ - static unsigned long bits_##_model = _init; \ - static struct ddebug_class_param _flags##_##_model = { \ - .bits = &bits_##_model, \ - .flags = #_flags, \ - .map = &map_##_model, \ - }; \ - module_param_cb(_flags##_##_model, ¶m_ops_dyndbg_classes, \ - &_flags##_##_model, 0600) -#ifdef DEBUG -#define DYNDBG_CLASSMAP_PARAM (_model, _flags) DYNDBG_CLASSMAP_PARAM_(_model, _flags, ~0) -#else -#define DYNDBG_CLASSMAP_PARAM (_model, _flags) DYNDBG_CLASSMAP_PARAM_(_model, _flags, 0) -#endif -/* * Demonstrate/test all 4 class-typed classmaps with a sys-param. *
@@ -113,11 +97,11 @@ DYNDBG_CLASSMAP_DEFINE(map_level_num, DD_CLASS_TYPE_LEVEL_NUM, V0, "V0", "V1", "V2", "V3", "V4", "V5", "V6", "V7");/* -* now add the sysfs-params +* now add the sysfs-params: name, classmap, flags-toggled */ -DYNDBG_CLASSMAP_PARAM (disjoint_bits, p); -DYNDBG_CLASSMAP_PARAM (level_num, p); +DYNDBG_CLASSMAP_PARAM (p_disjoint_bits, map_disjoint_bits, p); +DYNDBG_CLASSMAP_PARAM (p_level_num, map_level_num, p);#else /* TEST_DYNAMIC_DEBUG_SUBMOD */
Signature · 1 line
2.41.0
Jim Cromie
maintainerPATCH v4 16/21 dyndbg-test: make it build with just CONFIG_DYNAMIC_DEBUG_CORE
In reply to Jim CromieTo make the 2 test modules buildable with CONFIG_DYNAMIC_DEBUG_CORE, add CFLAGS_$ofile defns to supply -DDYNAMIC_DEBUG_MODULE to cc. And change the Kconfig entry to allow building with just _CORE.
--- lib/Kconfig.debug | 10 +++++----- lib/Makefile | 2 ++ 2 files changed, 7 insertions(+), 5 deletions(-)
lib/Kconfig.debug +5 -5
@@ -2695,12 +2695,12 @@ 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 works/demo's the dyndbg's classmap API, by + creating 2 classes: a DISJOINT classmap (like DRM.debug) + and a LEVELS/VERBOSE classmap (where 2>1). If unsure, say N.
lib/Makefile +2 -0
@@ -233,6 +233,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
Signature · 1 line
2.41.0
Jim Cromie
maintainerPATCH v4 17/21 drm: restore CONFIG_DRM_USE_DYNAMIC_DEBUG un-BROKEN
In reply to Jim CromieLots of burn-in testing needed before signing, upstreaming. I set default Y to maximize testing by default.
NOTE: without __UNIQUE_ID fix in HEAD~1, this population of DRM_CLASSMAP_USE()rs experienced name collisions in several different @lkp-robot allyes and randconfigs, probably because the macro is always a file-scope declarator, and is always near the top of fhe file. Moving declarations around tended to fix one collision, only to create another collision elsewhere.
--- drivers/gpu/drm/Kconfig | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/gpu/drm/Kconfig +1 -2
@@ -52,8 +52,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.41.0
Jim Cromie
maintainerPATCH v4 18/21 compiler.h: RFC - s/__LINE__/__COUNTER__/ in __UNIQUE_ID fallback
In reply to Jim CromieWe currently have 3 defns for __UNIQUE_ID(); gcc and clang are using __COUNTER__ for real uniqueness, 3rd just uses __LINE__, which should fail on this (and harder to avoid situations):
DECLARE_FOO(); DECLARE_FOO();
Its 2023, can we haz a no-fallback __UNIQUE_ID ?
NOTE:
This also changes __UNIQUE_ID_ to _kaUID_. Ive been getting lkp-reports of collisions on names which should be unique; this shouldnt happen on gcc & clang, but does on some older ones, on some platforms, on some allyes & rand-configs. Like this:
mips64-linux-ld:
drivers/gpu/drm/display/drm_dp_helper.o:(__dyndbg_class_users+0x0):
multiple definition of `__UNIQUE_ID_ddebug_class_user405'; drivers/gpu/drm/drm_gem_shmem_helper.o:(__dyndbg_class_users+0x0):
first defined here
Like above, the collision reports appear to always be 3-digit counters, which look like line-numbers. Changing to _kaUID_ in this defn should make it more obvious (in *.i file) when a fallback has happened. To be clear, I havent seen it yet. Nor have I seen the multiple-defn problem above since adding this patch.
Lets see what lkp-robot says about this.
--- include/linux/compiler.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
include/linux/compiler.h +2 -2
@@ -177,9 +177,9 @@ void ftrace_likely_update(struct ftrace_likely_data *f, int val, __asm__ ("" : "=r" (var) : "0" (var))#endif -/* Not-quite-unique ID. */ +/* JFTI: to fix Not-quite-unique ID */ #ifndef __UNIQUE_ID -# define __UNIQUE_ID (prefix) __PASTE(__PASTE(__UNIQUE_ID_, prefix), __LINE__) +# define __UNIQUE_ID (prefix) __PASTE(__PASTE(_kaUID_, prefix), __COUNTER__)#endif /**
Signature · 1 line
2.41.0
Re: [PATCH v4 18/21] compiler.h: RFC - s/__LINE__/__COUNTER__/ in __UNIQUE_ID fallback
Hi Jim
Quoted 7 lines · Jim Cromie
We currently have 3 defns for
__UNIQUE_ID(); gcc and clang are using__COUNTER__for real uniqueness, 3rd just uses__LINE__, which should fail on this (and harder to avoid situations):DECLARE_FOO(); DECLARE_FOO();Its 2023, can we haz a no-fallback
__UNIQUE_ID?
Yeah, I fail to see how this fallback definition can actually be used after commit 95207db8166a ("Remove Intel compiler support"); even before that, it would be pretty unlikely since icc usage has not been visible for a long time. The kernel only officially supports clang or GCC now, so the definitions of __UNIQUE_ID() in include/linux/compiler-clang.h and include/linux/compiler-gcc.h should always be used because of the include in include/linux/compiler_types.h, right?
I think the correct clean up is to just hoist the definition of __UNIQUE_ID() out of the individual compiler headers into the common one here but...
Quoted 7 lines
NOTE:
This also changes
__UNIQUE_ID_to _kaUID_. Ive been getting lkp-reports of collisions on names which should be unique; this shouldnt happen on gcc & clang, but does on some older ones, on some platforms, on some allyes & rand-configs. Like this:
Quoted 5 lines
mips64-linux-ld:
drivers/gpu/drm/display/drm_dp_helper.o:(__dyndbg_class_users+0x0):
multiple definition of `__UNIQUE_ID_ddebug_class_user405'; drivers/gpu/drm/drm_gem_shmem_helper.o:(__dyndbg_class_users+0x0):
first defined here
This problem cannot be addressed with this patch given the above information, no? Seems like that might mean that __COUNTER__ has issues in earlier compilers?
Cheers,
Nathan
Quoted 39 lines
Like above, the collision reports appear to always be 3-digit counters, which look like line-numbers. Changing to _kaUID_ in this defn should make it more obvious (in *.i file) when a fallback has happened. To be clear, I havent seen it yet. Nor have I seen the multiple-defn problem above since adding this patch.
Lets see what lkp-robot says about this.
CC Luc Van Oostenryck <[email protected]> (maintainer:SPARSE CHECKER)CC Nathan Chancellor <[email protected]> (supporter:CLANG/LLVM BUILD SUPPORT)CC Nick Desaulniers <[email protected]> (supporter:CLANG/LLVM BUILD SUPPORT)CC Tom Rix <[email protected]> (reviewer:CLANG/LLVM BUILD SUPPORT)CC [email protected] (open list:SPARSE CHECKER)CC [email protected] (open list)CC [email protected] (open list:CLANG/LLVM BUILD SUPPORT)Signed-off-by Jim Cromie <[email protected]>--- include/linux/compiler.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)include/linux/compiler.h +2
-2@@ -177,9 +177,9 @@ void ftrace_likely_update(struct ftrace_likely_data *f, int val, __asm__ ("" : "=r" (var) : "0" (var))#endif -/* Not-quite-unique ID. */ +/* JFTI: to fix Not-quite-unique ID */ #ifndef __UNIQUE_ID -# define __UNIQUE_ID (prefix) __PASTE(__PASTE(__UNIQUE_ID_, prefix), __LINE__) +# define __UNIQUE_ID (prefix) __PASTE(__PASTE(_kaUID_, prefix), __COUNTER__)#endif /** Signature · 1 line
2.41.0
Jim Cromie
maintainerPATCH v4 19/21 drm-drivers: DRM_CLASSMAP_USE in 2nd batch of drivers, helpers
In reply to Jim CromieAdd a DRM_CLASSMAP_USE declaration to 2nd batch of helpers and *_drv.c files. For drivers, add the decl just above the module's PARAMs, since it identifies the "inherited" drm.debug param.
Note: with CONFIG_DRM_USE_DYNAMIC_DEBUG=y, a module not also declaring DRM_CLASSMAP_USE will have its class'd prdbgs stuck in the initial (disabled, but for DEBUG) state.
The stuck sites are evident in /proc/dynamic_debug/control as:
class unknown, _id:N # control's last column
rather than a proper "enumeration":
class:DRM_UT_CORE
This set of updates was found by choosing M for all DRM-config items I found (not allmodconfig), building & modprobing them, and grepping "class unknown," control. There may yet be others.
NOTE:
As HEAD~1 describes then hacks out, __UNIQUE_ID macro in compiler.h is still stuck using __LINE__ fallback instead of actual unique __COUNTER__.
Without HEAD~1, the placement of the DRM_CLASSMAP_USE decls was prone to this collision, as reported by @lkp-robot in several allyes configs (s390,arm-mumble) for both gcc & clang.
Moving decls around fixed each, and more popped up, it felt like whack-a-mole. Time to just test the toolchain everywhere.
--- drivers/gpu/drm/drm_gem_shmem_helper.c | 2 ++ drivers/gpu/drm/gud/gud_drv.c | 2 ++ drivers/gpu/drm/mgag200/mgag200_drv.c | 2 ++ drivers/gpu/drm/qxl/qxl_drv.c | 2 ++ drivers/gpu/drm/radeon/radeon_drv.c | 2 ++ drivers/gpu/drm/udl/udl_main.c | 2 ++ drivers/gpu/drm/vkms/vkms_drv.c | 2 ++ drivers/gpu/drm/vmwgfx/vmwgfx_drv.c | 2 ++ 8 files changed, 16 insertions(+)
drivers/gpu/drm/drm_gem_shmem_helper.c +2 -0
@@ -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 );/**
drivers/gpu/drm/gud/gud_drv.c +2 -0
@@ -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 ,
drivers/gpu/drm/mgag200/mgag200_drv.c +2 -0
@@ -24,6 +24,8 @@ 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;
drivers/gpu/drm/qxl/qxl_drv.c +2 -0
@@ -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;
drivers/gpu/drm/radeon/radeon_drv.c +2 -0
@@ -274,6 +274,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 };
drivers/gpu/drm/udl/udl_main.c +2 -0
@@ -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
drivers/gpu/drm/vkms/vkms_drv.c +2 -0
@@ -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" );
drivers/gpu/drm/vmwgfx/vmwgfx_drv.c +2 -0
@@ -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.41.0
Jim Cromie
maintainerPATCH v4 20/21 config TEST_DYNAMIC_DEBUG default m
In reply to Jim Cromie--- lib/Kconfig.debug | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
lib/Kconfig.debug +2 -1
@@ -2696,13 +2696,14 @@ config TEST_STATIC_KEYS config TEST_DYNAMIC_DEBUG tristate "Build test-dynamic-debug module" + default m depends on DYNAMIC_DEBUG || DYNAMIC_DEBUG_CORE help This module works/demo's the dyndbg's classmap API, by creating 2 classes: a DISJOINT classmap (like DRM.debug) and a LEVELS/VERBOSE classmap (where 2>1). - If unsure, say N. + If unsure, say N. If bored/curious, say M config TEST_KMOD tristate "kmod stress tester"
Signature · 1 line
2.41.0
Randy Dunlap
reviewerRe: [PATCH v4 20/21] config TEST_DYNAMIC_DEBUG default m
Hi Jim,
Quoted 10 lines · Jim Cromie
Signed-off-by Jim Cromie <[email protected]>--- lib/Kconfig.debug | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)lib/Kconfig.debug +0
-0
lib/Kconfig.debug config TEST_STATIC_KEYS · line 2699
Quoted 4 lines
lib/Kconfig.debug +1
-0@@ -2696,13 +2696,14 @@ config TEST_STATIC_KEYS config TEST_DYNAMIC_DEBUG tristate "Build test-dynamic-debug module" + default m
You need to justify such a change, and since it's not required for running the system, I don't think it should be 'm'.
Quoted 11 lines
lib/Kconfig.debug +1
-1depends on DYNAMIC_DEBUG || DYNAMIC_DEBUG_CORE help This module works/demo's the dyndbg's classmap API, by creating 2 classes: a DISJOINT classmap (like DRM.debug) and a LEVELS/VERBOSE classmap (where 2>1). - If unsure, say N. + If unsure, say N. If bored/curious, say M config TEST_KMOD tristate "kmod stress tester"
Signature · 1 line
~Randy
[email protected]
maintainerRe: [PATCH v4 20/21] config TEST_DYNAMIC_DEBUG default m
Quoted 15 lines · Randy Dunlap
Hi Jim,
Quoted 11 lines · Jim Cromie
Signed-off-by Jim Cromie <[email protected]>--- lib/Kconfig.debug | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)lib/Kconfig.debug +0
-0@@ -2696,13 +2696,14 @@ config TEST_STATIC_KEYS
Quoted 7 lines
lib/Kconfig.debug config TEST_STATIC_KEYS · line 2699
Quoted 3 lines
lib/Kconfig.debug +1
-0config TEST_DYNAMIC_DEBUG tristate "Build test-dynamic-debug module" + default mYou need to justify such a change, and since it's not required for running the system, I don't think it should be 'm'.
meh, now I cant "justify" the bored/curious comment. ;-) I'll drop this patch.
Quoted 14 lines
lib/Kconfig.debug config TEST_STATIC_KEYS · line 2709
Quoted 11 lines
lib/Kconfig.debug +1
-1depends on DYNAMIC_DEBUG || DYNAMIC_DEBUG_CORE help This module works/demo's the dyndbg's classmap API, by creating 2 classes: a DISJOINT classmap (like DRM.debug) and a LEVELS/VERBOSE classmap (where 2>1). - If unsure, say N. + If unsure, say N. If bored/curious, say M config TEST_KMOD tristate "kmod stress tester"--
~Randy
Jim Cromie
maintainerPATCH v4 21/21 dyndbg-doc: add classmap info to howto
In reply to Jim CromieAdd some basic info on classmap usage and api
--- .../admin-guide/dynamic-debug-howto.rst | 64 ++++++++++++++++++- 1 file changed, 63 insertions(+), 1 deletion(-)
Documentation/admin-guide/dynamic-debug-howto.rst +63 -1
@@ -224,7 +224,6 @@ the ``p`` flag has meaning, other flags are ignored. Note the regexp ``^[-+=][flmpt_]+$`` matches a flags specification. To clear all flags at once, use ``=_`` or ``-flmpt``. - Debug messages during Boot Process ==================================
@@ -374,3 +373,66 @@ 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 generally selects *prdbg* callsites using structural info: +module, file, function, line. Using classmaps, user modules can +organize/select pr_debug()s as they like. + +- classes coordinates/spans multiple modules +- complements the mod,file,func attrs +- keeps pr_debug's 0-off-cost JUMP_LABEL goodness +- isolates from other class'd and un-class'd pr_debugs() + (one doesnt mix 2 clients bank accounts) + + # IOW this doesn't change DRM.debug settings + #> echo -p > /proc/dynamic_debug/control + + # change the classes by naming them explicitly (no wildcard here) + #> echo class DRM_UT_CORE +p > /proc/dynamic_debug/control + +To support DRM.debug (/sys/module/drm/parameters/debug), dyndbg +provides DYNDBG_CLASSMAP_PARAM*. It maps the categories/classes: +DRM_UT_CORE.. to bits 0..N, allowing to set all classes at once. + +Dynamic Debug Classmap API +========================== + +DYNDBG_CLASSMAP_DEFINE - modules create CLASSMAPs, naming the classes +and type, and mapping the class-names to consecutive _class_ids. By +doing so, they tell dyndbg that they are using those class_ids, and +authorize dyndbg to manipulate the callsites by their class-names. + +Its expected that client modules will follow the DRM.debug model: +1. define their debug-classes using an enum type, where the enum +symbol and its integer value define both the classnames and class-ids. +2. use or macro-wrap __pr_debug_cls(ENUM_VAL, "hello world\n") + +There are 2 types of classmaps: + + DD_CLASS_TYPE_DISJOINT_BITS: classes are independent, ala DRM.debug + DD_CLASS_TYPE_LEVEL_NUM: classes are relative (Verbose3 > Verbose2) + +Both these classmap-types use the class-names/ENUM_VALs to validate +commands into >control. + +DYNDBG_CLASSMAP_PARAM - refs a DEFINEd classmap, exposing the set of +defined classes to manipulation as a group. This interface enforces +the relatedness of classes of DD_CLASS_TYPE_LEVEL_NUM typed classmaps; +all classes are independent in the >control parser itself. + +DYNDBG_CLASSMAP_USE - drm drivers use the CLASSMAP that drm DEFINEs. +This shares the classmap defn, and authorizes coordinated changes +amongst the CLASSMAP DEFINEr and multiple USErs. + +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 (__pr_debug_cls(id,fmt..)). This won't be reflected in +the PARAM readback value, but the pr_debug callsites can be toggled +into agreement with the param. +
Signature · 1 line
2.41.0
Randy Dunlap
reviewerRe: [PATCH v4 21/21] dyndbg-doc: add classmap info to howto
Quoted 19 lines · Jim Cromie
Add some basic info on classmap usage and api
Signed-off-by Jim Cromie <[email protected]>--- .../admin-guide/dynamic-debug-howto.rst | 64 ++++++++++++++++++- 1 file changed, 63 insertions(+), 1 deletion(-)Documentation/admin-guide/dynamic-debug-howto.rst +3
-0@@ -374,3 +373,66 @@ 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 +=======================
Documentation/admin-guide/dynamic-debug-howto.rst just a shortcut for ``print_hex_dump(KERN_DEBUG)``. · line 388
Quoted 10 lines
Documentation/admin-guide/dynamic-debug-howto.rst +10
-0+ +Dyndbg generally selects *prdbg* callsites using structural info: +module, file, function, line. Using classmaps, user modules can +organize/select pr_debug()s as they like. + +- classes coordinates/spans multiple modules +- complements the mod,file,func attrs +- keeps pr_debug's 0-off-cost JUMP_LABEL goodness +- isolates from other class'd and un-class'd pr_debugs() + (one doesnt mix 2 clients bank accounts)
doesn't
Quoted 17 lines
Documentation/admin-guide/dynamic-debug-howto.rst +17
-0+ + # IOW this doesn't change DRM.debug settings + #> echo -p > /proc/dynamic_debug/control + + # change the classes by naming them explicitly (no wildcard here) + #> echo class DRM_UT_CORE +p > /proc/dynamic_debug/control + +To support DRM.debug (/sys/module/drm/parameters/debug), dyndbg +provides DYNDBG_CLASSMAP_PARAM*. It maps the categories/classes: +DRM_UT_CORE.. to bits 0..N, allowing to set all classes at once. + +Dynamic Debug Classmap API +========================== + +DYNDBG_CLASSMAP_DEFINE - modules create CLASSMAPs, naming the classes +and type, and mapping the class-names to consecutive _class_ids. By +doing so, they tell dyndbg that they are using those class_ids, and
Documentation/admin-guide/dynamic-debug-howto.rst just a shortcut for ``print_hex_dump(KERN_DEBUG)``. · line 415
Quoted 10 lines
Documentation/admin-guide/dynamic-debug-howto.rst +10
-0+authorize dyndbg to manipulate the callsites by their class-names. + +Its expected that client modules will follow the DRM.debug model: +1. define their debug-classes using an enum type, where the enum +symbol and its integer value define both the classnames and class-ids. +2. use or macro-wrap __pr_debug_cls(ENUM_VAL, "hello world\n") + +There are 2 types of classmaps: + + DD_CLASS_TYPE_DISJOINT_BITS: classes are independent, ala DRM.debug
a la
or just like
Documentation/admin-guide/dynamic-debug-howto.rst just a shortcut for ``print_hex_dump(KERN_DEBUG)``. · line 421
Quoted 6 lines
Documentation/admin-guide/dynamic-debug-howto.rst +6
-0+ DD_CLASS_TYPE_LEVEL_NUM: classes are relative (Verbose3 > Verbose2) + +Both these classmap-types use the class-names/ENUM_VALs to validate +commands into >control. + +DYNDBG_CLASSMAP_PARAM - refs a DEFINEd classmap, exposing the set of
Is this: refers to a
?
Documentation/admin-guide/dynamic-debug-howto.rst just a shortcut for ``print_hex_dump(KERN_DEBUG)``. · line 427
Quoted 6 lines
Documentation/admin-guide/dynamic-debug-howto.rst +6
-0+defined classes to manipulation as a group. This interface enforces +the relatedness of classes of DD_CLASS_TYPE_LEVEL_NUM typed classmaps; +all classes are independent in the >control parser itself. + +DYNDBG_CLASSMAP_USE - drm drivers use the CLASSMAP that drm DEFINEs. +This shares the classmap defn, and authorizes coordinated changes
definition,
Documentation/admin-guide/dynamic-debug-howto.rst just a shortcut for ``print_hex_dump(KERN_DEBUG)``. · line 438
Quoted 11 lines
Documentation/admin-guide/dynamic-debug-howto.rst +11
-0+amongst the CLASSMAP DEFINEr and multiple USErs. + +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 (__pr_debug_cls(id,fmt..)). This won't be reflected in +the PARAM readback value, but the pr_debug callsites can be toggled +into agreement with the param. +
thanks.
Signature · 1 line
~Randy
[email protected]
maintainerRe: [PATCH v4 21/21] dyndbg-doc: add classmap info to howto
Quoted 27 lines · Randy Dunlap
Quoted 23 lines · Jim Cromie
Add some basic info on classmap usage and api
Signed-off-by Jim Cromie <[email protected]>--- .../admin-guide/dynamic-debug-howto.rst | 64 ++++++++++++++++++- 1 file changed, 63 insertions(+), 1 deletion(-)Documentation/admin-guide/dynamic-debug-howto.rst +7
-0@@ -374,3 +373,66 @@ 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 generally selects *prdbg* callsites using structural info: +module, file, function, line. Using classmaps, user modules can +organize/select pr_debug()s as they like.
Quoted 9 lines
Documentation/admin-guide/dynamic-debug-howto.rst just a shortcut for ``print_hex_dump(KERN_DEBUG)``. · line 388
Quoted 6 lines
Documentation/admin-guide/dynamic-debug-howto.rst +6
-0+ +- classes coordinates/spans multiple modules +- complements the mod,file,func attrs +- keeps pr_debug's 0-off-cost JUMP_LABEL goodness +- isolates from other class'd and un-class'd pr_debugs() + (one doesnt mix 2 clients bank accounts)doesn't
thanks Randy,
got this, and the rest.
Patchwork
CI[Intel-gfx] ✗ Fi.CI.CHECKPATCH: warning for fix DRM_USE_DYNAMIC_DEBUG regression (rev2)
In reply to Jim Cromie== Series Details ==
== Series Details ==
Series: fix DRM_USE_DYNAMIC_DEBUG regression (rev2)
URL : https://patchwork.freedesktop.org/series/113363/
State : warning
== Summary ==
Error: dim checkpatch failed075f00fa91b5 drm: use correct ccflags-y syntaxda5e4e98a0f2 test-dyndbg: fixup CLASSMAP usage errorbb7f9d768fa1 dyndbg: make ddebug_class_param union members same size 705c022f0043 dyndbg: replace classmap list with a vector855269370ac5 dyndbg: ddebug_apply_class_bitmap - add module arg, select on it ecd5ac2c7986 dyndbg: split param_set_dyndbg_classes to module/wrapper fns
-:68: CHECK:LINE_SPACING: Please use a blank line after function/struct/union/enum declarations #68: FILE: lib/dynamic_debug.c:772:
}
+/**
total: 0 errors, 0 warnings, 1 checks, 60 lines checkedfe3ccd116db8 dyndbg: drop NUM_TYPE_ARRAYe3b9b37549df dyndbg: reduce verbose/debug clutter
-:15: WARNING:COMMIT_LOG_LONG_LINE: Possible unwrapped commit description (prefer a maximum 75 chars per line) #15:
dyndbg: parsed: func="" file="" module="" format="" lineno=0-0 class=DRM_UT_CORE
total: 0 errors, 1 warnings, 0 checks, 50 lines checkedbed4c9cf5e20 dyndbg: silence debugs with no-change updates a799f27373c8 dyndbg: tighten ddebug_class_name() 1st arg type 086e0baab17d dyndbg: tighten fn-sig of ddebug_apply_class_bitmap 78ca67037fd9 dyndbg-API: remove DD_CLASS_TYPE_(DISJOINT|LEVEL)_NAMES and code -:157: WARNING:PREFER_FALLTHROUGH: Prefer 'fallthrough;' over fallthrough comment #157: FILE: lib/dynamic_debug.c:644:
+ /* numeric input, accept and fall-thru */
total: 0 errors, 1 warnings, 0 checks, 179 lines checkedfb5cf263531d dyndbg-API: fix DECLARE_DYNDBG_CLASSMAP & CONFIG_DRM_USE_DYNAMIC_DEBUG Traceback (most recent call last):
File "scripts/spdxcheck.py", line 6, in <module>
from ply import lex, yacc
ModuleNotFoundError: No module named 'ply'
-:71: WARNING:COMMIT_LOG_LONG_LINE: Possible unwrapped commit description (prefer a maximum 75 chars per line) #71:dynamic_debug.c has changes in 2 areas: ddebug_add_module(), ddebug_change().
-:163: ERROR:GIT_COMMIT_ID: Please use git commit description style 'commit <12+ chars of sha1> ("<title line>")' - ie: 'commit bb2ff6c27bc9 ("drm: Disable dynamic debug as broken")' #163:
Ref: bb2ff6c27bc9 ("drm: Disable dynamic debug as broken")
-:422: CHECK:LINE_SPACING: Please use a blank line after function/struct/union/enum declarations #422: FILE: include/linux/dynamic_debug.h:109:
+};
+/**
-:432: CHECK:MACRO_ARG_REUSE: Macro argument reuse '_var' - possible side-effects? #432: FILE: include/linux/dynamic_debug.h:119:
+#define DYNDBG_CLASSMAP_USE_(_var, _uname) \
+ extern struct ddebug_class_map _var; \
+ struct ddebug_class_user __used \
+ __section("__dyndbg_class_users") _uname = { \
+ .user_mod_name = KBUILD_MODNAME, \
+ .map = &_var, \
}
-:486: WARNING:AVOID_EXTERNS: externs should be avoided in .c files #486: FILE: lib/dynamic_debug.c:46:
+extern struct ddebug_class_user __start___dyndbg_class_users[];
-:487: WARNING:AVOID_EXTERNS: externs should be avoided in .c files #487: FILE: lib/dynamic_debug.c:47:
+extern struct ddebug_class_user __stop___dyndbg_class_users[];
-:504: CHECK:MACRO_ARG_REUSE: Macro argument reuse 'dt' - possible side-effects? #504: FILE: lib/dynamic_debug.c:153:
+#define vpr_dt_info(dt, _msg, ...) \
+ v2pr_info(_msg " module:%s nd:%d nc:%d nu:%d\n", ##__VA_ARGS__, \
+ dt->mod_name, dt->num_ddebugs, dt->num_classes, dt->num_class_users)
-:504: CHECK:MACRO_ARG_PRECEDENCE: Macro argument 'dt' may be better as '(dt)' to avoid precedence issues #504: FILE: lib/dynamic_debug.c:153:
+#define vpr_dt_info(dt, _msg, ...) \
+ v2pr_info(_msg " module:%s nd:%d nc:%d nu:%d\n", ##__VA_ARGS__, \
+ dt->mod_name, dt->num_ddebugs, dt->num_classes, dt->num_class_users)
-:586: WARNING:STATIC_CONST_CHAR_ARRAY: static const char * array should probably be static const char * const #586: FILE: lib/dynamic_debug.c:1142:
+static const char* ddebug_classmap_typenames[] = {
-:586: ERROR:POINTER_LOCATION: "foo* bar" should be "foo *bar" #586: FILE: lib/dynamic_debug.c:1142:
+static const char* ddebug_classmap_typenames[] = {
-:590: CHECK:MACRO_ARG_REUSE: Macro argument reuse 'cm' - possible side-effects? #590: FILE: lib/dynamic_debug.c:1146:
+#define vpr_cm_info(cm, _msg, ...) \
+ v2pr_info(_msg " module:%s base:%d len:%d type:%s\n", ##__VA_ARGS__, \
+ cm->mod_name, cm->base, cm->length, ddebug_classmap_typenames[cm->map_type])
-:590: CHECK:MACRO_ARG_PRECEDENCE: Macro argument 'cm' may be better as '(cm)' to avoid precedence issues #590: FILE: lib/dynamic_debug.c:1146:
+#define vpr_cm_info(cm, _msg, ...) \
+ v2pr_info(_msg " module:%s base:%d len:%d type:%s\n", ##__VA_ARGS__, \
+ cm->mod_name, cm->base, cm->length, ddebug_classmap_typenames[cm->map_type])
-:606: WARNING:LONG_LINE: line length of 123 exceeds 100 columns
#606: FILE: lib/dynamic_debug.c:1162:
+static void ddebug_match_apply_kparam(const struct kernel_param *kp, const struct ddebug_class_map *map, const char *modnm)
-:663: CHECK:BRACES: Blank lines aren't necessary after an open brace '{' #663: FILE: lib/dynamic_debug.c:1210:
if (!strcmp(cm->mod_name, dt->mod_name)) {
+
-:667: WARNING:BRACES: braces {} are not necessary for single statement blocks #667: FILE: lib/dynamic_debug.c:1214:
+ if (!nc++) {
dt->classes = cm;
}
-:689: WARNING:LONG_LINE: line length of 103 exceeds 100 columns
#689: FILE: lib/dynamic_debug.c:1233:
+static void ddebug_attach_client_module_classes(struct ddebug_table *dt, const struct _ddebug_info *di)
-:700: CHECK:BRACES: Blank lines aren't necessary after an open brace '{' #700: FILE: lib/dynamic_debug.c:1244:
+ for (i = 0, cli = di->class_users; i < di->num_class_users; i++, cli++) {
+
-:705: CHECK:BRACES: Blank lines aren't necessary after an open brace '{' #705: FILE: lib/dynamic_debug.c:1249:
+ if (!strcmp(cli->user_mod_name, dt->mod_name)) {
+
-:803: CHECK:MACRO_ARG_PRECEDENCE: Macro argument 'base' may be better as '(base)' to avoid precedence issues #803: FILE: lib/test_dynamic_debug.c:36:
+#define CLASSMAP_BITMASK(width, base) (((1UL << (width)) - 1) << base)
-:936: WARNING:FILE_PATH_CHANGES: added, moved or deleted file(s), does MAINTAINERS need updating? #936:
new file mode 100644
total: 2 errors, 8 warnings, 10 checks, 699 lines checkedc0a4cea422ee dyndbg: refactor ddebug_classparam_clamp_input
-:104: WARNING:QUOTED_WHITESPACE_BEFORE_NEWLINE: unnecessary whitespace before a quoted newline #104: FILE: lib/dynamic_debug.c:1177:
+ v2pr_info("%s: lvl:%ld bits:0x%lx \n", KP_NAME(kp), *dcp->lvl, new_bits);
total: 0 errors, 1 warnings, 0 checks, 100 lines checked 1a5462aee94d dyndbg-API: promote DYNDBG_CLASSMAP_PARAM to API -:15: WARNING:TYPO_SPELLING: 'doesnt' may be misspelled - perhaps 'doesn't'? #15:
new user (test_dynamic_debug) doesnt need to share state,
^^^^^^
-:21: WARNING:TYPO_SPELLING: 'doesnt' may be misspelled - perhaps 'doesn't'? #21:
1. doesnt initialize bits properly.
^^^^^^
-:24: WARNING:TYPO_SPELLING: 'trys' may be misspelled - perhaps 'tries'? #24:
punt now - following commit trys to fix it, draws warning.
^^^^
-:123: CHECK:MACRO_ARG_PRECEDENCE: Macro argument '_bits' may be better as '(_bits)' to avoid precedence issues #123: FILE: include/linux/dynamic_debug.h:172:
+#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, ¶m_ops_dyndbg_classes, \
+ &_name##_##_flags, 0600)
-:123: CHECK:MACRO_ARG_PRECEDENCE: Macro argument '_var' may be better as '(_var)' to avoid precedence issues #123: FILE: include/linux/dynamic_debug.h:172:
+#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, ¶m_ops_dyndbg_classes, \
+ &_name##_##_flags, 0600)
total: 0 errors, 3 warnings, 2 checks, 122 lines checked 7a92889fdf06 dyndbg-test: make it build with just CONFIG_DYNAMIC_DEBUG_CORE 6e79033fb669 drm: restore CONFIG_DRM_USE_DYNAMIC_DEBUG un-BROKEN 96c77b59d00c compiler.h: RFC - s/__LINE__/__COUNTER__/ in __UNIQUE_ID fallback -:19: WARNING:TYPO_SPELLING: 'shouldnt' may be misspelled - perhaps 'shouldn't'? #19:
shouldnt happen on gcc & clang, but does on some older ones, on some ^^^^^^^^
-:57: CHECK:CAMELCASE: Avoid CamelCase: <_kaUID_>
#57: FILE: include/linux/compiler.h:182:
+# define __UNIQUE_ID(prefix) __PASTE(__PASTE(_kaUID_, prefix), __COUNTER__)
total: 0 errors, 1 warnings, 1 checks, 11 lines checkeda4afa5c542bb drm-drivers: DRM_CLASSMAP_USE in 2nd batch of drivers, helpers
-:40: WARNING:BAD_REPORTED_BY_LINK: Reported-by: should be immediately followed by Closes: with a URL to the report #40:
total: 0 errors, 1 warnings, 0 checks, 64 lines checked 769d49cb902e config TEST_DYNAMIC_DEBUG default m
-:7: WARNING:COMMIT_MESSAGE: Missing commit description - Add an appropriate one
total: 0 errors, 1 warnings, 0 checks, 15 lines checked 5482eb7e68c1 dyndbg-doc: add classmap info to howto -:37: ERROR:TRAILING_WHITESPACE: trailing whitespace #37: FILE: Documentation/admin-guide/dynamic-debug-howto.rst:387:
+- isolates from other class'd and un-class'd pr_debugs() $
-:38: WARNING:TYPO_SPELLING: 'doesnt' may be misspelled - perhaps 'doesn't'? #38: FILE: Documentation/admin-guide/dynamic-debug-howto.rst:388:
+ (one doesnt mix 2 clients bank accounts)
^^^^^^
-:62: ERROR:TRAILING_WHITESPACE: trailing whitespace #62: FILE: Documentation/admin-guide/dynamic-debug-howto.rst:412:
+ $
total: 2 errors, 1 warnings, 0 checks, 73 lines checked
Patchwork
CI[Intel-gfx] ✗ Fi.CI.SPARSE: warning for fix DRM_USE_DYNAMIC_DEBUG regression (rev2)
In reply to Jim Cromie== Series Details ==
== Series Details ==
Series: fix DRM_USE_DYNAMIC_DEBUG regression (rev2)
URL : https://patchwork.freedesktop.org/series/113363/
State : warning
== Summary ==
Error: dim sparse failed
Sparse version: v0.6.2
Fast mode used, each commit won't be checked separately.