linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jim Cromie <jim.cromie@gmail.com>
To: jbaron@akamai.com, linux-kernel@vger.kernel.org,
	dri-devel@lists.freedesktop.org, amd-gfx@lists.freedesktop.org,
	intel-gvt-dev@lists.freedesktop.org,
	intel-gfx@lists.freedesktop.org
Cc: gregkh@linuxfoundation.org, daniel.vetter@ffwll.ch,
	seanpaul@chromium.org, robdclark@gmail.com, rostedt@goodmis.org,
	mathieu.desnoyers@efficios.com, quic_saipraka@quicinc.com,
	will@kernel.org, catalin.marinas@arm.com,
	quic_psodagud@quicinc.com, maz@kernel.org, arnd@arndb.de,
	linux-arm-kernel@lists.infradead.org,
	linux-arm-msm@vger.kernel.org, mingo@redhat.com,
	jim.cromie@gmail.com
Subject: [PATCH v2 05/27] dyndbg: add exclusive class_id to pr_debug callsites
Date: Mon, 16 May 2022 16:56:18 -0600	[thread overview]
Message-ID: <20220516225640.3102269-6-jim.cromie@gmail.com> (raw)
In-Reply-To: <20220516225640.3102269-1-jim.cromie@gmail.com>

DRM issues ~10 exclusive categories of debug messages; to represent
this directly in dyndbg, add a new field: struct _ddebug.class_id:5.

We only need 4 bits for drm, and with that reserved, we have 2 to
spare on 32 bit builds; lets take one extra (5 bits total), and keep a
spare bit.  32 classes-per-bitmap is a practical usability limit
anyway with a bitmap interface:

  #> echo 0x012345678 > /sys/module/drm/parameters/debug

All existing callsites are initialized with _DPRINTK_CLASS_DFLT, which
is 2^5-1.  This reserves 0-30 for use in new categorized/class'd
pr_debugs, which fits perfectly with natural enums (ints: 0..N).

To achieve this, DEFINE_DYNAMIC_DEBUG_METADATA_CLS(cls,...) is added,
and DEFINE_DYNAMIC_DEBUG_METADATA is altered to call it with the
default.  The factory macro chain between there and pr_debug is
adjusted similarly.

No behavior change.

Signed-off-by: Jim Cromie <jim.cromie@gmail.com>
---
 include/linux/dynamic_debug.h | 54 ++++++++++++++++++++++++++---------
 1 file changed, 41 insertions(+), 13 deletions(-)

diff --git a/include/linux/dynamic_debug.h b/include/linux/dynamic_debug.h
index dd20e825c36f..39550fefcf0f 100644
--- a/include/linux/dynamic_debug.h
+++ b/include/linux/dynamic_debug.h
@@ -6,6 +6,8 @@
 #include <linux/jump_label.h>
 #endif
 
+#include <linux/build_bug.h>
+
 /*
  * An instance of this structure is created in a special
  * ELF section at every dynamic debug callsite.  At runtime,
@@ -21,6 +23,9 @@ struct _ddebug {
 	const char *filename;
 	const char *format;
 	unsigned int lineno:18;
+#define CLS_BITS 5
+	unsigned int class_id:CLS_BITS;
+#define _DPRINTK_CLASS_DFLT		((1 << CLS_BITS) - 1)
 	/*
 	 * The flags field controls the behaviour at the callsite.
 	 * The bits here are changed dynamically when the user
@@ -84,7 +89,7 @@ void __dynamic_ibdev_dbg(struct _ddebug *descriptor,
 			 const struct ib_device *ibdev,
 			 const char *fmt, ...);
 
-#define DEFINE_DYNAMIC_DEBUG_METADATA(name, fmt)		\
+#define DEFINE_DYNAMIC_DEBUG_METADATA_CLS(name, cls, fmt)	\
 	static struct _ddebug  __aligned(8)			\
 	__section("__dyndbg") name = {				\
 		.modname = KBUILD_MODNAME,			\
@@ -93,8 +98,14 @@ void __dynamic_ibdev_dbg(struct _ddebug *descriptor,
 		.format = (fmt),				\
 		.lineno = __LINE__,				\
 		.flags = _DPRINTK_FLAGS_DEFAULT,		\
+		.class_id = cls,				\
 		_DPRINTK_KEY_INIT				\
-	}
+	};							\
+	BUILD_BUG_ON_MSG(cls > _DPRINTK_CLASS_DFLT,		\
+			 "classid value overflow")
+
+#define DEFINE_DYNAMIC_DEBUG_METADATA(name, fmt)		\
+	DEFINE_DYNAMIC_DEBUG_METADATA_CLS(name, _DPRINTK_CLASS_DFLT, fmt)
 
 #ifdef CONFIG_JUMP_LABEL
 
@@ -125,18 +136,26 @@ void __dynamic_ibdev_dbg(struct _ddebug *descriptor,
 
 #endif /* CONFIG_JUMP_LABEL */
 
