use DYNAMIC_DEBUG to implement DRM.debug & DRM.trace
Subsystems (11)
Jim Cromie
maintainerv10 cover use DYNAMIC_DEBUG to implement DRM.debug & DRM.trace
Hi Jason, Greg, DRM-everyone, everyone,
resend to add more people, after rebasing on master to pick up 306589856399 drm/print: Add deprecation notes to DRM_...() functions
This patchset has 3 separate but related parts:
1. DEFINE_DYNAMIC_DEBUG_BITGRPS macro [patch 1/10]
Declares DRM.debug style bitmap, bits control pr_debugs by matching formats Adds callback to translate bits to $cmd > dynamic_debug/control This could obsolete EXPORT(dynamic_debug_exec_queries) not included.
/* anticipated_usage */
static struct dyndbg_desc drm_categories_map[] = {
[0] = { DRM_DBG_CAT_CORE },
[1] = { DRM_DBG_CAT_DRIVER },
[2] = { DRM_DBG_CAT_KMS },
[3] = { DRM_DBG_CAT_PRIME }, ... }; DEFINE_DYNAMIC_DEBUG_BITGRPS(debug, __drm_debug,
" bits control drm.debug categories ", drm_categories_map);
Please consider this patch for -next/now/current:
- new interface, new code, no users to break
- allows DRM folks to consider in earnest.
- api bikeshedding to do ?
struct dyndbg_desc isnt that great a name, others too probably.
2. use (1) to reimplement drm.debug [patches 3-7]:
1st in amdgpu & i915 to control existing pr_debugs by their formats POC for (1)
then in drm-print, for all drm.debug API users
has kernel-footprint impact:
amdgpu has ~3k pr_debugs. (120kb callsite data) i915.ko has ~2k
avoids drm_debug_enabled(), gives NOOP savings & new flexibility. changes drm.debug categories from enum to format-prefix-string alters in-log format to include the format-prefix-string Daniel Vetter liked this at -v3
https://lore.kernel.org/lkml/YPbPvm%[email protected]/
Im sure Ive (still) missed stuff.
3. separately, Sean Paul proposed: drm.trace to mirror drm.debug to tracefs
https://patchwork.freedesktop.org/series/78133/
He argues:
tracefs is fast/lightweight compared to syslog independent selection (of drm categories) to tracefs
gives tailored traffic w.o flooding syslog
ISTM he's correct. So it follows that write-to-tracefs is also a good feature for dyndbg, where its then available for all pr_debug users, including all of drm, on a per-site basis, via echo +T >control. (iff CONFIG_TRACING).
So basically, I borg'd his:
[patch 14/14] drm/print: Add tracefs support to the drm logging helpers
Then I added a T flag, so it can be toggled from shell:
# turn on all drm's pr_debug --> tracefs echo module drm +T > /proc/dynamic_debug/control
It appears to just work: (RFC)
The instance name is a placeholder, per-module subdirs kinda fits the tracefs pattern, but full mod/file-basename/function/line feels like overkill, mod/basename-func.line would flatten it nicely. RFC.
[root@gandalf dyndbg-tracefs]# pwd /sys/kernel/tracing/instances/dyndbg-tracefs
[root@gandalf dyndbg-tracefs]# echo 1 > /sys/module/drm/parameters/trace [root@gandalf dyndbg-tracefs]# head -n16 trace | sed -e 's/^#//'
tracer: nop
entries-in-buffer/entries-written: 405/405 #P:24
_-----=> irqs-off
/ _----=> need-resched
| / _---=> hardirq/softirq
|| / _--=> preempt-depth
||| / _-=> migrate-disable
|||| / delay
TASK-PID CPU# ||||| TIMESTAMP FUNCTION
| | | ||||| | |
<...>-2254 [000] ..... 7040.894352: __dynamic_pr_debug: drm:core: comm="gnome-shel:cs0" pid=2254, dev=0xe200, auth=1, AMDGPU_CS
<...>-2207 [015] ..... 7040.894654: __dynamic_pr_debug: drm:core: comm="gnome-shell" pid=2207, dev=0xe200, auth=1, DRM_IOCTL_MODE_ADDFB2
<...>-2207 [015] ..... 7040.995403: __dynamic_pr_debug: drm:core: comm="gnome-shell" pid=2207, dev=0xe200, auth=1, DRM_IOCTL_MODE_RMFB
<...>-2207 [015] ..... 7040.995413: __dynamic_pr_debug: drm:core: OBJ ID: 121 (2)This is the pr-debug doing most of that logging: (from dynamic_debug/control)
drivers/gpu/drm/drm_ioctl.c:866 [drm]drm_ioctl =T "drm:core: comm=\042%s\042 pid=%d, dev=0x%lx, auth=%d, %s\012"
Turning on decoration flags changes the trace:
echo module drm format drm:core: +mflt > /proc/dynamic_debug/control
TASK-PID CPU# ||||| TIMESTAMP FUNCTION
| | | ||||| | |
<...>-2254 [003] ..... 15980.936660: __dynamic_pr_debug: [2254] drm:drm_ioctl:866: drm:core: comm="gnome-shel:cs0" pid=2254, dev=0xe200, auth=1, AMDGPU_CS
<...>-2207 [015] ..... 15980.936966: __dynamic_pr_debug: [2207] drm:drm_ioctl:866: drm:core: comm="gnome-shell" pid=2207, dev=0xe200, auth=1, DRM_IOCTL_MODE_ADDFB2
<...>-2207 [015] ..... 15981.037727: __dynamic_pr_debug: [2207] drm:drm_ioctl:866: drm:core: comm="gnome-shell" pid=2207, dev=0xe200, auth=1, DRM_IOCTL_MODE_RMFB
<...>-2207 [015] ..... 15981.037739: __dynamic_pr_debug: [2207] drm:drm_mode_object_put:195: drm:core: OBJ ID: 124 (2)
<...>-2207 [015] ..... 15981.037742: __dynamic_pr_debug: [2207] drm:drm_mode_object_put:195: drm:core: OBJ ID: 124 (1)The FUNCTION could stand tweaking (to match the callsite in the control file, cited above), or perhaps replaced by the 'mfl' decorations; the 't' flag is redundant for trace. Meh.
SELFTEST
A previous version of this patchset added test_dynamic_debug.ko, but it relied upon code I ripped out when I made tracefs available by default (without modules having to register 1st). So it fails 10/29 tests, which counted +T sites executed, via side effect.
TODO: userspace selftest
# to set expected tracing activity echo module test_dynamic_debug function do_debugging +T > control
# run do_debugging function (todo: add sysfs knob) echo 2 > /sys/module/test-dynamic-debug/parameters/run_me
If thats wrapped in the right trace_on, trace_pipe, etc incantations, the +T enabled pr_debugs in do_debugging() can be counted, compared against expectations, and passed or failed.
change since v9:
. patch confict against drm-misc resolved
. s/CATEGORIES/BITGRPS/ in 1/10 - keep name generic: bitmap + groups . CATEGORIES is drm term, use it there only
. fix api friction wrt drm.trace knob
2 separate macros: DEFINE_DYNAMIC_DEBUG_{LOG,TRACE}_GROUPS - JBaron
v9: https://patchwork.freedesktop.org/series/96327/
v8: https://patchwork.freedesktop.org/series/93914/
https://lore.kernel.org/lkml/[email protected]/
The major change since v8 is that +T now works for all users, if CONFIG_TRACING=y, otherwise it complains/errors.
SUMMARY
- drm as dyndbg user adds almost 9k callsites to kernel running this patchset substantial footprint
substantial source of pr-debug-trace events (not all, but some useful)
[jimc@gandalf wk-next]$ wc /proc/dynamic_debug/control
8927 71062 1099699 /proc/dynamic_debug/control
[jimc@gandalf wk-next]$ uname -a
Linux gandalf 5.15.0-rh2-12144-g5d5db04dfb0c #3 SMP PREEMPT Thu Nov 11 10:5
- pr_debug as event provider
using exported trace_array_printk
cheap with JUMP_LABEL
precise, ad-hoc or organized callsite enablement callsite descriptor is in its interface, so are VARARGS inspectable, extensible wo api churn,
iff trace_array_printk can do it.
Jim Cromie (10):
dyndbg: add DEFINE_DYNAMIC_DEBUG_BITGRPS macro and callbacks
drm: fix doc grammar
amdgpu: use dyndbg.BITGRPS to control existing pr_debugs i915/gvt: trim spaces from pr_debug "gvt: core:" prefixes i915/gvt: use dyndbg.BITGRPS for existing pr_debugs
drm_print: add choice to use dynamic debug in drm-debug
drm_print: instrument drm_debug_enabled
dyndbg: add print-to-tracefs, selftest with it - RFC
dyndbg: create DEFINE_DYNAMIC_DEBUG_LOG|TRACE_GROUPS
drm: use DEFINE_DYNAMIC_DEBUG_TRACE_GROUPS in 3 places
.../admin-guide/dynamic-debug-howto.rst | 7 +- MAINTAINERS | 1 + drivers/gpu/drm/Kconfig | 26 ++ drivers/gpu/drm/Makefile | 2 + drivers/gpu/drm/amd/amdgpu/Makefile | 2 + .../gpu/drm/amd/display/dc/core/dc_debug.c | 55 ++++- drivers/gpu/drm/drm_print.c | 62 +++-- drivers/gpu/drm/i915/Makefile | 2 + drivers/gpu/drm/i915/gvt/debug.h | 18 +- drivers/gpu/drm/i915/intel_gvt.c | 47 ++++ include/drm/drm_drv.h | 2 +- include/drm/drm_print.h | 182 +++++++++++--- include/linux/dynamic_debug.h | 88 ++++++- lib/Kconfig.debug | 11 + lib/Makefile | 1 + lib/dynamic_debug.c | 203 ++++++++++++++-- lib/test_dynamic_debug.c | 222 ++++++++++++++++++ 17 files changed, 843 insertions(+), 88 deletions(-) create mode 100644 lib/test_dynamic_debug.c
Signature · 1 line
2.31.1
Jim Cromie
maintainerPATCH v10 1/10 dyndbg: add DEFINE_DYNAMIC_DEBUG_BITGRPS macro and callbacks
DEFINE_DYNAMIC_DEBUG_BITGRPS(fsname, var, bitmap_desc, bitmap) allows users to create a drm.debug style (bitmap) sysfs interface, mapping each bit to a group of pr_debugs, matching on their formats.
This works well when the formats systematically include a prefix string such as ERR|WARN|INFO, etc.
Such groups can (already) be manipulated like so:
echo "format $prefix +p" >control
This macro merely makes it easier to operate them as groups
/* standard usage */
static struct dyndbg_bitdesc my_bitmap[] = {
[0] = { "gvt:cmd:" },
[1] = { "gvt:core:" },
[2] = { "gvt:dpy:" },
[3] = { "gvt:el:" },
[4] = { "gvt:irq:" },
[5] = { "gvt:mm:" },
[6] = { "gvt:mmio:" },
[7] = { "gvt:render:" },
[8] = { "gvt:sched:" }
};
DEFINE_DYNAMIC_DEBUG_BITGRPS(debug_gvt, __gvt_debug,
"i915/gvt bitmap desc", my_bitmap);In addition to the macro, patch adds:
- int param_set_dyndbg()
- int param_get_dyndbg()
- struct kernel_param_ops param_ops_dyndbg
Following the model of kernel/params.c STANDARD_PARAM_DEFS, these are non-static and exported.
get/set use an augmented kernel_param; the arg refs a new struct dyndbg_bitmap_param containing:
A- the map of "categories", an array of struct dyndbg_bitdescs,
indexed by bitpos, defining the match against pr_debug formats.
B- a pointer to the user module's ulong holding the bits/state.
By sharing state, we coordinate with code that still uses it directly. This allows drm-debug api to be converted incrementally, while still using __drm_debug & drm_debug_enabled() in other parts.
param_set_dyndbg() compares new vs old bits, and only updates prdbgs on changes. This maximally preserves the underlying state, which may have been customized via later echo $cmd >control. So if a user really wants to know that all prdbgs are set precisely, they must pre-clear then set.
dynamic_debug.h:
Add DEFINE_DYNAMIC_DEBUG_BITGRPS() described above, and a stub throwing a BUILD_BUG (RFC) when used without DYNAMIC_DEBUG support.
Add structs dyndbg_bitdesc, dyndbg_bitmap_param to support the main macro, and several helper macros wrapping the given categories with ^prefix and ' ' suffix. This way the callback can be more broadly used, by using the right helper macro.
Also externs the struct kernel_param param_ops_dyndbg symbol, as is done in moduleparams.h for all the STANDARD params.
USAGE NOTES:
Using dyndbg to query on "format $str" requires that $str must be present in the compiled-in format string. Searching on "%s" does not define a useful set of callsites.
Using DEFINE_DYNAMIC_DEBUG_CATEGORIES wo support gets a BUILD_BUG. ISTM there is already action at a declarative distance, nobody needs mystery as to why the /sysfs thingy didn't appear.
Dyndbg is agnostic wrt the categorization scheme used, in order to play well with any prefix convention already in use in the codebase. In fact, "prefix" is not strictly accurate without ^ anchor.
Ad-hoc categories and sub-categories are implicitly allowed, author discipline and review is expected.
Hierarchical classes/categories are natural:
"^drm:<CAT>:" is used in a later commit
"^drm:<CAT>:<SUB>:" is a natural extension.
"^drm:atomic:fail:" has been proposed, sounds directly useful
RFC: in a real sense we abandon enum strictures here, and lose some compiler help, on spelling errs for example. Obviously "drm:" != "DRM:".
Some properties of a hierarchical category deserve explication:
Trailing spaces matter !
With 1..3-space ("drm: ", "drm:atomic: ", "drm:atomic:fail: "), the ":" doesn't terminate the search-space, the trailing space does. So a "drm:" search spec will match all DRM categories & subcategories, and will not be useful in an interface where all categories are already controlled together. That said, "drm:atomic:" & "drm:atomic: " are different, and both are useful in cases.
Ad-Hoc categories & sub-categories:
Ad-hoc categories are those format-prefixes already in use; both amdgpu and i915 have numerous (120,~1800) pr_debugs, most of these use a system, a small set (9,13) of prefixes, to categorize the output. Dyndbg already works on these, this patch just allows adding a new bitmap knob to control them.
Ad-hoc sub-categories are slightly trickier.
since drm_dbg_atomic("fail: ...") is a macro:
pr_debug("drm:atomic:" " " format,...) // cpp-paste in a trailing space
We get "drm:atomic: fail:", with that undesirable embedded space; obviously not ideal wrt clear and simple prefixes.
a possible fix: drm_dbg_atomic_("fail: ..."); // trailing _ for ad-hoc subcat
Summarizing:
- "drm:kms: " & "drm:kms:" are different
- "drm:kms" also different - includes drm:kms2:
- "drm:kms:\t" also different - could be troublesome
- "drm:kms:*" doesn't work, no wildcard on format atm.
Order matters in DEFINE_DYNAMIC_DEBUG_CATEGORIES(... @bit_descs)
Since bits are/will-stay applied 0-N, the later bits can countermand the earlier ones, but it is tricky - consider;
DD_CATs(... "drm:atomic:", "drm:atomic:fail:" ) // misleading
The 1st search-term is misleading, because it includes (modifies) subcategories, but then 2nd overrides it. So don't do that.
---
vlatest:
. change /CATEGORIES/BITGRP/, leave former for app use
--- include/linux/dynamic_debug.h | 54 +++++++++++++++++++++++++ lib/dynamic_debug.c | 76 +++++++++++++++++++++++++++++++++++ 2 files changed, 130 insertions(+)
include/linux/dynamic_debug.h +54 -0
@@ -181,6 +181,10 @@ void __dynamic_ibdev_dbg(struct _ddebug *descriptor, KERN_DEBUG, prefix_str, prefix_type, \ rowsize, groupsize, buf, len, ascii) +struct kernel_param ; +int param_set_dyndbg (const char *instr,const struct kernel_param *kp); +int param_get_dyndbg (char *buffer,const struct kernel_param *kp); +#else /* !CONFIG_DYNAMIC_DEBUG_CORE */ #include <linux/string.h>
@@ -227,6 +231,56 @@ static inline int dynamic_debug_exec_queries(const char *query, const char *modnreturn 0 ; } +struct kernel_param ; +static inline int param_set_dyndbg (const char *instr,const struct kernel_param *kp) +{return 0 ; } +static inline int param_get_dyndbg (char *buffer,const struct kernel_param *kp) +{return 0 ; } +#endif /* !CONFIG_DYNAMIC_DEBUG_CORE */ +struct dyndbg_bitdesc { +const char *match;/* search format for this substr */ +}; + +struct dyndbg_bitmap_param { +unsigned long *bits;/* ref to shared state */ +unsigned int maplen; +struct dyndbg_bitdesc *map;/* indexed by bitpos */ +}; + +#if defined(CONFIG_DYNAMIC_DEBUG ) || \ + (defined(CONFIG_DYNAMIC_DEBUG_CORE ) && defined(DYNAMIC_DEBUG_MODULE )) +/** +* DEFINE_DYNAMIC_DEBUG_BITGRPS() - bitmap control of pr_debugs, by format match +* @fsname: parameter basename under /sys +* @_var: C-identifier holding bitmap +* @desc: string summarizing the controls provided +* @bitmap: C array of struct dyndbg_bitdescs +* +* Intended for modules with a systematic use of pr_debug prefixes in +* the format strings, this allows modules calling pr_debugs to +* control them in groups by matching against their formats, and map +* them to bits 0-N of a sysfs control point. +*/ +#define DEFINE_DYNAMIC_DEBUG_BITGRPS (fsname, _var, desc, data) \ + MODULE_PARM_DESC(fsname, desc); \ + static struct dyndbg_bitmap_param ddcats_##_var = \ + { .bits = &(_var), .map = data, \ + .maplen = ARRAY_SIZE(data) }; \ + module_param_cb(fsname, ¶m_ops_dyndbg, &ddcats_##_var, 0644) + +extern const struct kernel_param_ops param_ops_dyndbg; + +#else /* no dyndbg configured, throw error on macro use */ + +#if (defined(CONFIG_DYNAMIC_DEBUG_CORE ) && !defined(DYNAMIC_DEBUG_MODULE )) +#define DEFINE_DYNAMIC_DEBUG_BITGRPS (fsname, var, bitmap_desc, ...) \ + BUILD_BUG_ON_MSG(1, "you need -DDYNAMIC_DEBUG_MODULE in compile") +#else +#define DEFINE_DYNAMIC_DEBUG_BITGRPS (fsname, var, bitmap_desc, ...) \ + BUILD_BUG_ON_MSG(1, "CONFIG_DYNAMIC_DEBUG needed to use this macro: " #var) +#endif +#endif +#endif
lib/dynamic_debug.c +76 -0
82 lines not on this page · raw message
Signature · 1 line
2.31.1
Jim Cromie
maintainerPATCH v10 2/10 drm: fix doc grammar
In reply to Jim Cromieallocates and initializes ...
--- include/drm/drm_drv.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
include/drm/drm_drv.h +1 -1
@@ -486,7 +486,7 @@ void *__devm_drm_dev_alloc(struct device *parent,* @type: the type of the struct which contains struct &drm_device * @member: the name of the &drm_device within @type. * -* This allocates and initialize a new DRM device. No device registration is done. +* This allocates and initializes a new DRM device. No device registration is done. * Call drm_dev_register() to advertice the device to user space and register it * with other core subsystems. This should be done last in the device * initialization sequence to make sure userspace can't access an inconsistent
Signature · 1 line
2.31.1
Jim Cromie
maintainerPATCH v10 3/10 amdgpu: use dyndbg.BITGRPS to control existing pr_debugs
In reply to Jim Cromielogger_types.h defines many DC_LOG_*() categorized debug wrappers. Most of these already use DRM debug API, so are controllable using drm.debug, but others use a bare pr_debug("$prefix: .."), with 1 of 13 different class-prefixes matching [:uppercase:]
Use DEFINE_DYNAMIC_DEBUG_BITGRPS to create a sysfs location which maps from bits to these 13 sets of categorized pr_debugs to en/disable.
Makefile adds -DDYNAMIC_DEBUG_MODULE for CONFIG_DYNAMIC_DEBUG_CORE, otherwise BUILD_BUG_ON triggers (obvious errors on subtle misuse is better than mysterious ones).
--- drivers/gpu/drm/amd/amdgpu/Makefile | 2 + .../gpu/drm/amd/display/dc/core/dc_debug.c | 47 ++++++++++++++++++- 2 files changed, 48 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/Makefile +2 -0
@@ -38,6 +38,8 @@ ccflags-y := -I$(FULL_AMD_PATH)/include/asic_reg \ -I$(FULL_AMD_DISPLAY_PATH)/amdgpu_dm \ -I$(FULL_AMD_PATH)/amdkfd +ccflags-$(CONFIG_DYNAMIC_DEBUG_CORE) += -DYNAMIC_DEBUG_MODULE + amdgpu-y := amdgpu_drv.o # add KMS driver
drivers/gpu/drm/amd/display/dc/core/dc_debug.c +46 -1
54 lines not on this page · raw message
Signature · 1 line
2.31.1
Jim Cromie
maintainerPATCH v10 4/10 i915/gvt: trim spaces from pr_debug "gvt: core:" prefixes
In reply to Jim CromieTaking embedded spaces out of existing prefixes makes them more easily searchable; simplifying the extra quoting needed otherwise:
$> echo format "^gvt: core:" +p >control
Dropping the internal spaces means any trailing space in a query will more clearly terminate the prefix being searched for.
Consider a generic drm-debug example:
# turn off ATOMIC reports echo format "^drm:atomic: " -p > control
# turn off all ATOMIC:* reports, including any sub-categories echo format "^drm:atomic:" -p > control
# turn on ATOMIC:FAIL: reports echo format "^drm:atomic:fail: " +p > control
Removing embedded spaces in the format prefixes simplifies the corresponding match string. This means that "quoted" match-prefixes are only needed when the trailing space is desired, in order to exclude explicitly sub-categorized pr-debugs; in this example, "drm:atomic:fail:".
--- drivers/gpu/drm/i915/gvt/debug.h | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-)
drivers/gpu/drm/i915/gvt/debug.h +9 -9
@@ -36,30 +36,30 @@ do { \ } while (0) #define gvt_dbg_core(fmt, args...) \ - pr_debug("gvt: core: "fmt, ##args) + pr_debug("gvt:core: " fmt, ##args) #define gvt_dbg_irq(fmt, args...) \ - pr_debug("gvt: irq: "fmt, ##args) + pr_debug("gvt:irq: " fmt, ##args) #define gvt_dbg_mm(fmt, args...) \ - pr_debug("gvt: mm: "fmt, ##args) + pr_debug("gvt:mm: " fmt, ##args) #define gvt_dbg_mmio(fmt, args...) \ - pr_debug("gvt: mmio: "fmt, ##args) + pr_debug("gvt:mmio: " fmt, ##args) #define gvt_dbg_dpy(fmt, args...) \ - pr_debug("gvt: dpy: "fmt, ##args) + pr_debug("gvt:dpy: " fmt, ##args) #define gvt_dbg_el(fmt, args...) \ - pr_debug("gvt: el: "fmt, ##args) + pr_debug("gvt:el: " fmt, ##args) #define gvt_dbg_sched(fmt, args...) \ - pr_debug("gvt: sched: "fmt, ##args) + pr_debug("gvt:sched: " fmt, ##args) #define gvt_dbg_render(fmt, args...) \ - pr_debug("gvt: render: "fmt, ##args) + pr_debug("gvt:render: " fmt, ##args) #define gvt_dbg_cmd(fmt, args...) \ - pr_debug("gvt: cmd: "fmt, ##args) + pr_debug("gvt:cmd: " fmt, ##args)#endif
Signature · 1 line
2.31.1
Jim Cromie
maintainerPATCH v10 5/10 i915/gvt: use dyndbg.BITGRPS for existing pr_debugs
In reply to Jim CromieThe gvt component of this driver has ~120 pr_debugs with formats using one of 9 fixed string prefixes, which are quite similar to those enumerated in DRM debug categories. Following the interface model of drm.debug, add a parameter to map bits to these format prefixes.
static struct dyndbg_bitdesc i915_bitmap[] = {
[0] = { "gvt:cmd:" },
[1] = { "gvt:core:" },
[2] = { "gvt:dpy:" },
[3] = { "gvt:el:" },
[4] = { "gvt:irq:" },
[5] = { "gvt:mm:" },
[6] = { "gvt:mmio:" },
[7] = { "gvt:render:" },
[8] = { "gvt:sched:" }
};DEFINE_DYNAMIC_DEBUG_BITGRPS(debug_gvt, __gvt_debug,
"dyndbg bitmap desc",
If CONFIG_DYNAMIC_DEBUG_CORE=y, then gvt/Makefile adds -DDYNAMIC_DEBUG_MODULE to cflags, which CONFIG_DYNAMIC_DEBUG=n (CORE-only) builds need. This is redone more comprehensively soon.
--- drivers/gpu/drm/i915/Makefile | 2 ++ drivers/gpu/drm/i915/intel_gvt.c | 38 ++++++++++++++++++++++++++++++++ 2 files changed, 40 insertions(+)
drivers/gpu/drm/i915/Makefile +2 -0
@@ -317,6 +317,8 @@ i915-y += intel_gvt.o include $(src)/gvt/Makefile endif +ccflags-$(CONFIG_DYNAMIC_DEBUG_CORE) += -DDYNAMIC_DEBUG_MODULE + obj-$(CONFIG_DRM_I915) += i915.o obj-$(CONFIG_DRM_I915_GVT_KVMGT) += gvt/kvmgt.o
drivers/gpu/drm/i915/intel_gvt.c +38 -0
@@ -162,3 +162,41 @@ void intel_gvt_resume(struct drm_i915_private *dev_priv)if (intel_gvt_active (dev_priv))intel_gvt_pm_resume (dev_priv->gvt); } + +#if defined(CONFIG_DRM_USE_DYNAMIC_DEBUG ) + +unsigned long __gvt_debug; +EXPORT_SYMBOL (__gvt_debug); + +static struct dyndbg_bitdesc i915_dyndbg_bitmap[] = { + [0 ] = {"gvt:cmd:" }, + [1 ] = {"gvt:core:" }, + [2 ] = {"gvt:dpy:" }, + [3 ] = {"gvt:el:" }, + [4 ] = {"gvt:irq:" }, + [5 ] = {"gvt:mm:" }, + [6 ] = {"gvt:mmio:" }, + [7 ] = {"gvt:render:" }, + [8 ] = {"gvt:sched:" } +}; + +#define help_ (_N, _cat) "\t Bit-" #_N ":\t" _cat "\n" + +#define I915_GVT_CATEGORIES (name) \ + " Enable debug output via /sys/module/i915/parameters/" #name \ + ", where each bit enables a debug category.\n" \ + help_(0, "gvt:cmd:") \ + help_(1, "gvt:core:") \ + help_(2, "gvt:dpy:") \ + help_(3, "gvt:el:") \ + help_(4, "gvt:irq:") \ + help_(5, "gvt:mm:") \ + help_(6, "gvt:mmio:") \ + help_(7, "gvt:render:") \ + help_(8, "gvt:sched:") + +DEFINE_DYNAMIC_DEBUG_BITGRPS (debug_gvt, __gvt_debug, +I915_GVT_CATEGORIES (debug_gvt), + i915_dyndbg_bitmap); + +#endif
Signature · 1 line
2.31.1
Jim Cromie
maintainerPATCH v10 6/10 drm_print: add choice to use dynamic debug in drm-debug
In reply to Jim Cromiedrm's debug system writes 10 distinct categories of messages to syslog using a small API[1]: drm_dbg*(10 names), DRM_DEV_DEBUG*(3 names), DRM_DEBUG*(8 names). There are thousands of these callsites, each categorized in this systematized way.
These callsites can be enabled at runtime by their category, each controlled by a bit in drm.debug (/sys/modules/drm/parameter/debug). In the current "basic" implementation, drm_debug_enabled() tests these bits in __drm_debug each time an API[1] call is executed; while cheap individually, the costs accumulate with uptime.
This patch uses dynamic-debug with (required) jump-label to patch enabled callsites onto their respective NOOP slots, avoiding all runtime bit-checks of __drm_debug by drm_debug_enabled().
Dynamic debug has no concept of category, but we can emulate one by replacing enum categories with a set of prefix-strings; "drm:core:", "drm:kms:" "drm:driver:" etc, and prepend them (at compile time) to the given formats.
Then we can use:
# echo module drm format "^drm:core: " +p > control`
to enable the whole category with one query.
This conversion yields many new prdbg callsites:
dyndbg: 207 debug prints in module drm_kms_helper
dyndbg: 376 debug prints in module drm
dyndbg: 1811 debug prints in module i915
dyndbg: 3917 debug prints in module amdgpu
Each site costs 56 bytes of .data, which is a big increase for drm modules, so CONFIG_DRM_USE_DYNAMIC_DEBUG makes it optional.
CONFIG_JUMP_LABEL is also required, to get the promised optimizations.
The "basic" -> "dyndbg" switchover is layered into the macro scheme
A. A "prefix" version of DRM_UT_<CATs> map, named DRM_DBG_CAT_<CATs>
"basic": DRM_DBG_CAT_<CATs> <=== DRM_UT_<CATs>. Identity map. "dyndbg":
#define DRM_DBG_CAT_KMS "drm:kms: "
#define DRM_DBG_CAT_PRIME "drm:prime: "
#define DRM_DBG_CAT_ATOMIC "drm:atomic: "
DRM_UT_* are preserved, since theyre used elsewhere. Since the callback maintains its state in __drm_debug, drm_debug_enabled() will stay synchronized, and continue to work. We can address them separately if they are called enough to be worth fixing.
B. drm_dev_dbg() & drm_debug() are interposed with macros
basic: forward to renamed fn, with args preserved
enabled: redirect to pr_debug, dev_dbg, with CATEGORY format catenated
This is where drm_debug_enabled() is avoided. The prefix is prepended at compile-time, no category at runtime.
C. API[1] uses DRM_DBG_CAT_<CAT>s
The API already uses B, now it uses A too, instead of DRM_UT_<CAT>, to get the correct token type for "basic" and "dyndbg" configs.
D. use DEFINE_DYNAMIC_DEBUG_CATEGORIES()
This defines the map using DRM_CAT_<CAT>s, and creates the /sysfs bitmap to control those categories.
CONFIG_DRM_USE_DYNAMIC_DEBUG is also used to adjust amdgpu, i915 makefiles to add -DDYNAMIC_DEBUG_MODULE; it includes the current CONFIG_DYNAMIC_DEBUG_CORE and is enabled by the user.
LIMITATIONS:
dev_dbg(etal) effectively prepends twice, category then driver-name, yielding format strings like so:
bash-5.1# grep amdgpu: /proc/dynamic_debug/control | grep drm: | cut -d= -f2- _ "amdgpu: drm:core: fence driver on ring %s use gpu addr 0x%016llx\012" _ "amdgpu: drm:kms: Cannot create framebuffer from imported dma_buf\012"
This means we cannot use anchored "^drm:kms: " to specify the category, a small loss of precision.
Note that searching on "format ^amdgpu: " works, but this is less valuable, because the same can be done with "module amdgpu".
NOTES:
Because the dyndbg callback is keeping state in __drm_debug, it synchronizes with drm_debug_enabled() and its remaining users; the switchover should be transparent.
Code Review is expected to catch the lack of correspondence between bit=>prefix definitions (the selector) and the prefixes used in the API[1] layer above pr_debug()
I've coded the categories with trailing spaces. This excludes any sub-categories which might get added later. This convention protects any "drm:atomic:fail:" callsites from getting stomped on by echo 0 > debug. Other categories could differ, but we need some default.
Dyndbg requires that the prefix be in the compiled-in format string; run-time prefixing evades callsite selection by category.
pr_debug("%s: ...", __func__, ...) // not idealUnfortunately __func__ is not a macro, and cannot be catenated at preprocess/compile time.
If you want that, you might consider +mfl flags instead;)
---
v5:
. use DEFINE_DYNAMIC_DEBUG_CATEGORIES in drm_print.c
. s/DRM_DBG_CLASS_/DRM_DBG_CAT_/ - dont need another term
. default=y in Kconfig entry - per @DanVet
. move some commit-log prose to dyndbg commit
. add-prototyes to (param_get/set)_dyndbg
. more wrinkles found by <[email protected]>
. relocate ratelimit chunk from elsewhere
v6:
. add kernel doc
. fix cpp paste, drop '#'
v7:
. change __drm_debug to long, to fit with DEFINE_DYNAMIC_DEBUG_CATEGORIES . add -DDYNAMIC_DEBUG_MODULE to ccflags if DRM_USE_DYNAMIC_DEBUG v8:
. adapt to altered ^ insertion
. add mem cost numbers to kconfig
. kdoc improvements (I hope)
--- drivers/gpu/drm/Kconfig | 26 +++++ drivers/gpu/drm/Makefile | 2 + drivers/gpu/drm/amd/amdgpu/Makefile | 2 +- drivers/gpu/drm/drm_print.c | 55 ++++++--- drivers/gpu/drm/i915/Makefile | 2 +- include/drm/drm_print.h | 175 ++++++++++++++++++++++------ 6 files changed, 210 insertions(+), 52 deletions(-)
drivers/gpu/drm/Kconfig +26 -0
@@ -62,6 +62,32 @@ config DRM_DEBUG_MM If in doubt, say "N". +config DRM_USE_DYNAMIC_DEBUG + bool "use dynamic debug to implement drm.debug" + default y + depends on DRM + depends on DYNAMIC_DEBUG || DYNAMIC_DEBUG_CORE + depends on JUMP_LABEL + help + The "basic" drm.debug facility does a lot of unlikely + bit-field tests at runtime; while cheap individually, the + cost accumulates. DYNAMIC_DEBUG can patch pr_debug()s into + NOOP slots, in a running kernel, so avoids those bit-test + overheads, and is therefore recommended by default. + + DRM_USE_DYNAMIC_DEBUG converts "basic" to "dyndbg", this + creates many new dyndbg callsites (56 bytes each), which + significantly increases drm* module .data, so is optional. + On an x86-64 kernel, with a config derived from fedora, that + price is: + #prdbgs KiB #with DRM_USE_DYNAMIC_DEBUG=y + kernel 3079 166k + drm 1 .06k 376 21k + drm_kms_helper 207 12k + i915 167 9.3k 1811 101k + amdgpu 2339 130k 3917 220k + nouveau 3 .17k 105 ~60k + config DRM_DEBUG_SELFTEST tristate "kselftests for DRM" depends on DRM
drivers/gpu/drm/Makefile +2 -0
@@ -33,6 +33,8 @@ drm-$(CONFIG_PCI) += drm_pci.o drm-$(CONFIG_DEBUG_FS) += drm_debugfs.o drm_debugfs_crc.o drm-$(CONFIG_DRM_LOAD_EDID_FIRMWARE) += drm_edid_load.o +ccflags-$(CONFIG_DRM_USE_DYNAMIC_DEBUG) += -DDYNAMIC_DEBUG_MODULE + obj-$(CONFIG_DRM_DP_AUX_BUS) += drm_dp_aux_bus.o drm_vram_helper-y := drm_gem_vram_helper.o
drivers/gpu/drm/amd/amdgpu/Makefile +1 -1
@@ -38,7 +38,7 @@ ccflags-y := -I$(FULL_AMD_PATH)/include/asic_reg \ -I$(FULL_AMD_DISPLAY_PATH)/amdgpu_dm \ -I$(FULL_AMD_PATH)/amdkfd -ccflags-$(CONFIG_DYNAMIC_DEBUG_CORE) += -DYNAMIC_DEBUG_MODULE +ccflags-$(CONFIG_DRM_USE_DYNAMIC_DEBUG) += -DYNAMIC_DEBUG_MODULE amdgpu-y := amdgpu_drv.o
drivers/gpu/drm/drm_print.c +39 -16
91 lines not on this page · raw message
drivers/gpu/drm/i915/Makefile +1 -1
@@ -317,7 +317,7 @@ i915-y += intel_gvt.o include $(src)/gvt/Makefile endif -ccflags-$(CONFIG_DYNAMIC_DEBUG_CORE) += -DDYNAMIC_DEBUG_MODULE +ccflags-$(CONFIG_DRM_USE_DYNAMIC_DEBUG) += -DDYNAMIC_DEBUG_MODULE obj-$(CONFIG_DRM_I915) += i915.o obj-$(CONFIG_DRM_I915_GVT_KVMGT) += gvt/kvmgt.o
include/drm/drm_print.h +141 -34
288 lines not on this page · raw message
Signature · 1 line
2.31.1
Jim Cromie
maintainerPATCH v10 7/10 drm_print: instrument drm_debug_enabled
In reply to Jim CromieDuplicate drm_debug_enabled() code into both "basic" and "dyndbg" ifdef branches. Then add a pr_debug("todo: ...") into the "dyndbg" branch.
Then convert the "dyndbg" branch's code to a macro, so that the pr_debug() get its callsite info from the invoking function, instead of from drm_debug_enabled() itself.
This gives us unique callsite info for the 8 remaining users of drm_debug_enabled(), and lets us enable them individually to see how much logging traffic they generate. The oft-visited callsites can then be reviewed for runtime cost and possible optimizations.
Heres what we get:
bash-5.1# modprobe drm
dyndbg: 384 debug prints in module drm
bash-5.1# grep todo: /proc/dynamic_debug/controldrivers/gpu/drm/drm_edid.c:1843 [drm]connector_bad_edid =_ "todo: maybe avoid via dyndbg\012" drivers/gpu/drm/drm_print.c:309 [drm]___drm_dbg =p "todo: maybe avoid via dyndbg\012" drivers/gpu/drm/drm_print.c:286 [drm]__drm_dev_dbg =p "todo: maybe avoid via dyndbg\012" drivers/gpu/drm/drm_vblank.c:1491 [drm]drm_vblank_restore =_ "todo: maybe avoid via dyndbg\012" drivers/gpu/drm/drm_vblank.c:787 [drm]drm_crtc_vblank_helper_get_vblank_timestamp_internal =_ "todo: maybe avoid via dyndbg\012" drivers/gpu/drm/drm_vblank.c:410 [drm]drm_crtc_accurate_vblank_count =_ "todo: maybe avoid via dyndbg\012" drivers/gpu/drm/drm_atomic_uapi.c:1457 [drm]drm_mode_atomic_ioctl =_ "todo: maybe avoid via dyndbg\012" drivers/gpu/drm/drm_edid_load.c:178 [drm]edid_load =_ "todo: maybe avoid via dyndbg\012"
At quick glance, edid won't qualify, drm_print might, drm_vblank is strongest chance, maybe atomic-ioctl too.
--- include/drm/drm_print.h | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-)
include/drm/drm_print.h +11 -6
@@ -381,6 +381,11 @@ enum drm_debug_category {#define DRM_DBG_CAT_DP DRM_UT_DP#define DRM_DBG_CAT_DRMRES DRM_UT_DRMRES +static inline bool drm_debug_enabled (enum drm_debug_category category) +{ +return unlikely (__drm_debug & category); +} +#else /* CONFIG_DRM_USE_DYNAMIC_DEBUG */ /* join prefix + format in cpp so dyndbg can see it */
@@ -414,12 +419,13 @@ enum drm_debug_category {#define DRM_DBG_CAT_DP "drm:dp: "#define DRM_DBG_CAT_DRMRES "drm:res: " -#endif /* CONFIG_DRM_USE_DYNAMIC_DEBUG */ +#define drm_debug_enabled (category) \ + ({ \ + pr_debug("todo: maybe avoid via dyndbg\n"); \ + unlikely(__drm_debug & (category)); \ + }) -static inline bool drm_debug_enabled (enum drm_debug_category category) -{ -return unlikely (__drm_debug & category); -} +#endif /* CONFIG_DRM_USE_DYNAMIC_DEBUG */ /* * struct device based logging
@@ -582,7 +588,6 @@ void __drm_dev_dbg(const struct device *dev, enum drm_debug_category category,#define drm_dbg_drmres (drm, fmt, ...) \ drm_dev_dbg((drm) ? (drm)->dev : NULL, DRM_DBG_CAT_DRMRES, fmt, ##__VA_ARGS__) -/* * printk based logging *
Signature · 1 line
2.31.1
Jim Cromie
maintainerPATCH v10 8/10 dyndbg: add print-to-tracefs, selftest with it - RFC
In reply to Jim CromieSean Paul proposed, in:
https://patchwork.freedesktop.org/series/78133/
drm/trace: Mirror DRM debug logs to tracefs
His patchset's objective is to be able to independently steer some of the drm.debug stream to an alternate tracing destination, by splitting drm_debug_enabled() into syslog & trace flavors, and enabling them separately. 2 advantages were identified:
1- syslog is heavyweight, tracefs is much lighter
2- separate selection of enabled categories means less traffic
Dynamic-Debug can do 2nd exceedingly well:
A- all work is behind jump-label's NOOP, zero off cost. B- exact site selectivity, precisely the useful traffic.
can tailor enabled set interactively, at shell.
Since the tracefs interface is effective for drm (the threads suggest so), adding that interface to dynamic-debug has real potential for everyone including drm.
if CONFIG_TRACING:
Grab Sean's trace_init/cleanup code, use it to provide tracefs available by default to all pr_debugs. This will likely need some further per-module treatment; perhaps something reflecting hierarchy of module,file,function,line, maybe with a tuned flattening.
endif CONFIG_TRACING
Add a new +T flag to enable tracing, independent of +p, and add and use 3 macros: dyndbg_site_is_enabled/logging/tracing(), to encapsulate the flag checks. Existing code treats T like other flags.
Add ddebug_validate_flags() as last step in ddebug_parse_flags(). Its only job is to fail on +T for non-CONFIG_TRACING builds. It only sees the new flags, and cannot validate specific state transitions. This is fine, since we have no need for that; such a test would have to be done in ddebug_change(), which actually updates the callsites.
ddebug_change() adjusts the static-key-enable/disable condition to use _DPRINTK_ENABLED / abstraction macros.
dynamic_emit_prefix() now gates on _DPRINTK_ENABLED too, as an optimization but mostly to allow decluttering of its users.
__dynamic_pr_debug() etal get minor changes:
- call dynamic_emit_prefix() 1st, _enabled() optimizes.
- if (T) call trace_array_printk
- if (!p) go around original printk code.
done to minimize diff,
goto-ectomy + reindent later/separately
- share vaf across p|T
WRT <net|ib>_dev, I skipped all the <T,!!dev> specific dev_emit_prefix additions for now. tracefs is a fast customer with different needs, its not clear that pretty device-ID-ish strings is useful tracefs content (on ingest), or that couldn't be done more efficiently while analysing or postprocesing the tracefs buffer.
SELFTEST: test_dynamic_debug.ko:
Uses the tracer facility to implement a kernel module selftest.
TODO:
Earlier core code had (tracerfn)() indirection, allowing a plugin side-effector we could test the results of.
ATM all the tests which count +T'd callsite executions (and which expect >0) are failing.
Now it needs a rethink to test from userspace, rather than the current test-once at module-load. It needs a parameters/testme button.
So remainder of this is a bit stale ....
- A custom tracer counts the number of calls (of T-enabled pr_debugs),
- do_debugging(x) calls a set of categorized pr_debugs x times
- test registers the tracer on the module
then iteratively:
manipulates dyndbg states via query-cmds, mostly format ^prefix runs do_debugging()
counts enabled callsite executions
reports mismatches
- modprobe test_dynamic_debug use_bad_tracer=1
attaches a bad/recursive tracer
Bad Things (did) Happen.
has thrown me interesting panics.
cannot replicate atm.
RFC: (DONE)
The "tracer" interface probably needs work and a new name. It is only 1/2 way towards a real tracefs interface; and the code I lifted from Sean Paul in the next patch could be implemented in dynamic_debug.c instead, and made available for all pr_debug users.
This would also eliminate need for dynamic_debug_(un)register_tracer(), since dyndbg could just provide it when TRACING is on.
NOTES:
$> modprobe test_dynamic_debug dyndbg=+p
it fails 3/29 tests. havent looked at why.
$> modprobe test_dynamic_debug use_bad_tracer=1
Earlier in dev, bad_tracer() exploded in recursion, I havent been able to replicate that lately.
--- .../admin-guide/dynamic-debug-howto.rst | 7 +- MAINTAINERS | 1 + include/linux/dynamic_debug.h | 12 +- lib/Kconfig.debug | 11 + lib/Makefile | 1 + lib/dynamic_debug.c | 127 ++++++++-- lib/test_dynamic_debug.c | 222 ++++++++++++++++++ 7 files changed, 355 insertions(+), 26 deletions(-) create mode 100644 lib/test_dynamic_debug.c
Documentation/admin-guide/dynamic-debug-howto.rst +4 -3
@@ -227,7 +227,8 @@ of the characters:: The flags are:: - p enables the pr_debug() callsite. + p enables the pr_debug() callsite to syslog + T enables the pr_debug() callsite to tracefs f Include the function name in the printed message l Include line number in the printed message m Include module name in the printed message
@@ -240,8 +241,8 @@ have meaning, other flags ignored. For display, the flags are preceded by ``=`` (mnemonic: what the flags are currently equal to). -Note the regexp ``^[-+=][flmpt_]+$`` matches a flags specification. -To clear all flags at once, use ``=_`` or ``-flmpt``. +Note the regexp ``^[-+=][flmptT_]+$`` matches a flags specification. +To clear all flags at once, use ``=_`` or ``-flmptT``. Debug messages during Boot Process
MAINTAINERS +1 -0
@@ -6663,6 +6663,7 @@ M: Jason Baron <[email protected]> S: Maintained F: include/linux/dynamic_debug.h F: lib/dynamic_debug.c +F: lib/test_dynamic_debug.c DYNAMIC INTERRUPT MODERATION M: Tal Gilboa <[email protected]>
include/linux/dynamic_debug.h +11 -1
@@ -28,15 +28,25 @@ struct _ddebug {*/ #define _DPRINTK_FLAGS_NONE 0#define _DPRINTK_FLAGS_PRINT (1<<0)/* printk() a message using the format */ +#define _DPRINTK_FLAGS_TRACE (1<<5)/* trace_printk() the message */ +#define _DPRINTK_ENABLED (_DPRINTK_FLAGS_PRINT | _DPRINTK_FLAGS_TRACE) + +/* internal, need type protection for external use */ +#define __dyndbg_site_is_enabled (desc) (!!(desc->flags & _DPRINTK_ENABLED)) +#define __dyndbg_site_is_logging (desc) (!!(desc->flags & _DPRINTK_FLAGS_PRINT)) +#define __dyndbg_site_is_tracing (desc) (!!(desc->flags & _DPRINTK_FLAGS_TRACE)) +#define _DPRINTK_FLAGS_INCL_MODNAME (1<<1)#define _DPRINTK_FLAGS_INCL_FUNCNAME (1<<2)#define _DPRINTK_FLAGS_INCL_LINENO (1<<3)#define _DPRINTK_FLAGS_INCL_TID (1<<4) -#define _DPRINTK_FLAGS_INCL_ANY \ +#define _DPRINTK_FLAGS_INCL_ANY \ (_DPRINTK_FLAGS_INCL_MODNAME | _DPRINTK_FLAGS_INCL_FUNCNAME |\ _DPRINTK_FLAGS_INCL_LINENO | _DPRINTK_FLAGS_INCL_TID) +#define __dyndbg_site_is_decorated (desc) (!!(desc->flags & _DPRINTK_FLAGS_INCL_ANY)) +#if definedDEBUG #define _DPRINTK_FLAGS_DEFAULT _DPRINTK_FLAGS_PRINT#else
lib/Kconfig.debug +11 -0
@@ -2480,6 +2480,17 @@ config TEST_STATIC_KEYS If unsure, say N. +config TEST_DYNAMIC_DEBUG + tristate "Test DYNAMIC_DEBUG" + depends on m + depends on DYNAMIC_DEBUG + 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. + + If unsure, say N. + config TEST_KMOD tristate "kmod stress tester" depends on m
lib/Makefile +1 -0
@@ -82,6 +82,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_PRINTF) += test_printf.o obj-$(CONFIG_TEST_SCANF) += test_scanf.o obj-$(CONFIG_TEST_BITMAP) += test_bitmap.o
lib/dynamic_debug.c +105 -22
256 lines not on this page · raw message
lib/test_dynamic_debug.c new file +222 -0
222 lines not on this page · raw message
Signature · 1 line
2.31.1
Re: [PATCH v10 08/10] dyndbg: add print-to-tracefs, selftest with it - RFC
Quoted 29 lines · Jim Cromie
Sean Paul proposed, in:
https://patchwork.freedesktop.org/series/78133/
drm/trace: Mirror DRM debug logs to tracefsHis patchset's objective is to be able to independently steer some of the drm.debug stream to an alternate tracing destination, by splitting
drm_debug_enabled()into syslog & trace flavors, and enabling them separately. 2 advantages were identified:1- syslog is heavyweight, tracefs is much lighter
2- separate selection of enabled categories means less trafficDynamic-Debug can do 2nd exceedingly well:
A- all work is behind jump-label's NOOP, zero off cost. B- exact site selectivity, precisely the useful traffic.
can tailor enabled set interactively, at shell.Since the tracefs interface is effective for drm (the threads suggest so), adding that interface to dynamic-debug has real potential for everyone including drm.
if
CONFIG_TRACING:Grab Sean's trace_init/cleanup code, use it to provide tracefs available by default to all
pr_debugs. This will likely need some further per-module treatment; perhaps something reflecting hierarchy of module,file,function,line, maybe with a tuned flattening.
Quoted 5 lines
endif
CONFIG_TRACINGAdd a new +T flag to enable tracing, independent of +p, and add and use 3 macros: dyndbg_site_is_enabled/logging/tracing(), to encapsulate the flag checks. Existing code treats T like other flags.
I posted a patchset a while ago to do something very similar, but that got stalled for some reason and I unfortunately didn't follow it up:
https://lore.kernel.org/lkml/[email protected]/
A key difference between that patchset and this patch (besides that small fact that I used +x instead of +T) was that my patchset allowed the dyndbg trace to be emitted to the main buffer and did not force them to be in an instance-specific buffer.
That feature is quite important at least for my use case since I often use dyndbg combined with function tracing, and the latter doesn't work on non-main instances according to Documentation/trace/ftrace.rst.
For example, here's a random example of a bootargs from one of my recent debugging sessions:
trace_event=printk:* ftrace_filter=_mmc*,mmc*,sd*,dw_mci*,mci* ftrace=function trace_buf_size=20M dyndbg="file drivers/mmc/* +x"
Jason Baron
maintainerRe: [PATCH v10 08/10] dyndbg: add print-to-tracefs, selftest with it - RFC
Quoted 39 lines · Vincent Whitchurch
Quoted 29 lines · Jim Cromie
Sean Paul proposed, in:
https://urldefense.com/v3/__https://patchwork.freedesktop.org/series/78133/__;!!GjvTz_vk!HcKnMRByYkIdyF1apqQjlN5aBIomzJR1an3YWXM6KXs0EftVMQdrewRA8Dki4A$
drm/trace: Mirror DRM debug logs to tracefsHis patchset's objective is to be able to independently steer some of the drm.debug stream to an alternate tracing destination, by splitting
drm_debug_enabled()into syslog & trace flavors, and enabling them separately. 2 advantages were identified:1- syslog is heavyweight, tracefs is much lighter
2- separate selection of enabled categories means less trafficDynamic-Debug can do 2nd exceedingly well:
A- all work is behind jump-label's NOOP, zero off cost. B- exact site selectivity, precisely the useful traffic.
can tailor enabled set interactively, at shell.Since the tracefs interface is effective for drm (the threads suggest so), adding that interface to dynamic-debug has real potential for everyone including drm.
if
CONFIG_TRACING:Grab Sean's trace_init/cleanup code, use it to provide tracefs available by default to all
pr_debugs. This will likely need some further per-module treatment; perhaps something reflecting hierarchy of module,file,function,line, maybe with a tuned flattening.Quoted 5 lines
endif
CONFIG_TRACINGAdd a new +T flag to enable tracing, independent of +p, and add and use 3 macros: dyndbg_site_is_enabled/logging/tracing(), to encapsulate the flag checks. Existing code treats T like other flags.
I posted a patchset a while ago to do something very similar, but that got stalled for some reason and I unfortunately didn't follow it up:
Quoted 6 lines
A key difference between that patchset and this patch (besides that small fact that I used +x instead of +T) was that my patchset allowed the dyndbg trace to be emitted to the main buffer and did not force them to be in an instance-specific buffer.
Yes, I agree I'd prefer that we print here to the 'main' buffer - it seems to keep things simpler and easier to combine the output from different sources as you mentioned.
Thanks,
-Jason
Quoted 11 lines
That feature is quite important at least for my use case since I often use dyndbg combined with function tracing, and the latter doesn't work on non-main instances according to
Documentation/trace/ftrace.rst.For example, here's a random example of a bootargs from one of my recent debugging sessions:
trace_event=printk:* ftrace_filter=_mmc*,mmc*,sd*,dw_mci*,mci* ftrace=function trace_buf_size=20M dyndbg="file
drivers/mmc/*+x"
Steven Rostedt
maintainerRe: [PATCH v10 08/10] dyndbg: add print-to-tracefs, selftest with it - RFC
Quoted 7 lines · On Fri, 12 Nov 2021 10:08:41 -0500 Jason Baron <[email protected]> wrote:
Quoted 4 lines
A key difference between that patchset and this patch (besides that small fact that I used +x instead of +T) was that my patchset allowed the dyndbg trace to be emitted to the main buffer and did not force them to be in an instance-specific buffer.
Yes, I agree I'd prefer that we print here to the 'main' buffer - it seems to keep things simpler and easier to combine the output from different sources as you mentioned.
I do not want anything to print to the "main buffer" that can not be filtered or turned off by the tracing infrastructure itself (aka tracefs file system).
Once we allow that, then the trace file will become useless because everything will write to the main buffer and fill it with noise.
Events that can be enabled and disabled from tracefs are fine, as they can be limited. This is why I added that nasty warning if people leave around trace_printk(), because it does exactly this (write to the main buffer). It's fine for debugging a custom kernel, but should never be enabled in something that is shipped, or part of mainline.
-- Steve
Jason Baron
maintainerRe: [PATCH v10 08/10] dyndbg: add print-to-tracefs, selftest with it - RFC
Quoted 18 lines · Steven Rostedt
Quoted 7 lines · On Fri, 12 Nov 2021 10:08:41 -0500 Jason Baron <[email protected]> wrote:
Quoted 4 lines
A key difference between that patchset and this patch (besides that small fact that I used +x instead of +T) was that my patchset allowed the dyndbg trace to be emitted to the main buffer and did not force them to be in an instance-specific buffer.
Yes, I agree I'd prefer that we print here to the 'main' buffer - it seems to keep things simpler and easier to combine the output from different sources as you mentioned.
I do not want anything to print to the "main buffer" that can not be filtered or turned off by the tracing infrastructure itself (aka tracefs file system).
Once we allow that, then the trace file will become useless because everything will write to the main buffer and fill it with noise.
Quoted 8 lines
Events that can be enabled and disabled from tracefs are fine, as they can be limited. This is why I added that nasty warning if people leave around
trace_printk(), because it does exactly this (write to the main buffer). It's fine for debugging a custom kernel, but should never be enabled in something that is shipped, or part of mainline.-- Steve
Ok, it looks like Vincent's patch defines a dyndbg event and then uses 'trace_dyndbg()' to output to the 'main' log. So all dynamic output to the 'main' ftrace buffer goes through that event if I understand it correctly. Here's a pointer to it for reference:
https://lore.kernel.org/lkml/[email protected]/
Would you be ok with that approach?
Thanks,
-Jason
Steven Rostedt
maintainerRe: [PATCH v10 08/10] dyndbg: add print-to-tracefs, selftest with it - RFC
Quoted 8 lines · On Fri, 12 Nov 2021 12:32:23 -0500 Jason Baron <[email protected]> wrote:
Ok, it looks like Vincent's patch defines a dyndbg event and then uses '
trace_dyndbg()' to output to the 'main' log. So all dynamic output to the 'main' ftrace buffer goes through that event if I understand it correctly. Here's a pointer to it for reference:https://lore.kernel.org/lkml/[email protected]/
Would you be ok with that approach?
Yes that approach is fine, because it doesn't actually go to the main log unless you enable the dyndbg trace event in the main buffer. You could also enable that event in an instance and have it go there.
-- Steve
Re: [PATCH v10 08/10] dyndbg: add print-to-tracefs, selftest with it - RFC
In reply to Jason BaronQuoted 42 lines · On Fri, 12 Nov 2021 10:08:41 -0500 Jason Baron <[email protected]> wrote:
Quoted 41 lines · Vincent Whitchurch
Quoted 29 lines · Jim Cromie
Sean Paul proposed, in:
https://urldefense.com/v3/__https://patchwork.freedesktop.org/series/78133/__;!!GjvTz_vk!HcKnMRByYkIdyF1apqQjlN5aBIomzJR1an3YWXM6KXs0EftVMQdrewRA8Dki4A$
drm/trace: Mirror DRM debug logs to tracefsHis patchset's objective is to be able to independently steer some of the drm.debug stream to an alternate tracing destination, by splitting
drm_debug_enabled()into syslog & trace flavors, and enabling them separately. 2 advantages were identified:1- syslog is heavyweight, tracefs is much lighter
2- separate selection of enabled categories means less trafficDynamic-Debug can do 2nd exceedingly well:
A- all work is behind jump-label's NOOP, zero off cost. B- exact site selectivity, precisely the useful traffic.
can tailor enabled set interactively, at shell.Since the tracefs interface is effective for drm (the threads suggest so), adding that interface to dynamic-debug has real potential for everyone including drm.
if
CONFIG_TRACING:Grab Sean's trace_init/cleanup code, use it to provide tracefs available by default to all
pr_debugs. This will likely need some further per-module treatment; perhaps something reflecting hierarchy of module,file,function,line, maybe with a tuned flattening.Quoted 5 lines
endif
CONFIG_TRACINGAdd a new +T flag to enable tracing, independent of +p, and add and use 3 macros: dyndbg_site_is_enabled/logging/tracing(), to encapsulate the flag checks. Existing code treats T like other flags.
I posted a patchset a while ago to do something very similar, but that got stalled for some reason and I unfortunately didn't follow it up:
Quoted 8 lines
Quoted 4 lines
A key difference between that patchset and this patch (besides that small fact that I used +x instead of +T) was that my patchset allowed the dyndbg trace to be emitted to the main buffer and did not force them to be in an instance-specific buffer.
Yes, I agree I'd prefer that we print here to the 'main' buffer - it seems to keep things simpler and easier to combine the output from different sources as you mentioned.
Hi,
I'm not quite sure I understand this discussion, but I would like to remind you all of what Sean's original work is about:
Userspace configures DRM tracing into a flight recorder buffer (I guess this is what you refer to "instance-specific buffer").
Userspace runs happily for months, and then hits a problem: a failure in the DRM sub-system most likely, e.g. an ioctl that should never fail, failed. Userspace handles that failure by dumping the flight recorder buffer into a file and saving or sending a bug report. The flight recorder contents give a log of all relevant DRM in-kernel actions leading to the unexpected failure to help developers debug it.
I don't mind if one can additionally send the flight recorder stream to the main buffer, but I do want the separate flight recorder buffer to be an option so that a) unrelated things cannot flood the interesting bits out of it, and b) the scope of collected information is relevant.
The very reason for this work is problems that are very difficult to reproduce in practice, either because the problem itself is triggered very rarely and randomly, or because the end users of the system have either no knowledge or no access to reconfigure debug logging and then reproduce the problem with good debug logs.
Thank you very much for pushing this work forward!
Thanks,
pq
Quoted 16 lines
Thanks,
-Jason
Quoted 11 lines
That feature is quite important at least for my use case since I often use dyndbg combined with function tracing, and the latter doesn't work on non-main instances according to
Documentation/trace/ftrace.rst.For example, here's a random example of a bootargs from one of my recent debugging sessions:
trace_event=printk:* ftrace_filter=_mmc*,mmc*,sd*,dw_mci*,mci* ftrace=function trace_buf_size=20M dyndbg="file
drivers/mmc/*+x"
Jason Baron
maintainerRe: [PATCH v10 08/10] dyndbg: add print-to-tracefs, selftest with it - RFC
Quoted 74 lines · Pekka Paalanen
Quoted 42 lines · On Fri, 12 Nov 2021 10:08:41 -0500 Jason Baron <[email protected]> wrote:
Quoted 41 lines · Vincent Whitchurch
Quoted 29 lines · Jim Cromie
Sean Paul proposed, in:
https://urldefense.com/v3/__https://patchwork.freedesktop.org/series/78133/__;!!GjvTz_vk!HcKnMRByYkIdyF1apqQjlN5aBIomzJR1an3YWXM6KXs0EftVMQdrewRA8Dki4A$
drm/trace: Mirror DRM debug logs to tracefsHis patchset's objective is to be able to independently steer some of the drm.debug stream to an alternate tracing destination, by splitting
drm_debug_enabled()into syslog & trace flavors, and enabling them separately. 2 advantages were identified:1- syslog is heavyweight, tracefs is much lighter
2- separate selection of enabled categories means less trafficDynamic-Debug can do 2nd exceedingly well:
A- all work is behind jump-label's NOOP, zero off cost. B- exact site selectivity, precisely the useful traffic.
can tailor enabled set interactively, at shell.Since the tracefs interface is effective for drm (the threads suggest so), adding that interface to dynamic-debug has real potential for everyone including drm.
if
CONFIG_TRACING:Grab Sean's trace_init/cleanup code, use it to provide tracefs available by default to all
pr_debugs. This will likely need some further per-module treatment; perhaps something reflecting hierarchy of module,file,function,line, maybe with a tuned flattening.Quoted 5 lines
endif
CONFIG_TRACINGAdd a new +T flag to enable tracing, independent of +p, and add and use 3 macros: dyndbg_site_is_enabled/logging/tracing(), to encapsulate the flag checks. Existing code treats T like other flags.
I posted a patchset a while ago to do something very similar, but that got stalled for some reason and I unfortunately didn't follow it up:
Quoted 8 lines
Quoted 4 lines
A key difference between that patchset and this patch (besides that small fact that I used +x instead of +T) was that my patchset allowed the dyndbg trace to be emitted to the main buffer and did not force them to be in an instance-specific buffer.
Yes, I agree I'd prefer that we print here to the 'main' buffer - it seems to keep things simpler and easier to combine the output from different sources as you mentioned.
Hi,
I'm not quite sure I understand this discussion, but I would like to remind you all of what Sean's original work is about:
Userspace configures DRM tracing into a flight recorder buffer (I guess this is what you refer to "instance-specific buffer").
Userspace runs happily for months, and then hits a problem: a failure in the DRM sub-system most likely, e.g. an ioctl that should never fail, failed. Userspace handles that failure by dumping the flight recorder buffer into a file and saving or sending a bug report. The flight recorder contents give a log of all relevant DRM in-kernel actions leading to the unexpected failure to help developers debug it.
I don't mind if one can additionally send the flight recorder stream to the main buffer, but I do want the separate flight recorder buffer to be an option so that a) unrelated things cannot flood the interesting bits out of it, and b) the scope of collected information is relevant.
Quoted 9 lines
The very reason for this work is problems that are very difficult to reproduce in practice, either because the problem itself is triggered very rarely and randomly, or because the end users of the system have either no knowledge or no access to reconfigure debug logging and then reproduce the problem with good debug logs.
Thank you very much for pushing this work forward!
So I think Vincent (earlier in the thread) was saying that he finds it very helpful have dynamic debug output go to the 'main' trace buffer, while you seem to be saying you'd prefer it just go to dynamic debug specific trace buffer.
So we certainly can have dynamic output potentially go to both places - although I think this would mean two tracepoints? But I really wonder if we really need a separate tracing buffer for dynamic debug when what goes to the 'main' buffer can be controlled and filtered to avoid your concern around a 'flood'?
Thanks,
-Jason
Re: [PATCH v10 08/10] dyndbg: add print-to-tracefs, selftest with it - RFC
Quoted 81 lines · On Thu, 18 Nov 2021 09:29:27 -0500 Jason Baron <[email protected]> wrote:
Quoted 80 lines · Pekka Paalanen
Quoted 42 lines · On Fri, 12 Nov 2021 10:08:41 -0500 Jason Baron <[email protected]> wrote:
Quoted 41 lines · Vincent Whitchurch
Quoted 29 lines · Jim Cromie
Sean Paul proposed, in:
https://urldefense.com/v3/__https://patchwork.freedesktop.org/series/78133/__;!!GjvTz_vk!HcKnMRByYkIdyF1apqQjlN5aBIomzJR1an3YWXM6KXs0EftVMQdrewRA8Dki4A$
drm/trace: Mirror DRM debug logs to tracefsHis patchset's objective is to be able to independently steer some of the drm.debug stream to an alternate tracing destination, by splitting
drm_debug_enabled()into syslog & trace flavors, and enabling them separately. 2 advantages were identified:1- syslog is heavyweight, tracefs is much lighter
2- separate selection of enabled categories means less trafficDynamic-Debug can do 2nd exceedingly well:
A- all work is behind jump-label's NOOP, zero off cost. B- exact site selectivity, precisely the useful traffic.
can tailor enabled set interactively, at shell.Since the tracefs interface is effective for drm (the threads suggest so), adding that interface to dynamic-debug has real potential for everyone including drm.
if
CONFIG_TRACING:Grab Sean's trace_init/cleanup code, use it to provide tracefs available by default to all
pr_debugs. This will likely need some further per-module treatment; perhaps something reflecting hierarchy of module,file,function,line, maybe with a tuned flattening.Quoted 5 lines
endif
CONFIG_TRACINGAdd a new +T flag to enable tracing, independent of +p, and add and use 3 macros: dyndbg_site_is_enabled/logging/tracing(), to encapsulate the flag checks. Existing code treats T like other flags.
I posted a patchset a while ago to do something very similar, but that got stalled for some reason and I unfortunately didn't follow it up:
Quoted 8 lines
Quoted 4 lines
A key difference between that patchset and this patch (besides that small fact that I used +x instead of +T) was that my patchset allowed the dyndbg trace to be emitted to the main buffer and did not force them to be in an instance-specific buffer.
Yes, I agree I'd prefer that we print here to the 'main' buffer - it seems to keep things simpler and easier to combine the output from different sources as you mentioned.
Hi,
I'm not quite sure I understand this discussion, but I would like to remind you all of what Sean's original work is about:
Userspace configures DRM tracing into a flight recorder buffer (I guess this is what you refer to "instance-specific buffer").
Userspace runs happily for months, and then hits a problem: a failure in the DRM sub-system most likely, e.g. an ioctl that should never fail, failed. Userspace handles that failure by dumping the flight recorder buffer into a file and saving or sending a bug report. The flight recorder contents give a log of all relevant DRM in-kernel actions leading to the unexpected failure to help developers debug it.
I don't mind if one can additionally send the flight recorder stream to the main buffer, but I do want the separate flight recorder buffer to be an option so that a) unrelated things cannot flood the interesting bits out of it, and b) the scope of collected information is relevant.
The very reason for this work is problems that are very difficult to reproduce in practice, either because the problem itself is triggered very rarely and randomly, or because the end users of the system have either no knowledge or no access to reconfigure debug logging and then reproduce the problem with good debug logs.
Quoted 8 lines
Quoted 3 lines
Thank you very much for pushing this work forward!
So I think Vincent (earlier in the thread) was saying that he finds it very helpful have dynamic debug output go to the 'main' trace buffer, while you seem to be saying you'd prefer it just go to dynamic debug specific trace buffer.
Seems like we have different use cases: traditional debugging, and in-production flight recorder for problem reporting. I'm not surprised if they need different treatment.
Quoted 5 lines
So we certainly can have dynamic output potentially go to both places - although I think this would mean two tracepoints? But I really wonder if we really need a separate tracing buffer for dynamic debug when what goes to the 'main' buffer can be controlled and filtered to avoid your concern around a 'flood'?
If the DRM tracing goes into the main buffer, then systems in production cannot have any other sub-system traced in a similar fashion. To me it would feel very arrogant to say that to make use of DRM flight recording, you cannot trace much or anything else.
The very purpose of the flight recorder is run in production all the time, not in a special debugging session.
There is also the question of access and contents of the trace buffer. Ultimately, if automatic bug reports are enabled in a system, the contents of the trace buffer would be sent as-is to some bug tracking system. If there is a chance to put non-DRM stuff in the trace buffer, that could be a security problem.
My use case is Weston. When Weston encounters an unexpected problem in production, something should automatically capture the DRM flight recorder contents and save it alongside the Weston log. Would be really nice if Weston itself could do that, but I suspect it is going to need root privileges so it needs some helper daemon.
Maybe Sean can reiterate their use case more?
Thanks,
pq
Jason Baron
maintainerRe: [PATCH v10 08/10] dyndbg: add print-to-tracefs, selftest with it - RFC
Quoted 123 lines · Pekka Paalanen
Quoted 81 lines · On Thu, 18 Nov 2021 09:29:27 -0500 Jason Baron <[email protected]> wrote:
Quoted 80 lines · Pekka Paalanen
Quoted 42 lines · On Fri, 12 Nov 2021 10:08:41 -0500 Jason Baron <[email protected]> wrote:
Quoted 41 lines · Vincent Whitchurch
Quoted 29 lines · Jim Cromie
Sean Paul proposed, in:
https://urldefense.com/v3/__https://patchwork.freedesktop.org/series/78133/__;!!GjvTz_vk!HcKnMRByYkIdyF1apqQjlN5aBIomzJR1an3YWXM6KXs0EftVMQdrewRA8Dki4A$
drm/trace: Mirror DRM debug logs to tracefsHis patchset's objective is to be able to independently steer some of the drm.debug stream to an alternate tracing destination, by splitting
drm_debug_enabled()into syslog & trace flavors, and enabling them separately. 2 advantages were identified:1- syslog is heavyweight, tracefs is much lighter
2- separate selection of enabled categories means less trafficDynamic-Debug can do 2nd exceedingly well:
A- all work is behind jump-label's NOOP, zero off cost. B- exact site selectivity, precisely the useful traffic.
can tailor enabled set interactively, at shell.Since the tracefs interface is effective for drm (the threads suggest so), adding that interface to dynamic-debug has real potential for everyone including drm.
if
CONFIG_TRACING:Grab Sean's trace_init/cleanup code, use it to provide tracefs available by default to all
pr_debugs. This will likely need some further per-module treatment; perhaps something reflecting hierarchy of module,file,function,line, maybe with a tuned flattening.Quoted 5 lines
endif
CONFIG_TRACINGAdd a new +T flag to enable tracing, independent of +p, and add and use 3 macros: dyndbg_site_is_enabled/logging/tracing(), to encapsulate the flag checks. Existing code treats T like other flags.
I posted a patchset a while ago to do something very similar, but that got stalled for some reason and I unfortunately didn't follow it up:
Quoted 8 lines
Quoted 4 lines
A key difference between that patchset and this patch (besides that small fact that I used +x instead of +T) was that my patchset allowed the dyndbg trace to be emitted to the main buffer and did not force them to be in an instance-specific buffer.
Yes, I agree I'd prefer that we print here to the 'main' buffer - it seems to keep things simpler and easier to combine the output from different sources as you mentioned.
Hi,
I'm not quite sure I understand this discussion, but I would like to remind you all of what Sean's original work is about:
Userspace configures DRM tracing into a flight recorder buffer (I guess this is what you refer to "instance-specific buffer").
Userspace runs happily for months, and then hits a problem: a failure in the DRM sub-system most likely, e.g. an ioctl that should never fail, failed. Userspace handles that failure by dumping the flight recorder buffer into a file and saving or sending a bug report. The flight recorder contents give a log of all relevant DRM in-kernel actions leading to the unexpected failure to help developers debug it.
I don't mind if one can additionally send the flight recorder stream to the main buffer, but I do want the separate flight recorder buffer to be an option so that a) unrelated things cannot flood the interesting bits out of it, and b) the scope of collected information is relevant.
The very reason for this work is problems that are very difficult to reproduce in practice, either because the problem itself is triggered very rarely and randomly, or because the end users of the system have either no knowledge or no access to reconfigure debug logging and then reproduce the problem with good debug logs.
Quoted 8 lines
Quoted 3 lines
Thank you very much for pushing this work forward!
So I think Vincent (earlier in the thread) was saying that he finds it very helpful have dynamic debug output go to the 'main' trace buffer, while you seem to be saying you'd prefer it just go to dynamic debug specific trace buffer.
Seems like we have different use cases: traditional debugging, and in-production flight recorder for problem reporting. I'm not surprised if they need different treatment.
Quoted 5 lines
So we certainly can have dynamic output potentially go to both places - although I think this would mean two tracepoints? But I really wonder if we really need a separate tracing buffer for dynamic debug when what goes to the 'main' buffer can be controlled and filtered to avoid your concern around a 'flood'?
If the DRM tracing goes into the main buffer, then systems in production cannot have any other sub-system traced in a similar fashion. To me it would feel very arrogant to say that to make use of DRM flight recording, you cannot trace much or anything else.
The very purpose of the flight recorder is run in production all the time, not in a special debugging session.
There is also the question of access and contents of the trace buffer. Ultimately, if automatic bug reports are enabled in a system, the contents of the trace buffer would be sent as-is to some bug tracking system. If there is a chance to put non-DRM stuff in the trace buffer, that could be a security problem.
My use case is Weston. When Weston encounters an unexpected problem in production, something should automatically capture the DRM flight recorder contents and save it alongside the Weston log. Would be really nice if Weston itself could do that, but I suspect it is going to need root privileges so it needs some helper daemon.
Quoted 6 lines
Maybe Sean can reiterate their use case more?
Thanks,
pq
Ok, so in this current thread the proposal was to create a "dyndbg-tracefs" buffer to put the dynamic debug output (including drm output from dynamic debug) into. And I was saying let's just put in the 'main' trace buffer (predicated on a dynamic debug specific tracepoint), since there seems to be a a use-case for that and it keeps things simpler.
But I went back to Sean's original patch, and it creates a drm specific trace buffer "drm" (via trace_array_get_by_name("drm")). Here:
https://patchwork.freedesktop.org/patch/445549/?series=78133&rev=5
So I think that may be some of the confusion here? The current thread/ proposal is not for a drm specific trace buffer...
Having a subsystem specific trace buffer would allow subsystem specific trace log permissions depending on the sensitivity of the data. But doesn't drm output today go to the system log which is typically world readable today?
So I could see us supporting subsystem specific trace buffer output via dynamic debug here. We could add new dev_debug() variants that allow say a trace buffer to be supplied. So in that way subsystems could 'opt-out' of having their data put into the global trace buffer. And perhaps some subsystems we would want to allow output to both buffers? The subsystem specific one and the global one?
Thanks,
-Jason
[email protected]
maintainerRe: [PATCH v10 08/10] dyndbg: add print-to-tracefs, selftest with it - RFC
Quoted 140 lines · Jason Baron
Quoted 123 lines · Pekka Paalanen
Quoted 81 lines · On Thu, 18 Nov 2021 09:29:27 -0500 Jason Baron <[email protected]> wrote:
Quoted 80 lines · Pekka Paalanen
Quoted 42 lines · On Fri, 12 Nov 2021 10:08:41 -0500 Jason Baron <[email protected]> wrote:
Quoted 41 lines · Vincent Whitchurch
Quoted 29 lines · Jim Cromie
Sean Paul proposed, in:
https://urldefense.com/v3/__https://patchwork.freedesktop.org/series/78133/__;!!GjvTz_vk!HcKnMRByYkIdyF1apqQjlN5aBIomzJR1an3YWXM6KXs0EftVMQdrewRA8Dki4A$
drm/trace: Mirror DRM debug logs to tracefsHis patchset's objective is to be able to independently steer some of the drm.debug stream to an alternate tracing destination, by splitting
drm_debug_enabled()into syslog & trace flavors, and enabling them separately. 2 advantages were identified:1- syslog is heavyweight, tracefs is much lighter
2- separate selection of enabled categories means less trafficDynamic-Debug can do 2nd exceedingly well:
A- all work is behind jump-label's NOOP, zero off cost. B- exact site selectivity, precisely the useful traffic.
can tailor enabled set interactively, at shell.Since the tracefs interface is effective for drm (the threads suggest so), adding that interface to dynamic-debug has real potential for everyone including drm.
if
CONFIG_TRACING:Grab Sean's trace_init/cleanup code, use it to provide tracefs available by default to all
pr_debugs. This will likely need some further per-module treatment; perhaps something reflecting hierarchy of module,file,function,line, maybe with a tuned flattening.Quoted 5 lines
endif
CONFIG_TRACINGAdd a new +T flag to enable tracing, independent of +p, and add and use 3 macros: dyndbg_site_is_enabled/logging/tracing(), to encapsulate the flag checks. Existing code treats T like other flags.
I posted a patchset a while ago to do something very similar, but that got stalled for some reason and I unfortunately didn't follow it up:
Quoted 8 lines
Quoted 4 lines
A key difference between that patchset and this patch (besides that small fact that I used +x instead of +T) was that my patchset allowed the dyndbg trace to be emitted to the main buffer and did not force them to be in an instance-specific buffer.
Yes, I agree I'd prefer that we print here to the 'main' buffer - it seems to keep things simpler and easier to combine the output from different sources as you mentioned.
Hi,
I'm not quite sure I understand this discussion, but I would like to remind you all of what Sean's original work is about:
Userspace configures DRM tracing into a flight recorder buffer (I guess this is what you refer to "instance-specific buffer").
Userspace runs happily for months, and then hits a problem: a failure in the DRM sub-system most likely, e.g. an ioctl that should never fail, failed. Userspace handles that failure by dumping the flight recorder buffer into a file and saving or sending a bug report. The flight recorder contents give a log of all relevant DRM in-kernel actions leading to the unexpected failure to help developers debug it.
I don't mind if one can additionally send the flight recorder stream to the main buffer, but I do want the separate flight recorder buffer to be an option so that a) unrelated things cannot flood the interesting bits out of it, and b) the scope of collected information is relevant.
The very reason for this work is problems that are very difficult to reproduce in practice, either because the problem itself is triggered very rarely and randomly, or because the end users of the system have either no knowledge or no access to reconfigure debug logging and then reproduce the problem with good debug logs.
Quoted 8 lines
Quoted 3 lines
Thank you very much for pushing this work forward!
So I think Vincent (earlier in the thread) was saying that he finds it very helpful have dynamic debug output go to the 'main' trace buffer, while you seem to be saying you'd prefer it just go to dynamic debug specific trace buffer.
Seems like we have different use cases: traditional debugging, and in-production flight recorder for problem reporting. I'm not surprised if they need different treatment.
Quoted 5 lines
So we certainly can have dynamic output potentially go to both places - although I think this would mean two tracepoints? But I really wonder if we really need a separate tracing buffer for dynamic debug when what goes to the 'main' buffer can be controlled and filtered to avoid your concern around a 'flood'?
If the DRM tracing goes into the main buffer, then systems in production cannot have any other sub-system traced in a similar fashion. To me it would feel very arrogant to say that to make use of DRM flight recording, you cannot trace much or anything else.
The very purpose of the flight recorder is run in production all the time, not in a special debugging session.
There is also the question of access and contents of the trace buffer. Ultimately, if automatic bug reports are enabled in a system, the contents of the trace buffer would be sent as-is to some bug tracking system. If there is a chance to put non-DRM stuff in the trace buffer, that could be a security problem.
My use case is Weston. When Weston encounters an unexpected problem in production, something should automatically capture the DRM flight recorder contents and save it alongside the Weston log. Would be really nice if Weston itself could do that, but I suspect it is going to need root privileges so it needs some helper daemon.
Quoted 6 lines
Maybe Sean can reiterate their use case more?
Thanks,
pqOk, so in this current thread the proposal was to create a "dyndbg-tracefs" buffer to put the dynamic debug output (including drm output from dynamic debug) into. And I was saying let's just put in the 'main' trace buffer (predicated on a dynamic debug specific tracepoint), since there seems to be a a use-case for that and it keeps things simpler.
Quoted 7 lines
But I went back to Sean's original patch, and it creates a drm specific trace buffer "drm" (via
trace_array_get_by_name("drm")). Here:
https://patchwork.freedesktop.org/patch/445549/?series=78133&rev=5So I think that may be some of the confusion here? The current thread/ proposal is not for a drm specific trace buffer...
while thats true, it was a KISS choice, not intrinsic. Now that a requirement has emerged, I can think about it.
I thought use of all the pr_debug()s as a tracefs event provider made sense, since the callsite descriptor is passed in, and could be passed in to the tracefs interface.
Vincent's code has the macro magic to define that event, which IIUC is what makes it controllable by ftrace, and therefore acceptable in principle to Steve.
Would there be any reason to expand his set of 2 events into dev_dbg, pr_debug etc varieties ?
(ie any value to separating dev, !dev ?, maybe so)
Sean's code uses trace_array_printk primarily, which is EXPORTed, which is a virtue.
Vincents code does
+/*
+ * This code is heavily based on __ftrace_trace_stack().
+ *
+ * Allow 4 levels of nesting: normal, softirq, irq, NMI.
+ */
to implement
+static void dynamic_trace(const char *fmt, va_list args)
Has this __ftrace_trace_stack() code been bundled into or hidden under a supported interface ?
would it look anything like trace_array_printk() ?
what problem is that code solving inside dynamic-debug.c ?
Quoted 6 lines
Having a subsystem specific trace buffer would allow subsystem specific trace log permissions depending on the sensitivity of the data. But doesn't drm output today go to the system log which is typically world readable today?
Quoted 7 lines
So I could see us supporting subsystem specific trace buffer output via dynamic debug here. We could add new
dev_debug()variants that allow say a trace buffer to be supplied. So in that way subsystems could 'opt-out' of having their data put into the global trace buffer. And perhaps some subsystems we would want to allow output to both buffers? The subsystem specific one and the global one?
* trace_array_printk - Print a message to a specific instance
* @tr: The instance trace_array descriptor
* @ip: The instruction pointer that this is called from.
* @fmt: The format to print (printf format)
*
what happens when @tr == NULL ?
It could allow up-flow of events to the global instance
Quoted 5 lines
Thanks,
-Jason
So I wonder, is there any conceptual utility to this ?
echo 1 > instances/foo/filter_up # enable event upflow (or query-time merging?)
Maybe enabling this causes other files (the ones missing from instances/foo) to magically appear
so all those filtering capacities also appear.
Steven Rostedt
maintainerRe: [PATCH v10 08/10] dyndbg: add print-to-tracefs, selftest with it - RFC
Quoted 8 lines · On Fri, 19 Nov 2021 15:46:31 -0700 [email protected] wrote:
Quoted 7 lines
So I could see us supporting subsystem specific trace buffer output via dynamic debug here. We could add new
dev_debug()variants that allow say a trace buffer to be supplied. So in that way subsystems could 'opt-out' of having their data put into the global trace buffer. And perhaps some subsystems we would want to allow output to both buffers? The subsystem specific one and the global one?
Quoted 7 lines
*
trace_array_printk- Print a message to a specific instance
* @tr: The instancetrace_arraydescriptor
* @ip: The instruction pointer that this is called from.
* @fmt: The format to print (printf format)
*what happens when @tr == NULL ?
It does nothing, but perhaps crash the kernel.
Quoted 1 line
It could allow up-flow of events to the global instance
Absolutely not!
Then it's just a reimplementation of trace_printk(). Which I refuse to have.
Nothing should just dump to the main instance. Once we allow that, then everyone will be dumping there and you will no longer be able to trace anything because it will be filled with noise.
What is allowed is an event that acts like a trace_printk() but is an event, which you can turn off (have default off), and even pick which instance to go to.
Quoted 7 lines
Quoted 6 lines
Thanks,
-Jason
Quoted 7 lines
So I wonder, is there any conceptual utility to this ?
echo 1 > instances/foo/filter_up # enable event upflow (or query-time merging?)
Maybe enabling this causes other files (the ones missing from instances/foo) to magically appear
so all those filtering capacities also appear.
I've been busy doing other things so I haven't been keeping up with this thread (which I need to go back and read). Perhaps it was already stated, but I don't know why you want that.
trace-cmd can read several instances (including the top level one) and interleave them nicely, if that is what you are looking for. So can KernelShark.
-- Steve
Re: [PATCH v10 08/10] dyndbg: add print-to-tracefs, selftest with it - RFC
In reply to [email protected]Quoted 19 lines · On Fri, Nov 19, 2021 at 11:46:31PM +0100, [email protected] wrote:
Vincent's code has the macro magic to define that event, which IIUC is what makes it controllable by ftrace, and therefore acceptable in principle to Steve.
Would there be any reason to expand his set of 2 events intodev_dbg,pr_debugetc varieties ?
(ie any value to separating dev, !dev ?, maybe soSean's code uses
trace_array_printkprimarily, which is EXPORTed, which is a virtue.Vincents code does
+/*
+ * This code is heavily based on__ftrace_trace_stack().
+ *
+ * Allow 4 levels of nesting: normal, softirq, irq, NMI.
+ */to implement
Quoted 8 lines
+static void
dynamic_trace(const char *fmt, va_list args)Has this
__ftrace_trace_stack()code been bundled into or hidden under a supported interface ?would it look anything like
trace_array_printk()?what problem is that code solving inside
dynamic-debug.c?
I'm not sure I fully understand all of your questions, but perhaps this thread with Steven's reply to the first version of my patchset will answer some of them:
Re: [PATCH v10 08/10] dyndbg: add print-to-tracefs, selftest with it - RFC
In reply to Jason BaronQuoted 137 lines · On Fri, 19 Nov 2021 11:21:36 -0500 Jason Baron <[email protected]> wrote:
Quoted 123 lines · Pekka Paalanen
Quoted 81 lines · On Thu, 18 Nov 2021 09:29:27 -0500 Jason Baron <[email protected]> wrote:
Quoted 80 lines · Pekka Paalanen
Quoted 42 lines · On Fri, 12 Nov 2021 10:08:41 -0500 Jason Baron <[email protected]> wrote:
Quoted 41 lines · Vincent Whitchurch
Quoted 29 lines · Jim Cromie
Sean Paul proposed, in:
https://urldefense.com/v3/__https://patchwork.freedesktop.org/series/78133/__;!!GjvTz_vk!HcKnMRByYkIdyF1apqQjlN5aBIomzJR1an3YWXM6KXs0EftVMQdrewRA8Dki4A$
drm/trace: Mirror DRM debug logs to tracefsHis patchset's objective is to be able to independently steer some of the drm.debug stream to an alternate tracing destination, by splitting
drm_debug_enabled()into syslog & trace flavors, and enabling them separately. 2 advantages were identified:1- syslog is heavyweight, tracefs is much lighter
2- separate selection of enabled categories means less trafficDynamic-Debug can do 2nd exceedingly well:
A- all work is behind jump-label's NOOP, zero off cost. B- exact site selectivity, precisely the useful traffic.
can tailor enabled set interactively, at shell.Since the tracefs interface is effective for drm (the threads suggest so), adding that interface to dynamic-debug has real potential for everyone including drm.
if
CONFIG_TRACING:Grab Sean's trace_init/cleanup code, use it to provide tracefs available by default to all
pr_debugs. This will likely need some further per-module treatment; perhaps something reflecting hierarchy of module,file,function,line, maybe with a tuned flattening.Quoted 5 lines
endif
CONFIG_TRACINGAdd a new +T flag to enable tracing, independent of +p, and add and use 3 macros: dyndbg_site_is_enabled/logging/tracing(), to encapsulate the flag checks. Existing code treats T like other flags.
I posted a patchset a while ago to do something very similar, but that got stalled for some reason and I unfortunately didn't follow it up:
Quoted 8 lines
Quoted 4 lines
A key difference between that patchset and this patch (besides that small fact that I used +x instead of +T) was that my patchset allowed the dyndbg trace to be emitted to the main buffer and did not force them to be in an instance-specific buffer.
Yes, I agree I'd prefer that we print here to the 'main' buffer - it seems to keep things simpler and easier to combine the output from different sources as you mentioned.
Hi,
I'm not quite sure I understand this discussion, but I would like to remind you all of what Sean's original work is about:
Userspace configures DRM tracing into a flight recorder buffer (I guess this is what you refer to "instance-specific buffer").
Userspace runs happily for months, and then hits a problem: a failure in the DRM sub-system most likely, e.g. an ioctl that should never fail, failed. Userspace handles that failure by dumping the flight recorder buffer into a file and saving or sending a bug report. The flight recorder contents give a log of all relevant DRM in-kernel actions leading to the unexpected failure to help developers debug it.
I don't mind if one can additionally send the flight recorder stream to the main buffer, but I do want the separate flight recorder buffer to be an option so that a) unrelated things cannot flood the interesting bits out of it, and b) the scope of collected information is relevant.
The very reason for this work is problems that are very difficult to reproduce in practice, either because the problem itself is triggered very rarely and randomly, or because the end users of the system have either no knowledge or no access to reconfigure debug logging and then reproduce the problem with good debug logs.
Quoted 8 lines
Quoted 3 lines
Thank you very much for pushing this work forward!
So I think Vincent (earlier in the thread) was saying that he finds it very helpful have dynamic debug output go to the 'main' trace buffer, while you seem to be saying you'd prefer it just go to dynamic debug specific trace buffer.
Seems like we have different use cases: traditional debugging, and in-production flight recorder for problem reporting. I'm not surprised if they need different treatment.
Quoted 5 lines
So we certainly can have dynamic output potentially go to both places - although I think this would mean two tracepoints? But I really wonder if we really need a separate tracing buffer for dynamic debug when what goes to the 'main' buffer can be controlled and filtered to avoid your concern around a 'flood'?
If the DRM tracing goes into the main buffer, then systems in production cannot have any other sub-system traced in a similar fashion. To me it would feel very arrogant to say that to make use of DRM flight recording, you cannot trace much or anything else.
The very purpose of the flight recorder is run in production all the time, not in a special debugging session.
There is also the question of access and contents of the trace buffer. Ultimately, if automatic bug reports are enabled in a system, the contents of the trace buffer would be sent as-is to some bug tracking system. If there is a chance to put non-DRM stuff in the trace buffer, that could be a security problem.
My use case is Weston. When Weston encounters an unexpected problem in production, something should automatically capture the DRM flight recorder contents and save it alongside the Weston log. Would be really nice if Weston itself could do that, but I suspect it is going to need root privileges so it needs some helper daemon.
Quoted 6 lines
Maybe Sean can reiterate their use case more?
Thanks,
pqOk, so in this current thread the proposal was to create a "dyndbg-tracefs" buffer to put the dynamic debug output (including drm output from dynamic debug) into. And I was saying let's just put in the 'main' trace buffer (predicated on a dynamic debug specific tracepoint), since there seems to be a a use-case for that and it keeps things simpler.
Quoted 6 lines
But I went back to Sean's original patch, and it creates a drm specific trace buffer "drm" (via
trace_array_get_by_name("drm")). Here:
https://patchwork.freedesktop.org/patch/445549/?series=78133&rev=5So I think that may be some of the confusion here? The current thread/ proposal is not for a drm specific trace buffer...
Hi Jason,
I may very well have confused things, sorry about that. If this series is not superseding the idea of the DRM flight recorder, then don't mind me. It just sounded very similar and I also haven't seen new revisions of the flight recorder in a long time.
Quoted 4 lines
Having a subsystem specific trace buffer would allow subsystem specific trace log permissions depending on the sensitivity of the data. But doesn't drm output today go to the system log which is typically world readable today?
Yes, and that is exactly the problem. The DRM debug output is so high traffic it would make the system log both unusable due to cruft and slow down the whole machine. The debug output is only useful when something went wrong, and at that point it is too late to enable debugging. That's why a flight recorder with an over-written circular in-memory buffer is needed.
The log being world-readable (it's not in every distribution, I believe) only means on that one machine, but there are hopes of making some logs truly world-readable by posting them to the internet (bug reports).
I would be very wary of anything uploading my system logs automatically with bug reports, both from the reporter point of view (am I exposing things I don't want to) and from the bug report receiving service point of view (e.g. GDPR regulations).
Quoted 6 lines
So I could see us supporting subsystem specific trace buffer output via dynamic debug here. We could add new
dev_debug()variants that allow say a trace buffer to be supplied. So in that way subsystems could 'opt-out' of having their data put into the global trace buffer. And perhaps some subsystems we would want to allow output to both buffers? The subsystem specific one and the global one?
Unfortunately the rest of the discussion goes too high over my head.
Thanks,
pq
[email protected]
maintainerRe: [PATCH v10 08/10] dyndbg: add print-to-tracefs, selftest with it - RFC
Quoted 148 lines · Pekka Paalanen
Quoted 137 lines · On Fri, 19 Nov 2021 11:21:36 -0500 Jason Baron <[email protected]> wrote:
Quoted 123 lines · Pekka Paalanen
Quoted 81 lines · On Thu, 18 Nov 2021 09:29:27 -0500 Jason Baron <[email protected]> wrote:
Quoted 80 lines · Pekka Paalanen
Quoted 42 lines · On Fri, 12 Nov 2021 10:08:41 -0500 Jason Baron <[email protected]> wrote:
Quoted 41 lines · Vincent Whitchurch
Quoted 29 lines · Jim Cromie
Sean Paul proposed, in:
https://urldefense.com/v3/__https://patchwork.freedesktop.org/series/78133/__;!!GjvTz_vk!HcKnMRByYkIdyF1apqQjlN5aBIomzJR1an3YWXM6KXs0EftVMQdrewRA8Dki4A$
drm/trace: Mirror DRM debug logs to tracefsHis patchset's objective is to be able to independently steer some of the drm.debug stream to an alternate tracing destination, by splitting
drm_debug_enabled()into syslog & trace flavors, and enabling them separately. 2 advantages were identified:1- syslog is heavyweight, tracefs is much lighter
2- separate selection of enabled categories means less trafficDynamic-Debug can do 2nd exceedingly well:
A- all work is behind jump-label's NOOP, zero off cost. B- exact site selectivity, precisely the useful traffic.
can tailor enabled set interactively, at shell.Since the tracefs interface is effective for drm (the threads suggest so), adding that interface to dynamic-debug has real potential for everyone including drm.
if
CONFIG_TRACING:Grab Sean's trace_init/cleanup code, use it to provide tracefs available by default to all
pr_debugs. This will likely need some further per-module treatment; perhaps something reflecting hierarchy of module,file,function,line, maybe with a tuned flattening.Quoted 5 lines
endif
CONFIG_TRACINGAdd a new +T flag to enable tracing, independent of +p, and add and use 3 macros: dyndbg_site_is_enabled/logging/tracing(), to encapsulate the flag checks. Existing code treats T like other flags.
I posted a patchset a while ago to do something very similar, but that got stalled for some reason and I unfortunately didn't follow it up:
Quoted 8 lines
Quoted 4 lines
A key difference between that patchset and this patch (besides that small fact that I used +x instead of +T) was that my patchset allowed the dyndbg trace to be emitted to the main buffer and did not force them to be in an instance-specific buffer.
Yes, I agree I'd prefer that we print here to the 'main' buffer - it seems to keep things simpler and easier to combine the output from different sources as you mentioned.
Hi,
I'm not quite sure I understand this discussion, but I would like to remind you all of what Sean's original work is about:
Userspace configures DRM tracing into a flight recorder buffer (I guess this is what you refer to "instance-specific buffer").
Userspace runs happily for months, and then hits a problem: a failure in the DRM sub-system most likely, e.g. an ioctl that should never fail, failed. Userspace handles that failure by dumping the flight recorder buffer into a file and saving or sending a bug report. The flight recorder contents give a log of all relevant DRM in-kernel actions leading to the unexpected failure to help developers debug it.
I don't mind if one can additionally send the flight recorder stream to the main buffer, but I do want the separate flight recorder buffer to be an option so that a) unrelated things cannot flood the interesting bits out of it, and b) the scope of collected information is relevant.
The very reason for this work is problems that are very difficult to reproduce in practice, either because the problem itself is triggered very rarely and randomly, or because the end users of the system have either no knowledge or no access to reconfigure debug logging and then reproduce the problem with good debug logs.
Quoted 8 lines
Quoted 3 lines
Thank you very much for pushing this work forward!
So I think Vincent (earlier in the thread) was saying that he finds it very helpful have dynamic debug output go to the 'main' trace buffer, while you seem to be saying you'd prefer it just go to dynamic debug specific trace buffer.
Seems like we have different use cases: traditional debugging, and in-production flight recorder for problem reporting. I'm not surprised if they need different treatment.
Quoted 5 lines
So we certainly can have dynamic output potentially go to both places - although I think this would mean two tracepoints? But I really wonder if we really need a separate tracing buffer for dynamic debug when what goes to the 'main' buffer can be controlled and filtered to avoid your concern around a 'flood'?
If the DRM tracing goes into the main buffer, then systems in production cannot have any other sub-system traced in a similar fashion. To me it would feel very arrogant to say that to make use of DRM flight recording, you cannot trace much or anything else.
The very purpose of the flight recorder is run in production all the time, not in a special debugging session.
There is also the question of access and contents of the trace buffer. Ultimately, if automatic bug reports are enabled in a system, the contents of the trace buffer would be sent as-is to some bug tracking system. If there is a chance to put non-DRM stuff in the trace buffer, that could be a security problem.
My use case is Weston. When Weston encounters an unexpected problem in production, something should automatically capture the DRM flight recorder contents and save it alongside the Weston log. Would be really nice if Weston itself could do that, but I suspect it is going to need root privileges so it needs some helper daemon.
Quoted 6 lines
Maybe Sean can reiterate their use case more?
Thanks,
pqOk, so in this current thread the proposal was to create a "dyndbg-tracefs" buffer to put the dynamic debug output (including drm output from dynamic debug) into. And I was saying let's just put in the 'main' trace buffer (predicated on a dynamic debug specific tracepoint), since there seems to be a a use-case for that and it keeps things simpler.
Quoted 6 lines
But I went back to Sean's original patch, and it creates a drm specific trace buffer "drm" (via
trace_array_get_by_name("drm")). Here:
https://patchwork.freedesktop.org/patch/445549/?series=78133&rev=5So I think that may be some of the confusion here? The current thread/ proposal is not for a drm specific trace buffer...
Quoted 6 lines
Hi Jason,
I may very well have confused things, sorry about that. If this series is not superseding the idea of the DRM flight recorder, then don't mind me. It just sounded very similar and I also haven't seen new revisions of the flight recorder in a long time.
IMO this series has clarified the requirement for a flight-recorder mode, which seems to fit ideally in a separate instance.
Quoted 11 lines
Quoted 4 lines
Having a subsystem specific trace buffer would allow subsystem specific trace log permissions depending on the sensitivity of the data. But doesn't drm output today go to the system log which is typically world readable today?
Yes, and that is exactly the problem. The DRM debug output is so high traffic it would make the system log both unusable due to cruft and slow down the whole machine. The debug output is only useful when something went wrong, and at that point it is too late to enable debugging. That's why a flight recorder with an over-written circular in-memory buffer is needed.
Seans patch reuses enum drm_debug_category to split the tracing stream into 10 sub-streams
- how much traffic from each ?
- are some sub-streams more valuable for post-mortem ?
- any value from further refinement of categories ?
- drop irrelevant callsites individually to reduce clutter, extend buffer time/space ?
Re: [PATCH v10 08/10] dyndbg: add print-to-tracefs, selftest with it - RFC
Quoted 171 lines · On Mon, 22 Nov 2021 15:42:38 -0700 [email protected] wrote:
Quoted 148 lines · Pekka Paalanen
Quoted 137 lines · On Fri, 19 Nov 2021 11:21:36 -0500 Jason Baron <[email protected]> wrote:
Quoted 123 lines · Pekka Paalanen
Quoted 81 lines · On Thu, 18 Nov 2021 09:29:27 -0500 Jason Baron <[email protected]> wrote:
Quoted 80 lines · Pekka Paalanen
Quoted 42 lines · On Fri, 12 Nov 2021 10:08:41 -0500 Jason Baron <[email protected]> wrote:
Quoted 41 lines · Vincent Whitchurch
Quoted 29 lines · Jim Cromie
Sean Paul proposed, in:
https://urldefense.com/v3/__https://patchwork.freedesktop.org/series/78133/__;!!GjvTz_vk!HcKnMRByYkIdyF1apqQjlN5aBIomzJR1an3YWXM6KXs0EftVMQdrewRA8Dki4A$
drm/trace: Mirror DRM debug logs to tracefsHis patchset's objective is to be able to independently steer some of the drm.debug stream to an alternate tracing destination, by splitting
drm_debug_enabled()into syslog & trace flavors, and enabling them separately. 2 advantages were identified:1- syslog is heavyweight, tracefs is much lighter
2- separate selection of enabled categories means less trafficDynamic-Debug can do 2nd exceedingly well:
A- all work is behind jump-label's NOOP, zero off cost. B- exact site selectivity, precisely the useful traffic.
can tailor enabled set interactively, at shell.Since the tracefs interface is effective for drm (the threads suggest so), adding that interface to dynamic-debug has real potential for everyone including drm.
if
CONFIG_TRACING:Grab Sean's trace_init/cleanup code, use it to provide tracefs available by default to all
pr_debugs. This will likely need some further per-module treatment; perhaps something reflecting hierarchy of module,file,function,line, maybe with a tuned flattening.Quoted 5 lines
endif
CONFIG_TRACINGAdd a new +T flag to enable tracing, independent of +p, and add and use 3 macros: dyndbg_site_is_enabled/logging/tracing(), to encapsulate the flag checks. Existing code treats T like other flags.
I posted a patchset a while ago to do something very similar, but that got stalled for some reason and I unfortunately didn't follow it up:
Quoted 8 lines
Quoted 4 lines
A key difference between that patchset and this patch (besides that small fact that I used +x instead of +T) was that my patchset allowed the dyndbg trace to be emitted to the main buffer and did not force them to be in an instance-specific buffer.
Yes, I agree I'd prefer that we print here to the 'main' buffer - it seems to keep things simpler and easier to combine the output from different sources as you mentioned.
Hi,
I'm not quite sure I understand this discussion, but I would like to remind you all of what Sean's original work is about:
Userspace configures DRM tracing into a flight recorder buffer (I guess this is what you refer to "instance-specific buffer").
Userspace runs happily for months, and then hits a problem: a failure in the DRM sub-system most likely, e.g. an ioctl that should never fail, failed. Userspace handles that failure by dumping the flight recorder buffer into a file and saving or sending a bug report. The flight recorder contents give a log of all relevant DRM in-kernel actions leading to the unexpected failure to help developers debug it.
I don't mind if one can additionally send the flight recorder stream to the main buffer, but I do want the separate flight recorder buffer to be an option so that a) unrelated things cannot flood the interesting bits out of it, and b) the scope of collected information is relevant.
The very reason for this work is problems that are very difficult to reproduce in practice, either because the problem itself is triggered very rarely and randomly, or because the end users of the system have either no knowledge or no access to reconfigure debug logging and then reproduce the problem with good debug logs.
Quoted 8 lines
Quoted 3 lines
Thank you very much for pushing this work forward!
So I think Vincent (earlier in the thread) was saying that he finds it very helpful have dynamic debug output go to the 'main' trace buffer, while you seem to be saying you'd prefer it just go to dynamic debug specific trace buffer.
Seems like we have different use cases: traditional debugging, and in-production flight recorder for problem reporting. I'm not surprised if they need different treatment.
Quoted 5 lines
So we certainly can have dynamic output potentially go to both places - although I think this would mean two tracepoints? But I really wonder if we really need a separate tracing buffer for dynamic debug when what goes to the 'main' buffer can be controlled and filtered to avoid your concern around a 'flood'?
If the DRM tracing goes into the main buffer, then systems in production cannot have any other sub-system traced in a similar fashion. To me it would feel very arrogant to say that to make use of DRM flight recording, you cannot trace much or anything else.
The very purpose of the flight recorder is run in production all the time, not in a special debugging session.
There is also the question of access and contents of the trace buffer. Ultimately, if automatic bug reports are enabled in a system, the contents of the trace buffer would be sent as-is to some bug tracking system. If there is a chance to put non-DRM stuff in the trace buffer, that could be a security problem.
My use case is Weston. When Weston encounters an unexpected problem in production, something should automatically capture the DRM flight recorder contents and save it alongside the Weston log. Would be really nice if Weston itself could do that, but I suspect it is going to need root privileges so it needs some helper daemon.
Quoted 6 lines
Maybe Sean can reiterate their use case more?
Thanks,
pqOk, so in this current thread the proposal was to create a "dyndbg-tracefs" buffer to put the dynamic debug output (including drm output from dynamic debug) into. And I was saying let's just put in the 'main' trace buffer (predicated on a dynamic debug specific tracepoint), since there seems to be a a use-case for that and it keeps things simpler.
Quoted 6 lines
But I went back to Sean's original patch, and it creates a drm specific trace buffer "drm" (via
trace_array_get_by_name("drm")). Here:
https://patchwork.freedesktop.org/patch/445549/?series=78133&rev=5So I think that may be some of the confusion here? The current thread/ proposal is not for a drm specific trace buffer...
Quoted 6 lines
Hi Jason,
I may very well have confused things, sorry about that. If this series is not superseding the idea of the DRM flight recorder, then don't mind me. It just sounded very similar and I also haven't seen new revisions of the flight recorder in a long time.
IMO this series has clarified the requirement for a flight-recorder mode, which seems to fit ideally in a separate instance.
Quoted 11 lines
Quoted 4 lines
Having a subsystem specific trace buffer would allow subsystem specific trace log permissions depending on the sensitivity of the data. But doesn't drm output today go to the system log which is typically world readable today?
Yes, and that is exactly the problem. The DRM debug output is so high traffic it would make the system log both unusable due to cruft and slow down the whole machine. The debug output is only useful when something went wrong, and at that point it is too late to enable debugging. That's why a flight recorder with an over-written circular in-memory buffer is needed.
Quoted 7 lines
Seans patch reuses enum
drm_debug_categoryto split the tracing stream into 10 sub-streams
- how much traffic from each ?
- are some sub-streams more valuable for post-mortem ?
- any value from further refinement of categories ?
- drop irrelevant callsites individually to reduce clutter, extend buffer time/space ?
I think it's hard to predict which sub-streams you are going to need before you have a bug to debug. Hence I would err on the side of enabling too much. This also means that better or more refined categorisation might not be that much of help - or if it is, then are the excluded debug messages worth having in the kernel to begin with. Well, we're probably not that interested in GPU debugs but just everything related to the KMS side, which on the existing categories is... everything except half of CORE and DRIVER, maybe? Not sure.
Maybe Sean has a better idea.
My feeling is that that could mean in the order of hundreds of log events at framerate (e.g. 60 times per second) per each enabled output individually. And per DRM device, of course. This is with the uninteresting GPU debugs already excluded.
Still, I don't think the flight recorder buffer would need to be massive. I suspect it would be enough to hold a few frames' worth which is just a split second under active operation. When something happens, the userspace stack is likely going to stop on its tracks immediately to collect the debug information, which means the flooding should pause and the relevant messages don't get overwritten before we get them. In a multi-seat system where each device is controlled by a separate display server instance, per-device logs would help with this. OTOH, multi-seat is not a very common use case I suppose.
Thanks,
pq
Re: [PATCH v10 08/10] dyndbg: add print-to-tracefs, selftest with it - RFC
First off, let me reiterate that this feature would be invaluable as user-space developers. It's often pretty difficult to figure out the cause of an EINVAL, we have to ask users to follow complicated instructions [1] to grab DRM logs. Then have to skim through several megabytes of logs to find the error.
I have a hack [2] which just calls system("sudo dmesg") after a failed atomic commit, it's been pretty handy. But it's really just a hack, a proper solution would be awesome.
[1]: https://gitlab.freedesktop.org/wlroots/wlroots/-/wikis/DRM-Debugging
[2]: https://gitlab.freedesktop.org/emersion/libliftoff/-/merge_requests/61
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Having a subsystem specific trace buffer would allow subsystem specific trace log permissions depending on the sensitivity of the data. But doesn't drm output today go to the system log which is typically world readable today?
dmesg isn't world-readable these days, it's been changed recently-ish (last year?) at least on my distribution (Arch). I need root to grab dmesg.
(Maybe we can we just let the DRM master process grab the logs?)
Quoted 15 lines
Quoted 7 lines
Quoted 6 lines
Yes, and that is exactly the problem. The DRM debug output is so high traffic it would make the system log both unusable due to cruft and slow down the whole machine. The debug output is only useful when something went wrong, and at that point it is too late to enable debugging. That's why a flight recorder with an over-written circular in-memory buffer is needed.
Quoted 7 lines
Seans patch reuses enum
drm_debug_categoryto split the tracing stream into 10 sub-streams
- how much traffic from each ?
- are some sub-streams more valuable for post-mortem ?
- any value from further refinement of categories ?
- drop irrelevant callsites individually to reduce clutter, extend buffer time/space ?
Quoted 8 lines
I think it's hard to predict which sub-streams you are going to need before you have a bug to debug. Hence I would err on the side of enabling too much. This also means that better or more refined categorisation might not be that much of help - or if it is, then are the excluded debug messages worth having in the kernel to begin with. Well, we're probably not that interested in GPU debugs but just everything related to the KMS side, which on the existing categories is... everything except half of CORE and DRIVER, maybe? Not sure.
We've been recommending drm.debug=0x19F so far (see wiki linked above). KMS + PRIME + ATOMIC + LEASE is definitely something we want in, and CORE + DRIVER contains other useful info. We definitely don't want VBL.
Quoted 4 lines
My feeling is that that could mean in the order of hundreds of log events at framerate (e.g. 60 times per second) per each enabled output individually. And per DRM device, of course. This is with the uninteresting GPU debugs already excluded.
Indeed, successful KMS atomic commits already generate a lot of noise. On my machine, setting drm.debug=0x19F and running the following command:
sudo dmesg -w | pv >/dev/null
I get 400KiB/s when idling, and 850KiB/s when wiggling the cursor.
Quoted 9 lines
Still, I don't think the flight recorder buffer would need to be massive. I suspect it would be enough to hold a few frames' worth which is just a split second under active operation. When something happens, the userspace stack is likely going to stop on its tracks immediately to collect the debug information, which means the flooding should pause and the relevant messages don't get overwritten before we get them. In a multi-seat system where each device is controlled by a separate display server instance, per-device logs would help with this. OTOH, multi-seat is not a very common use case I suppose.
There's also the case of multi-GPU where GPU B's logs could clutter GPU A's, making it harder to understand the cause of an atomic commit failure on GPU A. So per-device logs would be useful, but not a hard requirement for me, having *anything* at all would already be a big win.
In my experiments linked above [2], system("sudo dmesg") after atomic commit failure worked pretty well, and the bottom of the log contained the cause of the failure. It was pretty useful to system("sudo dmesg -C") before performing an atomic commit, to be able to only collect the extract of the log relevant to the atomic commit.
Having some kind of "marker" mechanism could be pretty cool. "Mark" the log stream before performing an atomic commit (ideally that'd just return e.g. an uint64 offset), then on failure request the logs collected after that mark.
[email protected]
maintainerRe: [PATCH v10 08/10] dyndbg: add print-to-tracefs, selftest with it - RFC
In reply to Vincent WhitchurchQuoted 29 lines · Vincent Whitchurch
Quoted 11 lines · Jim Cromie
Dynamic-Debug can do 2nd exceedingly well:
A- all work is behind jump-label's NOOP, zero off cost. B- exact site selectivity, precisely the useful traffic.
can tailor enabled set interactively, at shell.Since the tracefs interface is effective for drm (the threads suggest so), adding that interface to dynamic-debug has real potential for everyone including drm.
Add a new +T flag to enable tracing, independent of +p, and add and
I posted a patchset a while ago to do something very similar, but that got stalled for some reason and I unfortunately didn't follow it up:
https://lore.kernel.org/lkml/[email protected]/
A key difference between that patchset and this patch (besides that small fact that I used +x instead of +T) was that my patchset allowed the dyndbg trace to be emitted to the main buffer and did not force them to be in an instance-specific buffer.
That feature is quite important at least for my use case since I often use dyndbg combined with function tracing, and the latter doesn't work on non-main instances according to
Documentation/trace/ftrace.rst.
Quoted 6 lines
For example, here's a random example of a bootargs from one of my recent debugging sessions:
trace_event=printk:* ftrace_filter=_mmc*,mmc*,sd*,dw_mci*,mci* ftrace=function trace_buf_size=20M dyndbg="file
drivers/mmc/*+x"
Hi Vincent,
are you planning to dust this patchset off and resubmit it ?
Ive been playing with it and learning ftrace (decade+ late), I found your boot-line example very helpful as 1st steps (still havent even tried the filtering)
with these adjustments (voiced partly to test my understanding) I would support it, and rework my patchset to use it.
- change flag to -e, good mnemonics for event/trace-event T is good too, but uppercase, no need to go there.
- include/trace/events/dyndbg.h - separate file, not mixed with print.h dyndbg class, so trace_event=dyndbg:*
- 1 event type per pr_debug, dev_dbg, netdev_dbg ? ibdev_dbg ? with the extra args: descriptor that Steven wanted, probably also struct <|net|ib>dev
If youre too busy for a while, I'd eventually take a (slow) run at it.
Re: [PATCH v10 08/10] dyndbg: add print-to-tracefs, selftest with it - RFC
Quoted 7 lines · On Wed, Dec 08, 2021 at 06:16:10AM +0100, [email protected] wrote:
are you planning to dust this patchset off and resubmit it ?
Ive been playing with it and learning ftrace (decade+ late), I found your boot-line example very helpful as 1st steps (still havent even tried the filtering)
Quoted 5 lines
with these adjustments (voiced partly to test my understanding) I would support it, and rework my patchset to use it.
- change flag to -e, good mnemonics for event/trace-event T is good too, but uppercase, no need to go there.
Any flag name works for me.
Quoted 6 lines
-
include/trace/events/dyndbg.h- separate file, not mixed withprint.hdyndbg class, so trace_event=dyndbg:*- 1 event type per
pr_debug,dev_dbg,netdev_dbg?ibdev_dbg? with the extra args: descriptor that Steven wanted, probably also struct <|net|ib>dev
For my use cases I don't see much value in having separate events for the different debug functions, but since all of them can be easily enabled (dyndbg:*, as you noted), that works for me too.
Quoted 1 line
If youre too busy for a while, I'd eventually take a (slow) run at it.
You're welcome to have a go. I think you've already rebased the patchset, but here's a diff top of v5.16-rc4 for reference. I noticed a bug inside the CONFIG_JUMP_LABEL handling (also present in the last version I posted) which should be fixed as part of the diff below (I've added a comment). Proper tests for this, like the ones you are adding in your patchset, would certainly be a good idea. Thanks.
8<-------------
Documentation/admin-guide/dynamic-debug-howto.rst +1 -0
@@ -228,6 +228,7 @@ of the characters:: The flags are:: p enables the pr_debug() callsite. + x enables trace to the printk:dyndbg event f Include the function name in the printed message l Include line number in the printed message m Include module name in the printed message
include/linux/dynamic_debug.h +7 -4
@@ -27,7 +27,7 @@ struct _ddebug {* writes commands to <debugfs>/dynamic_debug/control */ #define _DPRINTK_FLAGS_NONE 0 -#define _DPRINTK_FLAGS_PRINT (1<<0)/* printk() a message using the format */ +#define _DPRINTK_FLAGS_PRINTK (1<<0)/* printk() a message using the format */ #define _DPRINTK_FLAGS_INCL_MODNAME (1<<1)#define _DPRINTK_FLAGS_INCL_FUNCNAME (1<<2)#define _DPRINTK_FLAGS_INCL_LINENO (1<<3)
@@ -37,8 +37,11 @@ struct _ddebug { (_DPRINTK_FLAGS_INCL_MODNAME | _DPRINTK_FLAGS_INCL_FUNCNAME |\ _DPRINTK_FLAGS_INCL_LINENO | _DPRINTK_FLAGS_INCL_TID) +#define _DPRINTK_FLAGS_TRACE (1<<5) +#define _DPRINTK_FLAGS_ENABLE (_DPRINTK_FLAGS_PRINTK | \ + _DPRINTK_FLAGS_TRACE)#if definedDEBUG -#define _DPRINTK_FLAGS_DEFAULT _DPRINTK_FLAGS_PRINT +#define _DPRINTK_FLAGS_DEFAULT _DPRINTK_FLAGS_PRINTK#else #define _DPRINTK_FLAGS_DEFAULT 0#endif
@@ -120,10 +123,10 @@ void __dynamic_ibdev_dbg(struct _ddebug *descriptor,#ifdef DEBUG #define DYNAMIC_DEBUG_BRANCH (descriptor) \ - likely(descriptor.flags & _DPRINTK_FLAGS_PRINT) + likely(descriptor.flags & _DPRINTK_FLAGS_ENABLE)#else #define DYNAMIC_DEBUG_BRANCH (descriptor) \ - unlikely(descriptor.flags & _DPRINTK_FLAGS_PRINT) + unlikely(descriptor.flags & _DPRINTK_FLAGS_ENABLE)#endif #endif /* CONFIG_JUMP_LABEL */
include/trace/events/printk.h +11 -1
@@ -7,7 +7,7 @@#include <linux/tracepoint.h> -TRACE_EVENT(console, +DECLARE_EVENT_CLASS(printk, TP_PROTO(const char *text, size_t len), TP_ARGS(text, len),
@@ -31,6 +31,16 @@ TRACE_EVENT(console,TP_printk ("%s" ,__get_str (msg)) ); + +DEFINE_EVENT (printk, console, + TP_PROTO(const char *text, size_t len), +TP_ARGS (text, len) +); + +DEFINE_EVENT (printk, dyndbg, + TP_PROTO(const char *text, size_t len), +TP_ARGS (text, len) +);#endif /* _TRACE_PRINTK_H */ /* This part must be outside protection */
lib/dynamic_debug.c +144 -29
262 lines not on this page · raw message
Jim Cromie
maintainerPATCH v10 9/10 dyndbg: create DEFINE_DYNAMIC_DEBUG_LOG|TRACE_GROUPS
In reply to Jim CromieWith the recent addition of pr_debug to tracefs via +T flag, we now want to add drm.trace; like its model: drm.debug, it maps bits to pr_debug categories, but this one enables/disables writing to tracefs (iff CONFIG_TRACING).
Do this by:
1. add flags to dyndbg_bitmap_param, holds "p" or "T" to work for either.
add DEFINE_DYNAMIC_DEBUG_BITGRPS_FLAGS to init .flags DEFINE_DYNAMIC_DEBUG_BITGRPS gets "p" for compat. use it from...
2. DEFINE_DYNAMIC_DEBUG_LOG_GROUPS as (1) with "p" flags - print to syslog DEFINE_DYNAMIC_DEBUG_TRACE_GROUPS as (1) with "T" flags - trace to tracefs add kdoc to these
NOTES
The flags args (1) is a string, not just a 'p' or 'T'. This allows use of decorator flags ("mflt") too, in case the module author wants to insure those decorations are in the trace & log.
The LOG|TRACE (2) macros don't use any decorator flags, (and therefore don't toggle them), allowing users to control those themselves.
Decorator flags are shared for both LOG and TRACE consumers, coordination between users is expected. ATM, theres no declarative way to preset decorator flags, but DEFINE_DYNAMIC_DEBUG_BITGRPS_FLAGS can be used to explicitly toggle them.
--- include/linux/dynamic_debug.h | 44 ++++++++++++++++++++++++++--------- lib/dynamic_debug.c | 4 ++-- 2 files changed, 35 insertions(+), 13 deletions(-)
include/linux/dynamic_debug.h +33 -11
@@ -255,30 +255,52 @@ struct dyndbg_bitdesc {struct dyndbg_bitmap_param {unsigned long *bits;/* ref to shared state */ +const char *flags;unsigned int maplen;struct dyndbg_bitdesc *map;/* indexed by bitpos */ };#if defined(CONFIG_DYNAMIC_DEBUG ) || \ (defined(CONFIG_DYNAMIC_DEBUG_CORE ) && defined(DYNAMIC_DEBUG_MODULE )) + +#define DEFINE_DYNAMIC_DEBUG_BITGRPS_FLAGS (fsname, _var, _flags, desc, data) \ + MODULE_PARM_DESC(fsname, desc); \ + static struct dyndbg_bitmap_param ddcats_##_var = \ + { .bits = &(_var), .flags = (_flags), \ + .map = data, .maplen = ARRAY_SIZE(data) }; \ + module_param_cb(fsname, ¶m_ops_dyndbg, &ddcats_##_var, 0644) + +#define DEFINE_DYNAMIC_DEBUG_BITGRPS (fsname, _var, desc, data) \ + DEFINE_DYNAMIC_DEBUG_BITGRPS_FLAGS(fsname, _var, "p", desc, data) +/** -* DEFINE_DYNAMIC_DEBUG_BITGRPS() - bitmap control of pr_debugs, by format match +* DEFINE_DYNAMIC_DEBUG_LOG_GROUPS() - bitmap control of grouped pr_debugs --> syslog +* * @fsname: parameter basename under /sys * @_var: C-identifier holding bitmap * @desc: string summarizing the controls provided * @bitmap: C array of struct dyndbg_bitdescs * -* Intended for modules with a systematic use of pr_debug prefixes in -* the format strings, this allows modules calling pr_debugs to -* control them in groups by matching against their formats, and map -* them to bits 0-N of a sysfs control point. +* Intended for modules having pr_debugs with prefixed/categorized +* formats; this lets you group them by substring match, map groups to +* bits, and enable per group to write to syslog, via @fsname. */ -#define DEFINE_DYNAMIC_DEBUG_BITGRPS (fsname, _var, desc, data) \ - MODULE_PARM_DESC(fsname, desc); \ - static struct dyndbg_bitmap_param ddcats_##_var = \ - { .bits = &(_var), .map = data, \ - .maplen = ARRAY_SIZE(data) }; \ - module_param_cb(fsname, ¶m_ops_dyndbg, &ddcats_##_var, 0644) +#define DEFINE_DYNAMIC_DEBUG_LOG_GROUPS (fsname, _var, desc, data) \ + DEFINE_DYNAMIC_DEBUG_BITGRPS_FLAGS(fsname, _var, "p", desc, data) + +/** +* DEFINE_DYNAMIC_DEBUG_TRACE_GROUPS() - bitmap control of pr_debugs --> tracefs +* @fsname: parameter basename under /sys +* @_var: C-identifier holding bitmap +* @desc: string summarizing the controls provided +* @bitmap: C array of struct dyndbg_bitdescs +* +* Intended for modules having pr_debugs with prefixed/categorized +* formats; this lets you group them by substring match, map groups to +* bits, and enable per group to write to tracebuf, via @fsname. +*/ +#define DEFINE_DYNAMIC_DEBUG_TRACE_GROUPS (fsname, _var, desc, data) \ + DEFINE_DYNAMIC_DEBUG_BITGRPS_FLAGS(fsname, _var, "T", desc, data)extern const struct kernel_param_ops param_ops_dyndbg;
lib/dynamic_debug.c +2 -2
@@ -634,8 +634,8 @@ int param_set_dyndbg(const char *instr, const struct kernel_param *kp)for (i =0 ; i < p->maplen && i <BITS_PER_LONG ; map++, i++) {if (test_bit (i, &inbits) ==test_bit (i, p->bits))continue ; -snprintf (query,FMT_QUERY_SIZE ,"format '%s' %cp" , map->match, -test_bit (i, &inbits) ?'+' :'-' ); +snprintf (query,FMT_QUERY_SIZE ,"format '%s' %c%s" , map->match, +test_bit (i, &inbits) ?'+' :'-' , p->flags); matches =ddebug_exec_queries (query,KP_MOD_NAME );
Signature · 1 line
2.31.1
Jim Cromie
maintainerPATCH v10 10/10 drm: use DEFINE_DYNAMIC_DEBUG_TRACE_GROUPS in 3 places
In reply to Jim Cromieadd sysfs knobs to enable modules' pr_debug()s ---> tracefs
--- drivers/gpu/drm/amd/display/dc/core/dc_debug.c | 8 ++++++++ drivers/gpu/drm/drm_print.c | 13 ++++++++++--- drivers/gpu/drm/i915/intel_gvt.c | 15 ++++++++++++--- 3 files changed, 30 insertions(+), 6 deletions(-)
drivers/gpu/drm/amd/display/dc/core/dc_debug.c +8 -0
@@ -80,6 +80,14 @@ DEFINE_DYNAMIC_DEBUG_LOG_GROUPS(debug_dc, __debug_dc,DC_DYNDBG_BITMAP_DESC (debug_dc), amdgpu_bitmap); +#if defined(CONFIG_TRACING ) + +unsigned long __trace_dc; +EXPORT_SYMBOL (__trace_dc); +DEFINE_DYNAMIC_DEBUG_LOG_GROUPS (trace_dc, __trace_dc, +DC_DYNDBG_BITMAP_DESC (trace_dc), + amdgpu_bitmap); +#endif #endif #define DC_LOGGER_INIT (logger)
drivers/gpu/drm/drm_print.c +10 -3
@@ -72,9 +72,16 @@ static struct dyndbg_bitdesc drm_dyndbg_bitmap[] = { [8] = { DRM_DBG_CAT_DP }, [9] = { DRM_DBG_CAT_DRMRES } }; -DEFINE_DYNAMIC_DEBUG_BITGRPS (debug, __drm_debug,DRM_DEBUG_DESC , - drm_dyndbg_bitmap); - +DEFINE_DYNAMIC_DEBUG_LOG_GROUPS (debug, __drm_debug,DRM_DEBUG_DESC , + drm_dyndbg_bitmap); + +#ifdef CONFIG_TRACING +struct trace_array *trace_arr; +unsigned long __drm_trace; +EXPORT_SYMBOL (__drm_trace); +DEFINE_DYNAMIC_DEBUG_TRACE_GROUPS (trace, __drm_trace,DRM_DEBUG_DESC , + drm_dyndbg_bitmap); +#endif #endif void __drm_puts_coredump (struct drm_printer *p,const char *str)
drivers/gpu/drm/i915/intel_gvt.c +12 -3
@@ -195,8 +195,17 @@ static struct dyndbg_bitdesc i915_dyndbg_bitmap[] = { help_(7, "gvt:render:") \ help_(8, "gvt:sched:") -DEFINE_DYNAMIC_DEBUG_BITGRPS (debug_gvt, __gvt_debug, -I915_GVT_CATEGORIES (debug_gvt), - i915_dyndbg_bitmap); +DEFINE_DYNAMIC_DEBUG_LOG_GROUPS (debug_gvt, __gvt_debug, +I915_GVT_CATEGORIES (debug_gvt), + i915_dyndbg_bitmap); +#if defined(CONFIG_TRACING ) + +unsigned long __gvt_trace; +EXPORT_SYMBOL (__gvt_trace); +DEFINE_DYNAMIC_DEBUG_TRACE_GROUPS (trace_gvt, __gvt_trace, +I915_GVT_CATEGORIES (trace_gvt), + i915_dyndbg_bitmap); + +#endif #endif
Signature · 1 line
2.31.1
Patchwork
CI[Intel-gfx] ✗ Fi.CI.BUILD: failure for use DYNAMIC_DEBUG to implement DRM.debug & DRM.trace (rev3)
In reply to Jim Cromie== Series Details ==
== Series Details ==
Series: use DYNAMIC_DEBUG to implement DRM.debug & DRM.trace (rev3)
URL : https://patchwork.freedesktop.org/series/96327/
State : failure
== Summary ==
Patch is empty.
When you have resolved this problem, run "git am --continue". If you prefer to skip this patch, run "git am --skip" instead. To restore the original branch and stop patching, run "git am --abort".
Patchwork
CI[Intel-gfx] ✗ Fi.CI.BUILD: failure for use DYNAMIC_DEBUG to implement DRM.debug & DRM.trace (rev4)
In reply to Jim Cromie== Series Details ==
== Series Details ==
Series: use DYNAMIC_DEBUG to implement DRM.debug & DRM.trace (rev4)
URL : https://patchwork.freedesktop.org/series/96327/
State : failure
== Summary ==
Patch is empty.
When you have resolved this problem, run "git am --continue". If you prefer to skip this patch, run "git am --skip" instead. To restore the original branch and stop patching, run "git am --abort".