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 02/10] dyndbg: split __dyndbg_sites section out from __dyndbg
Date: Thu, 12 Oct 2023 13:48:26 -0600	[thread overview]
Message-ID: <20231012194834.3288085-3-jim.cromie@gmail.com> (raw)
In-Reply-To: <20231012194834.3288085-1-jim.cromie@gmail.com>

split struct _ddebug_site out from struct _ddebug (adding a site ptr),
and add new __dyndbg_sites section placement to vmlinux.lds.h

This is an implementation detail to isolate the redundant columns into
a separate section, so it specifically excludes lineno.

This allows (later) to copy and compress the info into a better (more
compact) representation thats still fast enough.  Then we can just
reclaim the whole __dyndbg_sites section.

Signed-off-by: Jim Cromie <jim.cromie@gmail.com>
---
 include/asm-generic/vmlinux.lds.h |  1 +
 include/linux/dynamic_debug.h     | 40 ++++++++++++++++++-------------
 kernel/module/main.c              |  3 +++
 lib/dynamic_debug.c               |  6 +++++
 4 files changed, 33 insertions(+), 17 deletions(-)

diff --git a/include/asm-generic/vmlinux.lds.h b/include/asm-generic/vmlinux.lds.h
index 5451f926a753..1d128259e373 100644
--- a/include/asm-generic/vmlinux.lds.h
+++ b/include/asm-generic/vmlinux.lds.h
@@ -368,6 +368,7 @@
 	BOUNDED_SECTION_BY(__dyndbg_classes, ___dyndbg_classes)		\
 	BOUNDED_SECTION_BY(__dyndbg_class_users, ___dyndbg_class_users)	\
 	BOUNDED_SECTION_BY(__dyndbg, ___dyndbg)				\
+	BOUNDED_SECTION_BY(__dyndbg_sites, ___dyndbg_sites)		\
 	LIKELY_PROFILE()		       				\
 	BRANCH_PROFILE()						\
 	TRACE_PRINTKS()							\
diff --git a/include/linux/dynamic_debug.h b/include/linux/dynamic_debug.h
index aacfafc466c0..5206a2cfdb37 100644
--- a/include/linux/dynamic_debug.h
+++ b/include/linux/dynamic_debug.h
@@ -9,21 +9,25 @@
 #include <linux/build_bug.h>
 
 /*
- * An instance of this structure is created in a special
- * ELF section at every dynamic debug callsite.  At runtime,
- * the special section is treated as an array of these.
+ * A pair of these structs are created into 2 special ELF sections for
+ * each pr_debug callsite.  At runtime, the special sections are
+ * treated as arrays.
  */
-
-struct _ddebug {
+struct _ddebug;
+struct _ddebug_site {
 	/*
-	 * These fields are used to drive the user interface
-	 * for selecting and displaying debug callsites.
+	 * These fields are used to:
+	 * - display callsites in the control file
+	 * - query/select callsites by the code's organization
+	 * - prefix/decorate pr_debug messages per user choices
 	 */
-	struct /* _ddebug_site */ {
-		const char *_modname;
-		const char *_function;
-		const char *_filename;
-	};
+	const char *_modname;
+	const char *_function;
+	const char *_filename;
+};
+
+struct _ddebug {
+	struct _ddebug_site *site;
 	const char *format;
 	unsigned int lineno:18;
 #define CLS_BITS 6
@@ -64,10 +68,6 @@ 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,
 	/**
@@ -139,9 +139,11 @@ struct ddebug_class_user {
 /* encapsulate linker provided built-in (or module) dyndbg data */
 struct _ddebug_info {
 	struct _ddebug *descs;
+	struct _ddebug_site *sites;
 	struct ddebug_class_map *classes;
 	struct ddebug_class_user *class_users;
 	unsigned int num_descs;
+	unsigned int num_sites;
 	unsigned int num_classes;
 	unsigned int num_class_users;
 };
@@ -226,9 +228,13 @@ void __dynamic_ibdev_dbg(struct _ddebug *descriptor,
 	._filename = __FILE__
 
 #define DEFINE_DYNAMIC_DEBUG_METADATA_CLS(name, cls, fmt)	\
+	static struct _ddebug_site  __aligned(8)		\
+	__section("__dyndbg_sites") name ##_site = {		\
+		DYNAMIC_DEBUG_SITE_INIT(),			\
+	};							\
 	static struct _ddebug  __aligned(8)			\
 	__section("__dyndbg") name = {				\
-		DYNAMIC_DEBUG_SITE_INIT(),			\
+		.site = &(name ##_site),			\
 		.format = (fmt),				\
 		.lineno = __LINE__,				\
 		.flags = _DPRINTK_FLAGS_DEFAULT,		\
diff --git a/kernel/module/main.c b/kernel/module/main.c
index 6b0b0d82b5ab..43458184744d 100644
--- a/kernel/module/main.c
+++ b/kernel/module/main.c
@@ -2211,6 +2211,9 @@ static int find_module_sections(struct module *mod, struct load_info *info)
 	mod->dyndbg_info.descs = section_objs(info, "__dyndbg",
 					      sizeof(*mod->dyndbg_info.descs),
 					      &mod->dyndbg_info.num_descs);
+	mod->dyndbg_info.sites = section_objs(info, "__dyndbg_sites",
+					      sizeof(*mod->dyndbg_info.sites),
+					      &mod->dyndbg_info.num_sites);
 	mod->dyndbg_info.classes = section_objs(info, "__dyndbg_classes",
 						sizeof(*mod->dyndbg_info.classes),
 						&mod->dyndbg_info.num_classes);
diff --git a/lib/dynamic_debug.c b/lib/dynamic_debug.c
index c0e595483cb9..0ad9f1bc00f0 100644
--- a/lib/dynamic_debug.c
+++ b/lib/dynamic_debug.c
@@ -41,6 +41,8 @@
 
 extern struct _ddebug __start___dyndbg[];
 extern struct _ddebug __stop___dyndbg[];
+extern struct _ddebug_site __start___dyndbg_sites[];
+extern struct _ddebug_site __stop___dyndbg_sites[];
 extern struct ddebug_class_map __start___dyndbg_classes[];
 extern struct ddebug_class_map __stop___dyndbg_classes[];
 extern struct ddebug_class_user __start___dyndbg_class_users[];
@@ -191,6 +193,10 @@ static struct ddebug_class_map *ddebug_find_valid_class(struct ddebug_table cons
 	return NULL;
 }
 
+#define desc_modname(d)		(d)->site->_modname
+#define desc_filename(d)	(d)->site->_filename
+#define desc_function(d)	(d)->site->_function
+
 /*
  * Search the tables for _ddebug's which match the given `query' and
  * apply the `flags' and `mask' to them.  Returns number of matching
-- 
2.41.0


  parent 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 ` [RFC PATCH 01/10] dyndbg: prep to isolate 3 repetetive fields Jim Cromie
2023-10-12 19:48 ` Jim Cromie [this message]
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 02/10] dyndbg: split __dyndbg_sites section out from __dyndbg 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-3-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.