[2/7] dyndbg: count repetition in __dyndbg_callsite fields.
diff mbox series

Message ID 20201125193626.2266995-3-jim.cromie@gmail.com
State New, archived
Headers show
Series
  • [1/7] dyndbg: move struct _ddebug's display fields to new _ddebug_callsite
Related show

Commit Message

Jim Cromie Nov. 25, 2020, 7:36 p.m. UTC
The __dyndbg_callsite section is basically a flat db-table, an array
of struct _ddebug_callsite[]s.  Its data is inherently hierarchical
and sorted, so a field-wise run-length encoding would compress well.

Add counters and code to test 3 fields of consecutive callsites for
repeated values.  The results inform a compression estimate.

 dyndbg: 2605 entries. repeated entries: 2369 module 2231 file 1147 func

Thats (91%, 86%, 44%) repeated values in those pointers/columns, on my
i7 laptop build.  With a zero-overhead markup, like LSB-stealing, we
could mark the differing tails of consecutive records, and get 11/24
compression on init/main pr_debugs.

For a slightly apples-to-oranges comparison (text vs pointers),
`gzip /proc/dynamic_debug/control` achieves 6/1 compression.

Signed-off-by: Jim Cromie <jim.cromie@gmail.com>
---
 lib/dynamic_debug.c | 17 +++++++++++++++--
 1 file changed, 15 insertions(+), 2 deletions(-)

Patch
diff mbox series

diff --git a/lib/dynamic_debug.c b/lib/dynamic_debug.c
index 2e4a39c349a5..5980d44ff2f8 100644
--- a/lib/dynamic_debug.c
+++ b/lib/dynamic_debug.c
@@ -1081,11 +1081,12 @@  static int __init dynamic_debug_init_control(void)
 
 static int __init dynamic_debug_init(void)
 {
-	struct _ddebug *iter, *iter_start;
+	struct _ddebug *iter, *iter_start, *prev = NULL;
 	const char *modname = NULL;
 	char *cmdline;
 	int ret = 0;
 	int n = 0, entries = 0, modct = 0;
+	int modreps = 0, funcreps = 0, filereps = 0;
 
 	if (&__start___dyndbg == &__stop___dyndbg) {
 		if (IS_ENABLED(CONFIG_DYNAMIC_DEBUG)) {
@@ -1099,7 +1100,16 @@  static int __init dynamic_debug_init(void)
 	iter = __start___dyndbg;
 	modname = iter->site->modname;
 	iter_start = iter;
-	for (; iter < __stop___dyndbg; iter++) {
+	for (prev = iter; iter < __stop___dyndbg; iter++) {
+		if (entries) {
+			if (prev->site->modname == iter->site->modname)
+				modreps++;
+			if (prev->site->function == iter->site->function)
+				funcreps++;
+			if (prev->site->filename == iter->site->filename)
+				filereps++;
+			prev++; /* one behind iter */
+		}
 		entries++;
 		if (strcmp(modname, iter->site->modname)) {
 			modct++;
@@ -1122,6 +1132,9 @@  static int __init dynamic_debug_init(void)
 		 (int)(entries * sizeof(struct _ddebug)),
 		 (int)(entries * sizeof(struct _ddebug_callsite)));
 
+	vpr_info("%d entries. repeated entries: %d module %d file %d func\n",
+		 entries, modreps, filereps, funcreps);
+
 	/* apply ddebug_query boot param, dont unload tables on err */
 	if (ddebug_setup_string[0] != '\0') {
 		pr_warn("ddebug_query param name is deprecated, change it to dyndbg\n");