Skip to contentSkip to conversation

ftrace: Fix type of ftrace_graph_ent_entry.depth

PATCH Superseded Ilya Leoshkevich 2 participants 4 messages Apr 11, 2025 – Apr 12, 2025 Tracing

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ftrace: Fix type of ftrace_graph_ent_entry.depth

ftrace_graph_ent.depth is int, but ftrace_graph_ent_entry.depth is unsigned long. This confuses trace-cmd on big-endian systems and makes it print a huge amount of spaces. Make the types match.

Fixes ff5c9c576e75 ("ftrace: Add support for function argument to graph tracer")
---
 kernel/trace/trace_entries.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
kernel/trace/trace_entries.h +2 -2
index ee40d4e6ad1c..ac6374b47fe3 100644
@@ -80,11 +80,11 @@ FTRACE_ENTRY(funcgraph_entry, ftrace_graph_ent_entry,
 	F_STRUCT(
 		__field_struct(	struct ftrace_graph_ent,	graph_ent	)
 		__field_packed(	unsigned long,	graph_ent,	func		)
-		__field_packed(	unsigned long,	graph_ent,	depth		)
+		__field_packed(	int,		graph_ent,	depth		)
 		__dynamic_array(unsigned long,	args				)
 	),
 
-	F_printk("--> %ps (%lu)", (void *)__entry->func, __entry->depth)
+	F_printk("--> %ps (%d)", (void *)__entry->func, __entry->depth)
 );
 
 #ifdef CONFIG_FUNCTION_GRAPH_RETADDR
Signature · 1 line
2.49.0
maintainer
#1 lore raw

kernel/trace/trace_entries.h FTRACE_ENTRY(funcgraph_entry, ftrace_graph_ent_entry, · line 87

Quoted 3 lines · On Fri, 11 Apr 2025 19:21:41 +0200 Ilya Leoshkevich <[email protected]> wrote:
kernel/trace/trace_entries.h +1 -1
-	F_printk("--> %ps (%lu)", (void *)__entry->func, __entry->depth)
+	F_printk("--> %ps (%d)", (void *)__entry->func, __entry->depth)

depth should never be negative. Why did you use "%d" and not "%u" ?

-- Steve

#2 lore raw
Quoted 10 lines · Steven Rostedt

kernel/trace/trace_entries.h FTRACE_ENTRY(funcgraph_entry, ftrace_graph_ent_entry, · line 87

Quoted 3 lines · On Fri, 11 Apr 2025 19:21:41 +0200 Ilya Leoshkevich <[email protected]> wrote:
kernel/trace/trace_entries.h +1 -1
-	F_printk("--> %ps (%lu)", (void *)__entry->func, __entry->depth)
+	F_printk("--> %ps (%d)", (void *)__entry->func, __entry->depth)

depth should never be negative. Why did you use "%d" and not "%u" ?

-- Steve

I used int, because it's int in ftrace_graph_ent and all other events.
If you think it's a good idea, I can change them all to unsigned int in a follow-up patch.

maintainer
#3 lore raw
Quoted 10 lines · On Sat, 12 Apr 2025 23:01:05 +0200 Ilya Leoshkevich <[email protected]> wrote:
Quoted 9 lines · Steven Rostedt

kernel/trace/trace_entries.h FTRACE_ENTRY(funcgraph_entry, ftrace_graph_ent_entry, · line 87

Quoted 3 lines · On Fri, 11 Apr 2025 19:21:41 +0200 Ilya Leoshkevich <[email protected]> wrote:
kernel/trace/trace_entries.h +1 -1
-	F_printk("--> %ps (%lu)", (void *)__entry->func, __entry->depth)
+	F_printk("--> %ps (%d)", (void *)__entry->func, __entry->depth)  

depth should never be negative. Why did you use "%d" and not "%u" ?

Quoted 5 lines
Quoted 1 line

-- Steve

I used int, because it's int in ftrace_graph_ent and all other events. If you think it's a good idea, I can change them all to unsigned int in a follow-up patch.

Hmm, a change like that should have been in the change log and explained.

The reason the code has int is because it uses negative depth to break out of iterations and such. But what is recorded is always zero or positive.

Yeah, let's keep it exposed as unsigned int.

Thanks,

-- Stene