tracepoint: Print the function symbol when tracepoint_debug is set
PATCH RESEND 1/1 tracepoint: Print the function symbol when tracepoint_debug is set
When tracepoint_debug is set, we may get the output in kernel log:
[ 380.013843] Probe 0 : 00000000f0d68cda
It is not readable, so change to print the function symbol. After this patch, the output may becomes:
[ 54.930567] Probe 0 : perf_trace_sched_wakeup_template
--- kernel/tracepoint.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/tracepoint.c +1 -1
@@ -127,7 +127,7 @@ static void debug_print_probes(struct tracepoint_func *funcs)return ;for (i =0 ; funcs[i].func; i++) -printk (KERN_DEBUG "Probe %d : %p\n" , i, funcs[i].func); +printk (KERN_DEBUG "Probe %d : %ps\n" , i, funcs[i].func); } static struct tracepoint_func *
Signature · 1 line
2.40.1
Mathieu Desnoyers
reviewerQuoted 6 lines · Huang Shijie
When
tracepoint_debugis set, we may get the output in kernel log:[ 380.013843] Probe 0 : 00000000f0d68cdaIt is not readable, so change to print the function symbol. After this patch, the output may becomes:
[ 54.930567] Probe 0 : perf_trace_sched_wakeup_template
What would it print if the address is corrupted ?
Perhaps we could do like the backtrace code and print e.g.
[<00000000f0d68cda>] perf_trace_sched_wakeup_template+0xNN/0xMM
?
I don't care about the actual layout, but removing the address from the formatted output appears to be removing useful data in debug situations.
Thanks,
Mathieu
Quoted 20 lines
Reviewed-by Christoph Lameter <[email protected]>Signed-off-by Huang Shijie <[email protected]>--- kernel/tracepoint.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)kernel/tracepoint.c +1
-1@@ -127,7 +127,7 @@ static void debug_print_probes(struct tracepoint_func *funcs)return ;for (i =0 ; funcs[i].func; i++) -printk (KERN_DEBUG "Probe %d : %p\n" , i, funcs[i].func); +printk (KERN_DEBUG "Probe %d : %ps\n" , i, funcs[i].func); } static struct tracepoint_func *
Signature · 3 lines
Mathieu Desnoyers EfficiOS Inc. https://www.efficios.com
Steven Rostedt
maintainerQuoted 12 lines · On Wed, 5 Mar 2025 08:53:43 -0500 Mathieu Desnoyers…
Quoted 6 lines · Huang Shijie
When
tracepoint_debugis set, we may get the output in kernel log:[ 380.013843] Probe 0 : 00000000f0d68cdaIt is not readable, so change to print the function symbol. After this patch, the output may becomes:
[ 54.930567] Probe 0 : perf_trace_sched_wakeup_templateWhat would it print if the address is corrupted ?
Perhaps we could do like the backtrace code and print e.g.
Quoted 8 lines
[<
00000000f0d68cda>] perf_trace_sched_wakeup_template+0xNN/0xMM?
I don't care about the actual layout, but removing the address from the formatted output appears to be removing useful data in debug situations.
Perhaps this can use "%pS" which shows both the function entry and the offset. If no function is found, it ends up being the same as "%p". Also, it's likely that the "%p" is hashed here and one couldn't use it to debug either.
-- Steve
Quoted 16 lines · Steven Rostedt
Quoted 13 lines · On Wed, 5 Mar 2025 08:53:43 -0500 Mathieu Desnoyers…
Quoted 6 lines · Huang Shijie
When
tracepoint_debugis set, we may get the output in kernel log:[ 380.013843] Probe 0 : 00000000f0d68cdaIt is not readable, so change to print the function symbol. After this patch, the output may becomes:
[ 54.930567] Probe 0 : perf_trace_sched_wakeup_templateWhat would it print if the address is corrupted ?
Perhaps we could do like the backtrace code and print e.g.
[<
00000000f0d68cda>] perf_trace_sched_wakeup_template+0xNN/0xMM
Quoted 7 lines
Quoted 6 lines
?
I don't care about the actual layout, but removing the address from the formatted output appears to be removing useful data in debug situations.
Perhaps this can use "%pS" which shows both the function entry and the
okay, I can change it to use "%pS" in next version if we think it is good enough:
[ 55.225555] Probe 0 : perf_trace_sched_wakeup_template+0x0/0x20
Thanks
Huang Shijie
Quoted 8 lines · Mathieu Desnoyers
Quoted 6 lines · Huang Shijie
When
tracepoint_debugis set, we may get the output in kernel log:
[ 380.013843] Probe 0 :00000000f0d68cdaIt is not readable, so change to print the function symbol. After this patch, the output may becomes:
[ 54.930567] Probe 0 :perf_trace_sched_wakeup_template
Quoted 5 lines
What would it print if the address is corrupted ?
Perhaps we could do like the backtrace code and print e.g.
[<
00000000f0d68cda>] perf_trace_sched_wakeup_template+0xNN/0xMM
If we want this format, we can change code to:
---
kernel/tracepoint.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
kernel/tracepoint.c +0 -0
@@ -127,7 +127,8 @@ static void debug_print_probes(struct tracepoint_func *funcs)
return;
for (i = 0; funcs[i].func; i++)
- printk(KERN_DEBUG "Probe %d : %p\n", i, funcs[i].func); + printk(KERN_DEBUG "Probe %d : [ %p ] %pS\n", + i, funcs[i].func, funcs[i].func); }
The output will look like:
[ 63.818829] Probe 0 : [ 0000000032848d41 ] perf_trace_sched_wakeup_template+0x0/0x20 [ 63.819287] Probe 0 : [ 00000000fe8cca4d ] perf_trace_sched_switch+0x0/0x20 [ 65.325638] Probe 0 : [ 0000000032848d41 ] perf_trace_sched_wakeup_template+0x0/0x20 [ 65.695631] Probe 0 : [ 00000000fe8cca4d ] perf_trace_sched_switch+0x0/0x20
Thanks
Huang Shijie
Steven Rostedt
maintainerQuoted 17 lines · On Thu, 6 Mar 2025 11:37:38 +0800 Shijie Huang…
kernel/tracepoint.c +2
-1@@ -127,7 +127,8 @@ static void debug_print_probes(struct tracepoint_func *funcs) return; for (i = 0; funcs[i].func; i++) - printk(KERN_DEBUG "Probe %d : %p\n", i, funcs[i].func); + printk(KERN_DEBUG "Probe %d : [ %p ] %pS\n", + i, funcs[i].func, funcs[i].func); }The output will look like:
Quoted 8 lines
[ 63.818829] Probe 0 : [
0000000032848d41]perf_trace_sched_wakeup_template+0x0/0x20
[ 63.819287] Probe 0 : [00000000fe8cca4d]perf_trace_sched_switch+0x0/0x20
[ 65.325638] Probe 0 : [0000000032848d41]perf_trace_sched_wakeup_template+0x0/0x20
[ 65.695631] Probe 0 : [00000000fe8cca4d]perf_trace_sched_switch+0x0/0x20
I'm fine either way. Mathieu, what's your preference?
Although the above shows a hashed %p. Is that even useful?
-- Steve
Mathieu Desnoyers
reviewerQuoted 31 lines · Steven Rostedt
Quoted 17 lines · On Thu, 6 Mar 2025 11:37:38 +0800 Shijie Huang…
kernel/tracepoint.c +2
-1@@ -127,7 +127,8 @@ static void debug_print_probes(struct tracepoint_func *funcs) return; for (i = 0; funcs[i].func; i++) - printk(KERN_DEBUG "Probe %d : %p\n", i, funcs[i].func); + printk(KERN_DEBUG "Probe %d : [ %p ] %pS\n", + i, funcs[i].func, funcs[i].func); }The output will look like:
Quoted 8 lines
[ 63.818829] Probe 0 : [
0000000032848d41]perf_trace_sched_wakeup_template+0x0/0x20
[ 63.819287] Probe 0 : [00000000fe8cca4d]perf_trace_sched_switch+0x0/0x20
[ 65.325638] Probe 0 : [0000000032848d41]perf_trace_sched_wakeup_template+0x0/0x20
[ 65.695631] Probe 0 : [00000000fe8cca4d]perf_trace_sched_switch+0x0/0x20I'm fine either way. Mathieu, what's your preference?
Quoted 1 line
Although the above shows a hashed %p. Is that even useful?
The hashed %p is not really useful.
I think we could just print %Sb
e.g. from core-api/printk-formats.rst:
%pSb versatile_init+0x0/0x110 [module_name ed5019fdf5e53be37cb1ba7899292d7e143b259e]
AFAIU, when the kallsyms_lookup_buildid fails, it prints the raw address instead (see __sprint_symbol).
Thanks,
Mathieu
Signature · 3 lines
Mathieu Desnoyers EfficiOS Inc. https://www.efficios.com
Quoted 9 lines · Mathieu Desnoyers
I think we could just print %Sb
e.g. from
core-api/printk-formats.rst:%pSb
versatile_init+0x0/0x110[module_nameed5019fdf5e53be37cb1ba7899292d7e143b259e]AFAIU, when the
kallsyms_lookup_buildidfails, it prints the raw address instead (see__sprint_symbol).
okay, I will use "%pSb" in version v2 later.
Thanks
Huang Shijie