All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] [PING] perf ftrace: Command fails on s390
@ 2021-04-21 12:04 Thomas Richter
  2021-04-21 19:53 ` Namhyung Kim
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Thomas Richter @ 2021-04-21 12:04 UTC (permalink / raw)
  To: linux-kernel, linux-perf-users, acme
  Cc: svens, gor, sumanthk, hca, Thomas Richter, Alexander Schmidt

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

Signed-off-by: Thomas Richter <tmricht@linux.ibm.com>
Reported-by: Alexander Schmidt <alexschm@de.ibm.com>
---
 tools/perf/builtin-ftrace.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/perf/builtin-ftrace.c b/tools/perf/builtin-ftrace.c
index d49448a1060c..87cb11a7a3ee 100644
--- a/tools/perf/builtin-ftrace.c
+++ b/tools/perf/builtin-ftrace.c
@@ -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


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] [PING] perf ftrace: Command fails on s390
  2021-04-21 12:04 [PATCH] [PING] perf ftrace: Command fails on s390 Thomas Richter
@ 2021-04-21 19:53 ` Namhyung Kim
  2021-04-23 13:40 ` Arnaldo Carvalho de Melo
  2021-04-23 18:59 ` Arnaldo Carvalho de Melo
  2 siblings, 0 replies; 4+ messages in thread
From: Namhyung Kim @ 2021-04-21 19:53 UTC (permalink / raw)
  To: Thomas Richter
  Cc: linux-kernel, linux-perf-users, Arnaldo Carvalho de Melo, svens,
	gor, sumanthk, hca, Alexander Schmidt

Hello,

On Wed, Apr 21, 2021 at 10:03 PM Thomas Richter <tmricht@linux.ibm.com> wrote:
>
> 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    |  }
>
> Signed-off-by: Thomas Richter <tmricht@linux.ibm.com>
> Reported-by: Alexander Schmidt <alexschm@de.ibm.com>

Acked-by: Namhyung Kim <namhyung@kernel.org>

Thanks,
Namhyung

> ---
>  tools/perf/builtin-ftrace.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/tools/perf/builtin-ftrace.c b/tools/perf/builtin-ftrace.c
> index d49448a1060c..87cb11a7a3ee 100644
> --- a/tools/perf/builtin-ftrace.c
> +++ b/tools/perf/builtin-ftrace.c
> @@ -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
>

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] [PING] perf ftrace: Command fails on s390
  2021-04-21 12:04 [PATCH] [PING] perf ftrace: Command fails on s390 Thomas Richter
  2021-04-21 19:53 ` Namhyung Kim
@ 2021-04-23 13:40 ` Arnaldo Carvalho de Melo
  2021-04-23 18:59 ` Arnaldo Carvalho de Melo
  2 siblings, 0 replies; 4+ messages in thread
From: Arnaldo Carvalho de Melo @ 2021-04-23 13:40 UTC (permalink / raw)
  To: Thomas Richter
  Cc: linux-kernel, linux-perf-users, svens, gor, sumanthk, hca,
	Alexander Schmidt

Em Wed, Apr 21, 2021 at 02:04:00PM +0200, Thomas Richter escreveu:
> 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

 
> 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    |  }
> 
> Signed-off-by: Thomas Richter <tmricht@linux.ibm.com>
> Reported-by: Alexander Schmidt <alexschm@de.ibm.com>
> ---
>  tools/perf/builtin-ftrace.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/tools/perf/builtin-ftrace.c b/tools/perf/builtin-ftrace.c
> index d49448a1060c..87cb11a7a3ee 100644
> --- a/tools/perf/builtin-ftrace.c
> +++ b/tools/perf/builtin-ftrace.c
> @@ -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
> 

-- 

- Arnaldo

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] [PING] perf ftrace: Command fails on s390
  2021-04-21 12:04 [PATCH] [PING] perf ftrace: Command fails on s390 Thomas Richter
  2021-04-21 19:53 ` Namhyung Kim
  2021-04-23 13:40 ` Arnaldo Carvalho de Melo
@ 2021-04-23 18:59 ` Arnaldo Carvalho de Melo
  2 siblings, 0 replies; 4+ messages in thread
From: Arnaldo Carvalho de Melo @ 2021-04-23 18:59 UTC (permalink / raw)
  To: Thomas Richter
  Cc: linux-kernel, linux-perf-users, svens, gor, sumanthk, hca,
	Alexander Schmidt

Em Wed, Apr 21, 2021 at 02:04:00PM +0200, Thomas Richter escreveu:
> 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 <jolsa@redhat.com>
R:      Namhyung Kim <namhyung@kernel.org>

These reviewers that help me into getting patches processed.

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

Thanks,

- Arnaldo

 
> 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    |  }
> 
> Signed-off-by: Thomas Richter <tmricht@linux.ibm.com>
> Reported-by: Alexander Schmidt <alexschm@de.ibm.com>
> ---
>  tools/perf/builtin-ftrace.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/tools/perf/builtin-ftrace.c b/tools/perf/builtin-ftrace.c
> index d49448a1060c..87cb11a7a3ee 100644
> --- a/tools/perf/builtin-ftrace.c
> +++ b/tools/perf/builtin-ftrace.c
> @@ -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
> 

-- 

- Arnaldo

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2021-04-23 19:02 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-04-21 12:04 [PATCH] [PING] perf ftrace: Command fails on s390 Thomas Richter
2021-04-21 19:53 ` Namhyung Kim
2021-04-23 13:40 ` Arnaldo Carvalho de Melo
2021-04-23 18:59 ` Arnaldo Carvalho de Melo

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.