Skip to contentSkip to conversation

perf ftrace: Command fails on s390

PATCH Applied Thomas Richter 3 participants 4 messages Apr 21, 2021 – Apr 23, 2021 perf events

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 perf ftrace: Command fails on s390

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    |  }
---
 tools/perf/builtin-ftrace.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/perf/builtin-ftrace.c +1 -1
index d49448a1060c..87cb11a7a3ee 100644
@@ -289,7 +289,7 @@ static int set_tracing_pid(struct perf_ftrace *ftrace)
 
 	for (i = 0; i < perf_thread_map__nr(ftrace->evlist->core.threads); i++) {
 		scnprintf(buf, sizeof(buf), "%d",
-			  ftrace->evlist->core.threads->map[i]);
+			  perf_thread_map__pid(ftrace->evlist->core.threads, i));
 		if (append_tracing_file("set_ftrace_pid", buf) < 0)
 			return -1;
 	}
Signature · 1 line
2.30.2
Acked-by on v1 1/1
#1 lore raw

Hello,

Quoted 22 lines · Thomas Richter

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
# | | | | | | |

Quoted 6 lines
   4)               |  rcu_read_lock_sched_held() {
   4)   0.552 us    |    rcu_lockdep_current_cpu_online();
   4)   6.124 us    |  }

Thanks,
Namhyung

Quoted 20 lines
---
 tools/perf/builtin-ftrace.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/perf/builtin-ftrace.c +1 -2
index d49448a1060c..87cb11a7a3ee 100644
@@ -289,7 +289,7 @@ static int set_tracing_pid(struct perf_ftrace *ftrace)
 
        for (i = 0; i < perf_thread_map__nr(ftrace->evlist->core.threads); i++) {
                scnprintf(buf, sizeof(buf), "%d",
-                         ftrace->evlist->core.threads->map[i]);
+                         perf_thread_map__pid(ftrace->evlist->core.threads, i));
                if (append_tracing_file("set_ftrace_pid", buf) < 0)
                        return -1;
        }
--

2.30.2

maintainer Applied
#2 lore raw
In reply to Thomas Richter

Em Wed, Apr 21, 2021 at 02:04:00PM +0200, Thomas Richter escreveu:

Quoted 6 lines

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.

Thanks, applied.

- Arnaldo

Quoted 40 lines

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    |  }
---
 tools/perf/builtin-ftrace.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/perf/builtin-ftrace.c +1 -1
index d49448a1060c..87cb11a7a3ee 100644
@@ -289,7 +289,7 @@ static int set_tracing_pid(struct perf_ftrace *ftrace)
 
 	for (i = 0; i < perf_thread_map__nr(ftrace->evlist->core.threads); i++) {
 		scnprintf(buf, sizeof(buf), "%d",
-			  ftrace->evlist->core.threads->map[i]);
+			  perf_thread_map__pid(ftrace->evlist->core.threads, i));
 		if (append_tracing_file("set_ftrace_pid", buf) < 0)
 			return -1;
 	}
Signature · 1 line
2.30.2
Signature · 1 line
- Arnaldo
#3 lore raw
In reply to Thomas Richter

Em Wed, Apr 21, 2021 at 02:04:00PM +0200, Thomas Richter escreveu:

Quoted 4 lines

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.

Since you pinged on this one, and rightly so, please CC:

From the MAINTAINERS file:

PERFORMANCE EVENTS SUBSYSTEM

R:      Jiri Olsa <[email protected]>
R:      Namhyung Kim <[email protected]>

These reviewers that help me into getting patches processed.

Patch is processed now, good catch, I collected Namhyung's Acked-by.

Thanks,

- Arnaldo

Quoted 42 lines

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    |  }
---
 tools/perf/builtin-ftrace.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/perf/builtin-ftrace.c +1 -1
index d49448a1060c..87cb11a7a3ee 100644
@@ -289,7 +289,7 @@ static int set_tracing_pid(struct perf_ftrace *ftrace)
 
 	for (i = 0; i < perf_thread_map__nr(ftrace->evlist->core.threads); i++) {
 		scnprintf(buf, sizeof(buf), "%d",
-			  ftrace->evlist->core.threads->map[i]);
+			  perf_thread_map__pid(ftrace->evlist->core.threads, i));
 		if (append_tracing_file("set_ftrace_pid", buf) < 0)
 			return -1;
 	}
Signature · 1 line
2.30.2
Signature · 1 line
- Arnaldo