All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jim Cromie <jim.cromie@gmail.com>
To: linux-kernel@vger.kernel.org, jbaron@akamai.com,
	gregkh@linuxfoundation.org
Cc: david@redhat.com, lb@semihalf.com, linux@rasmusvillemoes.dk,
	joe@perches.com, mcgrof@kernel.org, Liam.Howlett@Oracle.com,
	linux-mm@kvack.org, Jim Cromie <jim.cromie@gmail.com>
Subject: [RFC PATCH 01/10] dyndbg: prep to isolate 3 repetetive fields
Date: Thu, 12 Oct 2023 13:48:25 -0600	[thread overview]
Message-ID: <20231012194834.3288085-2-jim.cromie@gmail.com> (raw)
In-Reply-To: <20231012194834.3288085-1-jim.cromie@gmail.com>

Move 3 fields: modname, filename, function into an anonymous struct,
and rename with '_' prefix to catch stale uses.

Add 3 desc_*() macros to abstract the field refs.

Add DYNAMIC_DEBUG_SITE_INIT() to initialize the fields.

no functional change.

Signed-off-by: Jim Cromie <jim.cromie@gmail.com>
---
 include/linux/dynamic_debug.h | 22 ++++++++++++++++------
 lib/dynamic_debug.c           | 28 ++++++++++++++--------------
 2 files changed, 30 insertions(+), 20 deletions(-)

diff --git a/include/linux/dynamic_debug.h b/include/linux/dynamic_debug.h
index 2237d454bc19..aacfafc466c0 100644
--- a/include/linux/dynamic_debug.h
+++ b/include/linux/dynamic_debug.h
@@ -13,14 +13,17 @@
  * ELF section at every dynamic debug callsite.  At runtime,
  * the special section is treated as an array of these.
  */
+
 struct _ddebug {
 	/*
 	 * These fields are used to drive the user interface
 	 * for selecting and displaying debug callsites.
 	 */
-	const char *modname;
-	const char *function;
-	const char *filename;
+	struct /* _ddebug_site */ {
+		const char *_modname;
+		const char *_function;
+		const char *_filename;
+	};
 	const char *format;
 	unsigned int lineno:18;
 #define CLS_BITS 6
@@ -61,6 +64,10 @@ struct _ddebug {
 #endif
 } __attribute__((aligned(8)));
 
+#define desc_modname(d)		(d)->modname
+#define desc_filename(d)	(d)->filename
+#define desc_function(d)	(d)->function
+
 enum ddebug_class_map_type {
 	DD_CLASS_TYPE_DISJOINT_BITS,
 	/**
@@ -213,12 +220,15 @@ void __dynamic_ibdev_dbg(struct _ddebug *descriptor,
 			 const struct ib_device *ibdev,
 			 const char *fmt, ...);
 
+#define DYNAMIC_DEBUG_SITE_INIT()			\
+	._modname = KBUILD_MODNAME,			\
+	._function = __func__,				\
+	._filename = __FILE__
+
 #define DEFINE_DYNAMIC_DEBUG_METADATA_CLS(name, cls, fmt)	\
 	static struct _ddebug  __aligned(8)			\
 	__section("__dyndbg") name = {				\
-		.modname = KBUILD_MODNAME,			\
-		.function = __func__,				\
-		.filename = __FILE__,				\
+		DYNAMIC_DEBUG_SITE_INIT(),			\
 		.format = (fmt),				\
 		.lineno = __LINE__,				\
 		.flags = _DPRINTK_FLAGS_DEFAULT,		\
diff --git a/lib/dynamic_debug.c b/lib/dynamic_debug.c
index 3dc512fb1d66..c0e595483cb9 100644
--- a/lib/dynamic_debug.c
+++ b/lib/dynamic_debug.c
@@ -235,16 +235,16 @@ static int ddebug_change(const struct ddebug_query *query,
 
 			/* match against the source filename */
 			if (query->filename &&
-			    !match_wildcard(query->filename, dp->filename) &&
+			    !match_wildcard(query->filename, desc_filename(dp)) &&
 			    !match_wildcard(query->filename,
-					   kbasename(dp->filename)) &&
+					    kbasename(desc_filename(dp))) &&
 			    !match_wildcard(query->filename,
-					   trim_prefix(dp->filename)))
+					    trim_prefix(desc_filename(dp))))
 				continue;
 
 			/* match against the function */
 			if (query->function &&
-			    !match_wildcard(query->function, dp->function))
+			    !match_wildcard(query->function, desc_function(dp)))
 				continue;
 
 			/* match against the format */
@@ -281,8 +281,8 @@ static int ddebug_change(const struct ddebug_query *query,
 			}
 #endif
 			v4pr_info("changed %s:%d [%s]%s %s => %s\n",
-				  trim_prefix(dp->filename), dp->lineno,
-				  dt->mod_name, dp->function,
+				  trim_prefix(desc_filename(dp)), dp->lineno,
+				  dt->mod_name, desc_function(dp),
 				  ddebug_describe_flags(dp->flags, &fbuf),
 				  ddebug_describe_flags(newflags, &nbuf));
 			dp->flags = newflags;
