[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20250803035816.603405-33-jim.cromie@gmail.com>
Date: Sat, 2 Aug 2025 21:57:50 -0600
From: Jim Cromie <jim.cromie@...il.com>
To: linux-kernel@...r.kernel.org,
jbaron@...mai.com,
gregkh@...uxfoundation.org,
ukaszb@...omium.org,
louis.chauvet@...tlin.com
Cc: dri-devel@...ts.freedesktop.org,
amd-gfx@...ts.freedesktop.org,
intel-gvt-dev@...ts.freedesktop.org,
intel-gfx@...ts.freedesktop.org,
daniel.vetter@...ll.ch,
tvrtko.ursulin@...ux.intel.com,
jani.nikula@...el.com,
ville.syrjala@...ux.intel.com,
seanpaul@...omium.org,
robdclark@...il.com,
groeck@...gle.com,
yanivt@...gle.com,
bleung@...gle.com,
quic_saipraka@...cinc.com,
will@...nel.org,
catalin.marinas@....com,
quic_psodagud@...cinc.com,
maz@...nel.org,
arnd@...db.de,
linux-arm-kernel@...ts.infradead.org,
linux-arm-msm@...r.kernel.org,
mingo@...hat.com,
jim.cromie@...il.com
Subject: [PATCH v4 32/58] dyndbg: refactor *dynamic_emit_prefix to split lookups
Split dynamic_emit_prefix():
1. keep dynamic_emit_prefix() static inline
check ANY flags before calling 2
2. __dynamic_emit_prefix()
prints [TID] or <intr> if +t flag
check LOOKUP flags before calling 3
3. __dynamic_emit_lookup()
prints 1+ of: module, function, src-file, line
Notes:
With 3 only called when needed, print the trailing whitespace
unconditionally, and drop the pos_after_tid var.
By doing TID in 2, 3's output is cacheable in principle.
A prefix cache would allow de-duplicating the redundant data in the
_ddebug tables, and replacing them with space-efficient storage which
is not fast enough for every-time pr_debugs, but would work to fill
the cache the 1st time its enabled and invoked.
Signed-off-by: Jim Cromie <jim.cromie@...il.com>
---
lib/dynamic_debug.c | 40 +++++++++++++++++++++++++---------------
1 file changed, 25 insertions(+), 15 deletions(-)
diff --git a/lib/dynamic_debug.c b/lib/dynamic_debug.c
index c3e27637d9357..26261b5f99f05 100644
--- a/lib/dynamic_debug.c
+++ b/lib/dynamic_debug.c
@@ -824,19 +824,8 @@ static int remaining(int wrote)
return 0;
}
-static char *__dynamic_emit_prefix(const struct _ddebug *desc, char *buf)
+static int __dynamic_emit_lookup(const struct _ddebug *desc, char *buf, int pos)
{
- int pos_after_tid;
- int pos = 0;
-
- if (desc->flags & _DPRINTK_FLAGS_INCL_TID) {
- if (in_interrupt())
- pos += snprintf(buf + pos, remaining(pos), "<intr> ");
- else
- pos += snprintf(buf + pos, remaining(pos), "[%d] ",
- task_pid_vnr(current));
- }
- pos_after_tid = pos;
if (desc->flags & _DPRINTK_FLAGS_INCL_MODNAME)
pos += snprintf(buf + pos, remaining(pos), "%s:",
desc->modname);
@@ -849,8 +838,29 @@ static char *__dynamic_emit_prefix(const struct _ddebug *desc, char *buf)
if (desc->flags & _DPRINTK_FLAGS_INCL_LINENO)
pos += snprintf(buf + pos, remaining(pos), "%d:",
desc->lineno);
- if (pos - pos_after_tid)
- pos += snprintf(buf + pos, remaining(pos), " ");
+
+ /* we have a non-empty prefix, add trailing space */
+ if (remaining(pos))
+ buf[pos++] = ' ';
+
+ return pos;
+}
+
+static char *__dynamic_emit_prefix(struct _ddebug *desc, char *buf)
+{
+ int pos = 0;
+
+ if (desc->flags & _DPRINTK_FLAGS_INCL_TID) {
+ if (in_interrupt())
+ pos += snprintf(buf + pos, remaining(pos), "<intr> ");
+ else
+ pos += snprintf(buf + pos, remaining(pos), "[%d] ",
+ task_pid_vnr(current));
+ }
+
+ if (unlikely(desc->flags & _DPRINTK_FLAGS_INCL_LOOKUP))
+ pos += __dynamic_emit_lookup(desc, buf, pos);
+
if (pos >= PREFIX_SIZE)
buf[PREFIX_SIZE - 1] = '\0';
@@ -859,7 +869,7 @@ static char *__dynamic_emit_prefix(const struct _ddebug *desc, char *buf)
static inline char *dynamic_emit_prefix(struct _ddebug *desc, char *buf)
{
- if (unlikely(desc->flags & _DPRINTK_FLAGS_INCL_ANY))
+ if (desc->flags & _DPRINTK_FLAGS_INCL_ANY)
return __dynamic_emit_prefix(desc, buf);
return buf;
}
--
2.50.1
Powered by blists - more mailing lists