-#define __dynamic_func_call(id, fmt, func, ...) do {	\
-	DEFINE_DYNAMIC_DEBUG_METADATA(id, fmt);		\
-	if (DYNAMIC_DEBUG_BRANCH(id))			\
-		func(&id, ##__VA_ARGS__);		\
+#define __dynamic_func_call_cls(id, cls, fmt, func, ...) do {	\
+	DEFINE_DYNAMIC_DEBUG_METADATA_CLS(id, cls, fmt);	\
+	if (DYNAMIC_DEBUG_BRANCH(id))				\
+		func(&id, ##__VA_ARGS__);			\
 } while (0)
 
-#define __dynamic_func_call_no_desc(id, fmt, func, ...) do {	\
-	DEFINE_DYNAMIC_DEBUG_METADATA(id, fmt);			\
-	if (DYNAMIC_DEBUG_BRANCH(id))				\
-		func(__VA_ARGS__);				\
+#define __dynamic_func_call_no_desc_cls(id, cls, fmt, func, ...) do {	\
+	DEFINE_DYNAMIC_DEBUG_METADATA_CLS(id, cls, fmt);		\
+	if (DYNAMIC_DEBUG_BRANCH(id))					\
+		func(__VA_ARGS__);					\
 } while (0)
 
+#define __dynamic_func_call(id, fmt, func, ...)				\
+	__dynamic_func_call_cls(id, _DPRINTK_CLASS_DFLT,		\
+				fmt, func, ##__VA_ARGS__)
+
+#define __dynamic_func_call_no_desc(id, fmt, func, ...)			\
+	__dynamic_func_call_no_desc_cls(id, _DPRINTK_CLASS_DFLT,	\
+					fmt, func, ##__VA_ARGS__)
+
 /*
  * "Factory macro" for generating a call to func, guarded by a
  * DYNAMIC_DEBUG_BRANCH. The dynamic debug descriptor will be
@@ -145,15 +164,24 @@ void __dynamic_ibdev_dbg(struct _ddebug *descriptor,
  * the varargs. Note that fmt is repeated in invocations of this
  * macro.
  */
+#define _dynamic_func_call_cls(cls, fmt, func, ...)			\
+	__dynamic_func_call_cls(__UNIQUE_ID(ddebug), cls, fmt, func, ##__VA_ARGS__)
 #define _dynamic_func_call(fmt, func, ...)				\
-	__dynamic_func_call(__UNIQUE_ID(ddebug), fmt, func, ##__VA_ARGS__)
+	_dynamic_func_call_cls(_DPRINTK_CLASS_DFLT, fmt, func, ##__VA_ARGS__)
+
 /*
  * A variant that does the same, except that the descriptor is not
  * passed as the first argument to the function; it is only called
  * with precisely the macro's varargs.
  */
-#define _dynamic_func_call_no_desc(fmt, func, ...)	\
-	__dynamic_func_call_no_desc(__UNIQUE_ID(ddebug), fmt, func, ##__VA_ARGS__)
+#define _dynamic_func_call_no_desc_cls(fmt, cat, func, ...)		\
+	__dynamic_func_call_no_desc_cls(__UNIQUE_ID(ddebug), cat,	\
+					fmt, func, ##__VA_ARGS__)
+
+#define _dynamic_func_call_no_desc(fmt, func, ...)			\
+	__dynamic_func_call_no_desc_cls(__UNIQUE_ID(ddebug),		\
+					_DPRINTK_CLASS_DFLT,	\
+					fmt, func, ##__VA_ARGS__)
 
 #define dynamic_pr_debug(fmt, ...)				\
 	_dynamic_func_call(fmt,	__dynamic_pr_debug,		\
-- 
2.35.3


  parent reply	other threads:[~2022-05-16 22:57 UTC|newest]

Thread overview: 31+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-05-16 22:56 [RFC PATCH v2 00/27] DRM.debug on DYNAMIC_DEBUG, add trace events Jim Cromie
2022-05-16 22:56 ` [PATCH v2 01/27] dyndbg: fix static_branch manipulation Jim Cromie
2022-05-16 22:56 ` [PATCH v2 02/27] dyndbg: show both old and new in change-info Jim Cromie
2022-05-16 22:56 ` [PATCH v2 03/27] dyndbg: fix module.dyndbg handling Jim Cromie
2022-05-16 22:56 ` [PATCH v2 04/27] dyndbg: drop EXPORTed dynamic_debug_exec_queries Jim Cromie
2022-05-16 22:56 ` Jim Cromie [this message]
2022-05-16 22:56 ` [PATCH v2 06/27] dyndbg: add dynamic_debug_(un)register_classes Jim Cromie
2022-05-16 22:56 ` [PATCH v2 07/27] dyndbg: validate class FOO on module Jim Cromie
2022-05-16 22:56 ` [PATCH v2 08/27] dyndbg: add drm.debug style bitmap support Jim Cromie
2022-05-16 22:56 ` [PATCH v2 09/27] Doc/dyndbg: document new class class_name query support Jim Cromie
2022-05-16 22:56 ` [PATCH v2 10/27] dyndbg: let query-modname override defaulting modname Jim Cromie
2022-05-16 22:56 ` [PATCH v2 11/27] dyndbg: support symbolic class-names in bitmap Jim Cromie
2022-05-16 22:56 ` [PATCH v2 12/27] dyndbg: change zero-or-one classes-map to maps list Jim Cromie
2022-05-16 22:56 ` [PATCH v2 13/27] dyndbg: add __pr_debug_cls(class, fmt, ...) Jim Cromie
2022-05-16 22:56 ` [PATCH v2 14/27] dyndbg: add test_dynamic_debug module Jim Cromie
2022-05-16 22:56 ` [PATCH v2 15/27] drm: POC drm on dyndbg - map class-names to drm_debug_category's Jim Cromie
2022-05-16 22:56 ` [PATCH v2 16/27] drm/print: POC drm on dyndbg - use bitmap Jim Cromie
2022-05-16 22:56 ` [PATCH v2 17/27] drm_print: condense enum drm_debug_category Jim Cromie
2022-05-16 22:56 ` [PATCH v2 18/27] drm_print: interpose drm_*dbg with forwarding macros Jim Cromie
2022-05-16 22:56 ` [PATCH v2 19/27] drm_print: wrap drm_*_dbg in dyndbg descriptor factory macro Jim Cromie
2022-05-16 22:56 ` [PATCH v2 20/27] drm_print: refine drm_debug_enabled for jump-label Jim Cromie
2022-05-16 22:56 ` [PATCH v2 21/27] drm_print: prefer bare printk KERN_DEBUG on generic fn Jim Cromie
2022-05-16 22:56 ` [PATCH v2 22/27] drm_print: add _ddebug desc to drm_*dbg prototypes Jim Cromie
2022-05-16 22:56 ` [PATCH v2 23/27] dyndbg: add _DPRINTK_FLAGS_ENABLED Jim Cromie
2022-05-16 22:56 ` [PATCH v2 24/27] dyndbg: add _DPRINTK_FLAGS_TRACE Jim Cromie
2022-05-16 22:56 ` [PATCH v2 25/27] dyndbg: add write-events-to-tracefs code Jim Cromie
2022-05-16 22:56 ` [PATCH v2 26/27] dyndbg: 4 new trace-events: pr_debug, dev_dbg, drm_{,dev}debug Jim Cromie
2022-06-29 20:30   ` Steven Rostedt
2022-05-16 22:56 ` [PATCH v2 27/27] dyndbg/drm: POC add tracebits sysfs-knob Jim Cromie
2022-05-25 15:02 ` [RFC PATCH v2 00/27] DRM.debug on DYNAMIC_DEBUG, add trace events Daniel Vetter
     [not found]   ` <CAJfuBxzQPeYvpzd_=WkQasKJceHrUYK8umG6gWbTmoAUfApJ8w@mail.gmail.com>
2022-06-08 15:56     ` Daniel Vetter

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=20220516225640.3102269-6-jim.cromie@gmail.com \
    --to=jim.cromie@gmail.com \
    --cc=amd-gfx@lists.freedesktop.org \
    --cc=arnd@arndb.de \
    --cc=catalin.marinas@arm.com \
    --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-arm-kernel@lists.infradead.org \
    --cc=linux-arm-msm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mathieu.desnoyers@efficios.com \
    --cc=maz@kernel.org \
    --cc=mingo@redhat.com \
    --cc=quic_psodagud@quicinc.com \
    --cc=quic_saipraka@quicinc.com \
    --cc=robdclark@gmail.com \
    --cc=rostedt@goodmis.org \
    --cc=seanpaul@chromium.org \
    --cc=will@kernel.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;
as well as URLs for NNTP newsgroup(s).