@@ -781,13 +781,13 @@ static int __dynamic_emit_prefix(const struct _ddebug *desc, char *buf, int pos)
 {
 	if (desc->flags & _DPRINTK_FLAGS_INCL_MODNAME)
 		pos += snprintf(buf + pos, remaining(pos), "%s:",
-				desc->modname);
+				desc_modname(desc));
 	if (desc->flags & _DPRINTK_FLAGS_INCL_FUNCNAME)
 		pos += snprintf(buf + pos, remaining(pos), "%s:",
-				desc->function);
+				desc_function(desc));
 	if (desc->flags & _DPRINTK_FLAGS_INCL_SOURCENAME)
 		pos += snprintf(buf + pos, remaining(pos), "%s:",
-				trim_prefix(desc->filename));
+				trim_prefix(desc_filename(desc)));
 	return pos;
 }
 
@@ -1110,8 +1110,8 @@ static int ddebug_proc_show(struct seq_file *m, void *p)
 	}
 
 	seq_printf(m, "%s:%u [%s]%s =%s \"",
-		   trim_prefix(dp->filename), dp->lineno,
-		   iter->table->mod_name, dp->function,
+		   trim_prefix(desc_filename(dp)), dp->lineno,
+		   iter->table->mod_name, desc_function(dp),
 		   ddebug_describe_flags(dp->flags, &flags));
 	seq_escape_str(m, dp->format, ESCAPE_SPACE, "\t\r\n\"");
 	seq_puts(m, "\"");
@@ -1528,12 +1528,12 @@ static int __init dynamic_debug_init(void)
 	}
 
 	iter = iter_mod_start = __start___dyndbg;
-	modname = iter->modname;
+	modname = desc_modname(iter);
 	i = mod_sites = mod_ct = 0;
 
 	for (; iter < __stop___dyndbg; iter++, i++, mod_sites++) {
 
-		if (strcmp(modname, iter->modname)) {
+		if (strcmp(modname, desc_modname(iter))) {
 			mod_ct++;
 			di.num_descs = mod_sites;
 			di.descs = iter_mod_start;
@@ -1542,7 +1542,7 @@ static int __init dynamic_debug_init(void)
 				goto out_err;
 
 			mod_sites = 0;
-			modname = iter->modname;
+			modname = desc_modname(iter);
 			iter_mod_start = iter;
 		}
 	}
-- 
2.41.0


  reply	other threads:[~2023-10-12 19:49 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-10-12 19:48 [RFC PATCH 00/10] how to reclaim unneeded vmlinux memory ? Jim Cromie
2023-10-12 19:48 ` Jim Cromie [this message]
2023-10-12 19:48 ` [RFC PATCH 02/10] dyndbg: split __dyndbg_sites section out from __dyndbg Jim Cromie
2023-10-12 19:48 ` [RFC PATCH 03/10] dyndbg: add 2nd cursor pair to init-fn Jim Cromie
2023-10-12 19:48 ` [RFC PATCH 04/10] dyndbg: save _ddebug_site mod,file,func fields into maple-trees Jim Cromie
2023-10-12 19:48 ` [RFC PATCH 05/10] dyndbg: avoid _ddebug.site in ddebug_condense_sites Jim Cromie
2023-10-12 19:48 ` [RFC PATCH 06/10] dyndbg: add site_*() macros to avoid using _ddebug.site Jim Cromie
2023-10-12 19:48 ` [RFC PATCH 07/10] dyndbg: wire in __desc_*() functions Jim Cromie
2023-10-12 19:48 ` [RFC PATCH 08/10] dyndbg: drop _ddebug.site member Jim Cromie
2023-10-12 19:48 ` [RFC PATCH 09/10] dyndbg: add dd_clear_range to prune mtrees Jim Cromie
2023-10-12 19:48 ` [RFC PATCH 10/10] dyndbg: cache the dynamically generated prefixes per callsite Jim Cromie
  -- strict thread matches above, loose matches on Subject: below --
2023-10-12 19:47 [RFC PATCH 00/10] how to reclaim unneeded vmlinux memory ? Jim Cromie
2023-10-12 19:47 ` [RFC PATCH 01/10] dyndbg: prep to isolate 3 repetetive fields 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=20231012194834.3288085-2-jim.cromie@gmail.com \
    --to=jim.cromie@gmail.com \
    --cc=Liam.Howlett@Oracle.com \
    --cc=david@redhat.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=jbaron@akamai.com \
    --cc=joe@perches.com \
    --cc=lb@semihalf.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=linux@rasmusvillemoes.dk \
    --cc=mcgrof@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.