From: Jim Cromie <jim.cromie@gmail.com>
To: jbaron@akamai.com, gregkh@linuxfoundation.org,
linux-kernel@vger.kernel.org, linux@rasmusvillemoes.dk,
daniel.vetter@ffwll.ch, seanpaul@chromium.org,
dri-devel@lists.freedesktop.org, amd-gfx@lists.freedesktop.org,
intel-gvt-dev@lists.freedesktop.org,
intel-gfx@lists.freedesktop.org
Cc: Jim Cromie <jim.cromie@gmail.com>
Subject: [PATCH v9 09/10] dyndbg: create DEFINE_DYNAMIC_DEBUG_TRACE_CATEGORIES
Date: Tue, 26 Oct 2021 22:36:44 -0600 [thread overview]
Message-ID: <20211027043645.153133-10-jim.cromie@gmail.com> (raw)
In-Reply-To: <20211027043645.153133-1-jim.cromie@gmail.com>
clone DEFINE_DYNAMIC_DEBUG_CATEGORIES interface to enable pr_debug
output to tracefs.
Extend DEFINE_DYNAMIC_DEBUG_CATEGORIES to work for tracing, by
renaming it (with _FLAGS suffix), adding _flags param, and using it
2x; in original and new names, with "p" and "T" flags respectively.
TODO: rethink this, consider combined trace/debug declaration.
good: single bitmap-spec for both trace,debug, no chance of divergence.
bad: arg-type & count checks are hard, and bitmap follows too!
to combine both, we need 4 args:
sysfs_debug_name, __debug_var
sysfs_trace_name, __trace_var // these may be NULL, IFF !CONFIG_TRACE ??
then a bitmap:
[0] = { "category1" }, ...)
My BUILD_BUG-fu is insufficient to protect a naive macro.
Signed-off-by: Jim Cromie <jim.cromie@gmail.com>
---
include/linux/dynamic_debug.h | 19 ++++++++++++++-----
lib/dynamic_debug.c | 4 ++--
2 files changed, 16 insertions(+), 7 deletions(-)
diff --git a/include/linux/dynamic_debug.h b/include/linux/dynamic_debug.h
index 896848f546e6..f273ba82cbb0 100644
--- a/include/linux/dynamic_debug.h
+++ b/include/linux/dynamic_debug.h
@@ -254,11 +254,20 @@ struct dyndbg_bitdesc {
struct dyndbg_bitmap_param {
unsigned long *bits; /* ref to shared state */
+ const char *flags;
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_CATEGORIES_FLAGS(fsname, _var, _flags, desc, ...) \
+ MODULE_PARM_DESC(fsname, desc); \
+ static struct dyndbg_bitmap_param ddcats_##_var = \
+ { .bits = &(_var), .flags = (_flags), \
+ .map = { __VA_ARGS__, { .match = NULL }}}; \
+ module_param_cb(fsname, ¶m_ops_dyndbg, &ddcats_##_var, 0644)
+
/**
* DEFINE_DYNAMIC_DEBUG_CATEGORIES() - bitmap control of categorized pr_debugs
* @fsname: parameter basename under /sys
@@ -271,11 +280,11 @@ struct dyndbg_bitmap_param {
* modules calling pr_debugs to control them in groups according to
* those prefixes, and map them to bits 0-N of a sysfs control point.
*/
-#define DEFINE_DYNAMIC_DEBUG_CATEGORIES(fsname, _var, desc, ...) \
- MODULE_PARM_DESC(fsname, desc); \
- static struct dyndbg_bitmap_param ddcats_##_var = \
- { .bits = &(_var), .map = { __VA_ARGS__, { .match = NULL }}}; \
- module_param_cb(fsname, ¶m_ops_dyndbg, &ddcats_##_var, 0644)
+#define DEFINE_DYNAMIC_DEBUG_CATEGORIES(fsname, _var, desc, ...) \
+ DEFINE_DYNAMIC_DEBUG_CATEGORIES_FLAGS(fsname, _var, "p", desc, ##__VA_ARGS__)
+
+#define DEFINE_DYNAMIC_DEBUG_TRACE_CATEGORIES(fsname, _var, desc, ...) \
+ DEFINE_DYNAMIC_DEBUG_CATEGORIES_FLAGS(fsname, _var, "T", desc, ##__VA_ARGS__)
extern const struct kernel_param_ops param_ops_dyndbg;
diff --git a/lib/dynamic_debug.c b/lib/dynamic_debug.c
index f19465b114cd..b4146178780f 100644
--- a/lib/dynamic_debug.c
+++ b/lib/dynamic_debug.c
@@ -629,8 +629,8 @@ int param_set_dyndbg(const char *instr, const struct kernel_param *kp)
for (i = 0; map->match && 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);
--
2.31.1
next prev parent reply other threads:[~2021-10-27 4:37 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-10-27 4:36 [PATCH v9 00/10] use DYNAMIC_DEBUG to implement DRM.debug & DRM.trace Jim Cromie
2021-10-27 4:36 ` [PATCH v9 01/10] dyndbg: add DEFINE_DYNAMIC_DEBUG_CATEGORIES macro and callbacks Jim Cromie
2021-10-27 4:36 ` [PATCH v9 02/10] drm: fix doc grammar Jim Cromie
2021-10-27 4:36 ` [PATCH v9 03/10] amdgpu: use dyndbg.CATEGORIES to control existing pr_dbgs Jim Cromie
2021-10-27 4:36 ` [PATCH v9 04/10] i915/gvt: trim spaces from pr_debug "gvt: core:" prefixes Jim Cromie
2021-10-27 4:36 ` [PATCH v9 05/10] i915/gvt: use dyndbg.CATEGORIES for existing pr_debugs Jim Cromie
2021-10-27 4:36 ` [PATCH v9 06/10] drm_print: add choice to use dynamic debug in drm-debug Jim Cromie
2021-10-27 4:36 ` [PATCH v9 07/10] drm_print: instrument drm_debug_enabled Jim Cromie
2021-10-27 4:36 ` [PATCH v9 08/10] dyndbg: add print-to-tracefs, selftest with it - RFC Jim Cromie
2021-10-27 4:36 ` Jim Cromie [this message]
2021-10-27 4:36 ` [PATCH v9 10/10] drm: use DEFINE_DYNAMIC_DEBUG_TRACE_CATEGORIES bitmap to tracefs Jim Cromie
2021-11-03 15:58 ` Jason Baron
2021-11-04 6:31 ` jim.cromie
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20211027043645.153133-10-jim.cromie@gmail.com \
--to=jim.cromie@gmail.com \
--cc=amd-gfx@lists.freedesktop.org \
--cc=daniel.vetter@ffwll.ch \
--cc=dri-devel@lists.freedesktop.org \
--cc=gregkh@linuxfoundation.org \
--cc=intel-gfx@lists.freedesktop.org \
--cc=intel-gvt-dev@lists.freedesktop.org \
--cc=jbaron@akamai.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@rasmusvillemoes.dk \
--cc=seanpaul@chromium.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®