use DYNAMIC_DEBUG in drm/print
cover use DYNAMIC_DEBUG in drm/print
hi everyone,
this patchset reworks the drm.debug controlled debug categories, and remaps them to use dynamic_debug_exec_queries().
To do this "smoothly", DRM_UT_* is converted from an enum to a class-prefix string, which is prepended## to the real format string. This lets us use:
$> echo module drm\* format ^drm:kms: +p > /proc/dynamic_debug/control
3rd patch fixes a conflict while rebasing to rc3. I kept the fixup separate for more visibility.
commit c5261e93758a6b36f4292403027af383ec9da129
Author: Lyude Paul <[email protected]> Date: Fri Mar 26 16:37:54 2021 -0400
drm/print: Fixup DRM_DEBUG_KMS_RATELIMITED()
Since we're about to move drm_dp_helper.c over to drm_dbg_*(), we'll want to make sure that we can also add ratelimited versions of these macros in order to retain some of the previous debugging output behavior we had.
I can see I havent been paying attention.
Are plans laid out where I can catch up quickly ?
Separately, but related, I have an RFC patchset on LKML to reduce DYNAMIC_DEBUG's memory overhead. Patch 34 hints that rate-limiting can be done dynamically, on demand, for any prdbg known to dynamic_debug.
https://lore.kernel.org/lkml/[email protected]/T/#ma5052696fe9171649b93b3e1f482de90314a9b61
Jim Cromie (4):
drm: fixup comment spelling
drm: RFC add choice to use dynamic debug in drm-debug
drm: fixup DRM_DEBUG_KMS_RATELIMITED merge punt
i915: map gvt pr_debug categories to bits in parameters/debug_gvt
drivers/gpu/drm/Kconfig | 13 ++++ drivers/gpu/drm/drm_print.c | 75 ++++++++++++++++++- drivers/gpu/drm/i915/gvt/Makefile | 4 + drivers/gpu/drm/i915/i915_params.c | 76 +++++++++++++++++++ include/drm/drm_print.h | 116 ++++++++++++++++++++--------- 5 files changed, 243 insertions(+), 41 deletions(-)
Signature · 1 line
2.31.1
RFC PATCH 1/4 drm: fixup comment spelling
s/prink/printk/ - no functional changes
--- include/drm/drm_print.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
include/drm/drm_print.h +1 -1
@@ -327,7 +327,7 @@ static inline bool drm_debug_enabled(enum drm_debug_category category)/* * struct device based logging * -* Prefer drm_device based logging over device or prink based logging. +* Prefer drm_device based logging over device or printk based logging. */ __printf (3 ,4 )
Signature · 1 line
2.31.1
RFC PATCH 2/4 drm: RFC add choice to use dynamic debug in drm-debug
In reply to Jim Cromiedrm's debug system uses distinct categories of debug messages, mapped to bits in drm.debug. Currently, code does a lot of unlikely bit-mask checks on drm.debug (in drm_debug_enabled), we can use dynamic debug instead, and get all that jump_label goodness.
RFC: dynamic debug has no concept of category, but we can do without one if we can prepend a class-prefix to each printk format. Then we can use "format ^prefix" to select the whole category with one query. This is a log-facing and user visible change, but it seems unlikely to cause trouble for log watchers; they're not relying on the absence of class prefix strings.
This conversion yields ~2100 new callsites on my i7 laptop:
dyndbg: 195 debug prints in module drm_kms_helper
dyndbg: 298 debug prints in module drm
dyndbg: 1630 debug prints in module i915
CONFIG_DRM_USE_DYNAMIC_DEBUG enables this, and is available if its dependencies are enabled.
The indirection/switchover has a few parts:
1 a new callback on drm.debug which calls dynamic_debug_exec_queries
to map those bits to specific query/commands dynamic_debug_exec_queries("format ^drm:kms: +p", "drm*");
2 a "converted" or "classy" DRM_UT_* map
similar to DRM_UT_* ( symbol => bit-mask )
named it cDRM_UT_* ( symbol => format-class-prefix-string )
cDRM_UT_* is either ( CONFIG_DRM_USE_DYNAMIC_DEBUG )
legacy: cDRM_UT_* <-- DRM_UT_*
enabled:
+#define cDRM_UT_KMS "drm:kms: "
+#define cDRM_UT_PRIME "drm:prime: " +#define cDRM_UT_ATOMIC "drm:atomic: "
these are similar to "gvt: cmd:" in i915/gvt and effectively a replacement for DRM_NAME please bikeshed on keys, values. latter are log-facing.
3 drm_dev_dbg & drm_debug are renamed (prefixed with '_')
old names are now macros, which are ifdefd
legacy: -> to renamed fn
enabled: -> dev_dbg & pr_debug, after prepending prefix to format.
4 names in (2) are called from DRM_DEBUG_<Category> and drm_dbg_<Category>.
all these get "converted" to use cDRM_UT_*, to get right token type.
RFC: for dynamic debug, category is a source-facing addition; something like pr_debug_cat(cat, ...) would do it, iff cat is a compile-time const. Note that cat isn't needed in the printing, it would be saved into a new field in struct _ddebug, and used only for callsite selection, activation and control.
NOTE: conflict at KMS_RATELIMITED. I punted on proper resolution.
--- drivers/gpu/drm/Kconfig | 13 +++++ drivers/gpu/drm/drm_print.c | 75 +++++++++++++++++++++++++++-- include/drm/drm_print.h | 95 +++++++++++++++++++++++++++---------- 3 files changed, 155 insertions(+), 28 deletions(-)
drivers/gpu/drm/Kconfig +13 -0
@@ -57,6 +57,19 @@ config DRM_DEBUG_MM If in doubt, say "N". +config DRM_USE_DYNAMIC_DEBUG + bool "use dynamic debug to implement drm.debug" + default n + depends on DRM + depends on DYNAMIC_DEBUG || DYNAMIC_DEBUG_CORE + depends on JUMP_LABEL + help + The drm debug category facility does a lot of unlikely bit-field + tests at runtime; while cheap individually, the cost accumulates. + This option uses dynamic debug facility (if configured and + using jump_label) to avoid those runtime checks, patching + the kernel when those debugs are desired. + config DRM_DEBUG_SELFTEST tristate "kselftests for DRM" depends on DRM
drivers/gpu/drm/drm_print.c +71 -4
102 lines not on this page · raw message
include/drm/drm_print.h +71 -24
179 lines not on this page · raw message
Signature · 1 line
2.31.1
RFC PATCH 3/4 drm: fixup DRM_DEBUG_KMS_RATELIMITED merge punt
In reply to Jim CromieHEAD~2 punted on merging DRM_DEBUG_KMS_RATELIMITED; clean that up now, removing the extra macro indirections which support !KMS cases, since only _KMS_RATELIMITED is used. They can be re-added once needed.
conflict was here:c5261e93758a drm/print: Fixup DRM_DEBUG_KMS_RATELIMITED()
--- include/drm/drm_print.h | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-)
include/drm/drm_print.h +7 -12
@@ -571,20 +571,15 @@ void __drm_err(const char *format, ...);#define DRM_DEBUG_DP (fmt, ...) \ __drm_dbg(cDRM_UT_DP, fmt, ## __VA_ARGS__) -#define __DRM_DEFINE_DBG_RATELIMITED (category, drm, fmt, ...) \ -({ \ - static DEFINE_RATELIMIT_STATE(rs_, DEFAULT_RATELIMIT_INTERVAL, DEFAULT_RATELIMIT_BURST);\ - const struct drm_device *drm_ = (drm); \ - \ - if (drm_debug_enabled(DRM_UT_ ## category) && __ratelimit(&rs_)) \ - drm_dev_dbg(NULL, cDRM_UT_KMS, fmt, ##__VA_ARGS__); \ +#define DRM_DEBUG_KMS_RATELIMITED (fmt, ...) \ +({ \ + static DEFINE_RATELIMIT_STATE(rs_, DEFAULT_RATELIMIT_INTERVAL, \ + DEFAULT_RATELIMIT_BURST); \ + \ + if (drm_debug_enabled(DRM_UT_KMS) && __ratelimit(&rs_)) \ + __drm_dbg(cDRM_UT_KMS, fmt, ##__VA_ARGS__); \ }) -#define drm_dbg_kms_ratelimited (drm, fmt, ...) \ - __DRM_DEFINE_DBG_RATELIMITED(KMS, drm, fmt, ## __VA_ARGS__) - -#define DRM_DEBUG_KMS_RATELIMITED (fmt, ...) drm_dbg_kms_ratelimited(NULL, fmt, ## __VA_ARGS__) -/* * struct drm_device based WARNs *
Signature · 1 line
2.31.1
RFC PATCH 4/4 i915: map gvt pr_debug categories to bits in parameters/debug_gvt
In reply to Jim CromieThe gvt component of this driver has ~120 pr_debugs, in 9 "classes". Following model of drm.debug, add a parameter to map bits to these classes.
In Makefile, add DYNAMIC_DEBUG_MODULE if CONFIG_DRM_USE_DYNAMIC_DEBUG. In i915_params.c, add callback to map bits to queries.
TBD: consider moving the callback code into lib/dynamic_debug, it might make for a declarative interface, like an adorned version of:
+static char *format_prefix_classes[] = {
+ "gvt: cmd: ",
--- drivers/gpu/drm/i915/gvt/Makefile | 4 ++ drivers/gpu/drm/i915/i915_params.c | 76 ++++++++++++++++++++++++++++++ 2 files changed, 80 insertions(+)
drivers/gpu/drm/i915/gvt/Makefile +4 -0
@@ -7,3 +7,7 @@ GVT_SOURCE := gvt.o aperture_gm.o handlers.o vgpu.o trace_points.o firmware.o \ ccflags-y += -I $(srctree)/$(src) -I $(srctree)/$(src)/$(GVT_DIR)/ i915-y += $(addprefix $(GVT_DIR)/, $(GVT_SOURCE)) + +#ifdef CONFIG_DRM_USE_DYNAMIC_DEBUG +ccflags-y += -DDYNAMIC_DEBUG_MODULE +#endif
drivers/gpu/drm/i915/i915_params.c +76 -0
79 lines not on this page · raw message
Signature · 1 line
2.31.1