Skip to content

Commit 671b60c

Browse files
Thomas Richteracmel
authored andcommitted
perf ftrace: Fix access to pid in array when setting a pid filter
Command 'perf ftrace -v -- ls' fails in s390 (at least 5.12.0rc6). The root cause is a missing pointer dereference which causes an array element address to be used as PID. Fix this by extracting the PID. Output before: # ./perf ftrace -v -- ls function_graph tracer is used write '-263732416' to tracing/set_ftrace_pid failed: Invalid argument failed to set ftrace pid # Output after: ./perf ftrace -v -- ls function_graph tracer is used # tracer: function_graph # # CPU DURATION FUNCTION CALLS # | | | | | | | 4) | rcu_read_lock_sched_held() { 4) 0.552 us | rcu_lockdep_current_cpu_online(); 4) 6.124 us | } Reported-by: Alexander Schmidt <[email protected]> Signed-off-by: Thomas Richter <[email protected]> Acked-by: Namhyung Kim <[email protected]> Cc: Heiko Carstens <[email protected]> Cc: Sumanth Korikkar <[email protected]> Cc: Sven Schnelle <[email protected]> Cc: Vasily Gorbik <[email protected]> Link: http://lore.kernel.org/lkml/[email protected] Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
1 parent b14585d commit 671b60c

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

tools/perf/builtin-ftrace.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -289,7 +289,7 @@ static int set_tracing_pid(struct perf_ftrace *ftrace)
289289

290290
for (i = 0; i < perf_thread_map__nr(ftrace->evlist->core.threads); i++) {
291291
scnprintf(buf, sizeof(buf), "%d",
292-
ftrace->evlist->core.threads->map[i]);
292+
perf_thread_map__pid(ftrace->evlist->core.threads, i));
293293
if (append_tracing_file("set_ftrace_pid", buf) < 0)
294294
return -1;
295295
}

0 commit comments

Comments
 (0)