linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] perf script: Fix display inconsitency when call-graph config is used
@ 2016-05-16  4:51 He Kuang
  2016-05-27  3:47 ` Hekuang
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: He Kuang @ 2016-05-16  4:51 UTC (permalink / raw)
  To: peterz, mingo, acme, alexander.shishkin, wangnan0; +Cc: hekuang, linux-kernel

There's a display inconsistency when 'call-graph' config event appears
in different position. The problem can be reproduced like this:

We record signal_deliver with call-graph and signal_generate without it.

  $ perf record -g -a -e signal:signal_deliver -e signal:signal_generate/call-graph=no/

  [ perf record: Captured and wrote 0.017 MB perf.data (2 samples) ]

  $ perf script

  kworker/u2:1    13 [000]  6563.875949: signal:signal_generate: sig=2 errno=0 code=128 comm=perf pid=1313 grp=1 res=0 ff61cc __send_signal+0x3ec ([kernel.kallsyms])
  perf  1313 [000]  6563.877584:  signal:signal_deliver: sig=2 errno=0 code=128 sa_handler=43115e sa_flags=14000000
              7ffff314 get_signal+0x80007f0023a4 ([kernel.kallsyms])
              7fffe358 do_signal+0x80007f002028 ([kernel.kallsyms])
              7fffa5e8 exit_to_usermode_loop+0x80007f002053 ([kernel.kallsyms])
              ...

Then we exchange the order of these two events in commandline, and keep
signal_generate without call-graph.

  $ perf record -g -a -e signal:signal_generate/call-graph=no/ -e signal:signal_deliver

  [ perf record: Captured and wrote 0.017 MB perf.data (2 samples) ]

  $ perf script

    kworker/u2:2  1314 [000]  6933.353060: signal:signal_generate: sig=2 errno=0 code=128 comm=perf pid=1321 grp=1 res=0
            perf  1321 [000]  6933.353872:  signal:signal_deliver: sig=2 errno=0 code=128 sa_handler=43115e sa_flags=14000000

This time, the callchain of the event signal_deliver disappeared. The
problem is caused by that perf only checks for the first evsel in evlist
and decides if callchain should be printed.

This patch travseres all evsels in evlist to see if any of them have
callchains, and shows the right result:

  $ perf script

  kworker/u2:2  1314 [000]  6933.353060: signal:signal_generate: sig=2 errno=0 code=128 comm=perf pid=1321 grp=1 res=0 ff61cc __send_signal+0x3ec ([kernel.kallsyms])
  perf  1321 [000]  6933.353872:  signal:signal_deliver: sig=2 errno=0 code=128 sa_handler=43115e sa_flags=14000000
              7ffff314 get_signal+0x80007f0023a4 ([kernel.kallsyms])
              7fffe358 do_signal+0x80007f002028 ([kernel.kallsyms])
              7fffa5e8 exit_to_usermode_loop+0x80007f002053 ([kernel.kallsyms])
              ...

Signed-off-by: He Kuang <hekuang@huawei.com>
---
 tools/perf/builtin-script.c | 23 +++++++++++++----------
 1 file changed, 13 insertions(+), 10 deletions(-)

diff --git a/tools/perf/builtin-script.c b/tools/perf/builtin-script.c
index efca816..7a18b92 100644
--- a/tools/perf/builtin-script.c
+++ b/tools/perf/builtin-script.c
@@ -339,7 +339,7 @@ static void set_print_ip_opts(struct perf_event_attr *attr)
  */
 static int perf_session__check_output_opt(struct perf_session *session)
 {
-	int j;
+	unsigned int j;
 	struct perf_evsel *evsel;
 
 	for (j = 0; j < PERF_TYPE_MAX; ++j) {
@@ -388,17 +388,20 @@ static int perf_session__check_output_opt(struct perf_session *session)
 		struct perf_event_attr *attr;
 
 		j = PERF_TYPE_TRACEPOINT;
-		evsel = perf_session__find_first_evtype(session, j);
-		if (evsel == NULL)
-			goto out;
 
-		attr = &evsel->attr;
+		evlist__for_each(session->evlist, evsel) {
+			if (evsel->attr.type != j)
+				continue;
+
+			attr = &evsel->attr;
 
-		if (attr->sample_type & PERF_SAMPLE_CALLCHAIN) {
-			output[j].fields |= PERF_OUTPUT_IP;
-			output[j].fields |= PERF_OUTPUT_SYM;
-			output[j].fields |= PERF_OUTPUT_DSO;
-			set_print_ip_opts(attr);
+			if (attr->sample_type & PERF_SAMPLE_CALLCHAIN) {
+				output[j].fields |= PERF_OUTPUT_IP;
+				output[j].fields |= PERF_OUTPUT_SYM;
+				output[j].fields |= PERF_OUTPUT_DSO;
+				set_print_ip_opts(attr);
+				goto out;
+			}
 		}
 	}
 
-- 
1.8.5.2

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

* Re: [PATCH] perf script: Fix display inconsitency when call-graph config is used
  2016-05-16  4:51 [PATCH] perf script: Fix display inconsitency when call-graph config is used He Kuang
@ 2016-05-27  3:47 ` Hekuang
  2016-06-03  8:38 ` Wangnan (F)
  2016-06-08  8:37 ` [tip:perf/core] perf script: Show call graphs when 1st event doesn't have it but some other has tip-bot for He Kuang
  2 siblings, 0 replies; 5+ messages in thread
From: Hekuang @ 2016-05-27  3:47 UTC (permalink / raw)
  To: peterz, mingo, acme, alexander.shishkin, wangnan0; +Cc: linux-kernel

ping..

在 2016/5/16 12:51, He Kuang 写道:
> There's a display inconsistency when 'call-graph' config event appears
> in different position. The problem can be reproduced like this:
>
> We record signal_deliver with call-graph and signal_generate without it.
>
>    $ perf record -g -a -e signal:signal_deliver -e signal:signal_generate/call-graph=no/
>
>    [ perf record: Captured and wrote 0.017 MB perf.data (2 samples) ]
>
>    $ perf script
>
>    kworker/u2:1    13 [000]  6563.875949: signal:signal_generate: sig=2 errno=0 code=128 comm=perf pid=1313 grp=1 res=0 ff61cc __send_signal+0x3ec ([kernel.kallsyms])
>    perf  1313 [000]  6563.877584:  signal:signal_deliver: sig=2 errno=0 code=128 sa_handler=43115e sa_flags=14000000
>                7ffff314 get_signal+0x80007f0023a4 ([kernel.kallsyms])
>                7fffe358 do_signal+0x80007f002028 ([kernel.kallsyms])
>                7fffa5e8 exit_to_usermode_loop+0x80007f002053 ([kernel.kallsyms])
>                ...
>
> Then we exchange the order of these two events in commandline, and keep
> signal_generate without call-graph.
>
>    $ perf record -g -a -e signal:signal_generate/call-graph=no/ -e signal:signal_deliver
>
>    [ perf record: Captured and wrote 0.017 MB perf.data (2 samples) ]
>
>    $ perf script
>
>      kworker/u2:2  1314 [000]  6933.353060: signal:signal_generate: sig=2 errno=0 code=128 comm=perf pid=1321 grp=1 res=0
>              perf  1321 [000]  6933.353872:  signal:signal_deliver: sig=2 errno=0 code=128 sa_handler=43115e sa_flags=14000000
>
> This time, the callchain of the event signal_deliver disappeared. The
> problem is caused by that perf only checks for the first evsel in evlist
> and decides if callchain should be printed.
>
> This patch travseres all evsels in evlist to see if any of them have
> callchains, and shows the right result:
>
>    $ perf script
>
>    kworker/u2:2  1314 [000]  6933.353060: signal:signal_generate: sig=2 errno=0 code=128 comm=perf pid=1321 grp=1 res=0 ff61cc __send_signal+0x3ec ([kernel.kallsyms])
>    perf  1321 [000]  6933.353872:  signal:signal_deliver: sig=2 errno=0 code=128 sa_handler=43115e sa_flags=14000000
>                7ffff314 get_signal+0x80007f0023a4 ([kernel.kallsyms])
>                7fffe358 do_signal+0x80007f002028 ([kernel.kallsyms])
>                7fffa5e8 exit_to_usermode_loop+0x80007f002053 ([kernel.kallsyms])
>                ...
>
> Signed-off-by: He Kuang <hekuang@huawei.com>
> ---
>   tools/perf/builtin-script.c | 23 +++++++++++++----------
>   1 file changed, 13 insertions(+), 10 deletions(-)
>
> diff --git a/tools/perf/builtin-script.c b/tools/perf/builtin-script.c
> index efca816..7a18b92 100644
> --- a/tools/perf/builtin-script.c
> +++ b/tools/perf/builtin-script.c
> @@ -339,7 +339,7 @@ static void set_print_ip_opts(struct perf_event_attr *attr)
>    */
>   static int perf_session__check_output_opt(struct perf_session *session)
>   {
> -	int j;
> +	unsigned int j;
>   	struct perf_evsel *evsel;
>   
>   	for (j = 0; j < PERF_TYPE_MAX; ++j) {
> @@ -388,17 +388,20 @@ static int perf_session__check_output_opt(struct perf_session *session)
>   		struct perf_event_attr *attr;
>   
>   		j = PERF_TYPE_TRACEPOINT;
> -		evsel = perf_session__find_first_evtype(session, j);
> -		if (evsel == NULL)
> -			goto out;
>   
> -		attr = &evsel->attr;
> +		evlist__for_each(session->evlist, evsel) {
> +			if (evsel->attr.type != j)
> +				continue;
> +
> +			attr = &evsel->attr;
>   
> -		if (attr->sample_type & PERF_SAMPLE_CALLCHAIN) {
> -			output[j].fields |= PERF_OUTPUT_IP;
> -			output[j].fields |= PERF_OUTPUT_SYM;
> -			output[j].fields |= PERF_OUTPUT_DSO;
> -			set_print_ip_opts(attr);
> +			if (attr->sample_type & PERF_SAMPLE_CALLCHAIN) {
> +				output[j].fields |= PERF_OUTPUT_IP;
> +				output[j].fields |= PERF_OUTPUT_SYM;
> +				output[j].fields |= PERF_OUTPUT_DSO;
> +				set_print_ip_opts(attr);
> +				goto out;
> +			}
>   		}
>   	}
>   

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

* Re: [PATCH] perf script: Fix display inconsitency when call-graph config is used
  2016-05-16  4:51 [PATCH] perf script: Fix display inconsitency when call-graph config is used He Kuang
  2016-05-27  3:47 ` Hekuang
@ 2016-06-03  8:38 ` Wangnan (F)
  2016-06-03 14:39   ` Arnaldo Carvalho de Melo
  2016-06-08  8:37 ` [tip:perf/core] perf script: Show call graphs when 1st event doesn't have it but some other has tip-bot for He Kuang
  2 siblings, 1 reply; 5+ messages in thread
From: Wangnan (F) @ 2016-06-03  8:38 UTC (permalink / raw)
  To: acme, alexander.shishkin, dsahern; +Cc: He Kuang, peterz, mingo, linux-kernel

Hi, Arnaldo and David,

Could you please have a look at this patch? It solves a perf script 
problem when
dealing with mixed call-graph and no-call-graph events.

Thank you.

On 2016/5/16 12:51, He Kuang wrote:
> There's a display inconsistency when 'call-graph' config event appears
> in different position. The problem can be reproduced like this:
>
> We record signal_deliver with call-graph and signal_generate without it.
>
>    $ perf record -g -a -e signal:signal_deliver -e signal:signal_generate/call-graph=no/
>
>    [ perf record: Captured and wrote 0.017 MB perf.data (2 samples) ]
>
>    $ perf script
>
>    kworker/u2:1    13 [000]  6563.875949: signal:signal_generate: sig=2 errno=0 code=128 comm=perf pid=1313 grp=1 res=0 ff61cc __send_signal+0x3ec ([kernel.kallsyms])
>    perf  1313 [000]  6563.877584:  signal:signal_deliver: sig=2 errno=0 code=128 sa_handler=43115e sa_flags=14000000
>                7ffff314 get_signal+0x80007f0023a4 ([kernel.kallsyms])
>                7fffe358 do_signal+0x80007f002028 ([kernel.kallsyms])
>                7fffa5e8 exit_to_usermode_loop+0x80007f002053 ([kernel.kallsyms])
>                ...
>
> Then we exchange the order of these two events in commandline, and keep
> signal_generate without call-graph.
>
>    $ perf record -g -a -e signal:signal_generate/call-graph=no/ -e signal:signal_deliver
>
>    [ perf record: Captured and wrote 0.017 MB perf.data (2 samples) ]
>
>    $ perf script
>
>      kworker/u2:2  1314 [000]  6933.353060: signal:signal_generate: sig=2 errno=0 code=128 comm=perf pid=1321 grp=1 res=0
>              perf  1321 [000]  6933.353872:  signal:signal_deliver: sig=2 errno=0 code=128 sa_handler=43115e sa_flags=14000000
>
> This time, the callchain of the event signal_deliver disappeared. The
> problem is caused by that perf only checks for the first evsel in evlist
> and decides if callchain should be printed.
>
> This patch travseres all evsels in evlist to see if any of them have
> callchains, and shows the right result:
>
>    $ perf script
>
>    kworker/u2:2  1314 [000]  6933.353060: signal:signal_generate: sig=2 errno=0 code=128 comm=perf pid=1321 grp=1 res=0 ff61cc __send_signal+0x3ec ([kernel.kallsyms])
>    perf  1321 [000]  6933.353872:  signal:signal_deliver: sig=2 errno=0 code=128 sa_handler=43115e sa_flags=14000000
>                7ffff314 get_signal+0x80007f0023a4 ([kernel.kallsyms])
>                7fffe358 do_signal+0x80007f002028 ([kernel.kallsyms])
>                7fffa5e8 exit_to_usermode_loop+0x80007f002053 ([kernel.kallsyms])
>                ...
>
> Signed-off-by: He Kuang <hekuang@huawei.com>
> ---
>   tools/perf/builtin-script.c | 23 +++++++++++++----------
>   1 file changed, 13 insertions(+), 10 deletions(-)
>
> diff --git a/tools/perf/builtin-script.c b/tools/perf/builtin-script.c
> index efca816..7a18b92 100644
> --- a/tools/perf/builtin-script.c
> +++ b/tools/perf/builtin-script.c
> @@ -339,7 +339,7 @@ static void set_print_ip_opts(struct perf_event_attr *attr)
>    */
>   static int perf_session__check_output_opt(struct perf_session *session)
>   {
> -	int j;
> +	unsigned int j;
>   	struct perf_evsel *evsel;
>   
>   	for (j = 0; j < PERF_TYPE_MAX; ++j) {
> @@ -388,17 +388,20 @@ static int perf_session__check_output_opt(struct perf_session *session)
>   		struct perf_event_attr *attr;
>   
>   		j = PERF_TYPE_TRACEPOINT;
> -		evsel = perf_session__find_first_evtype(session, j);
> -		if (evsel == NULL)
> -			goto out;
>   
> -		attr = &evsel->attr;
> +		evlist__for_each(session->evlist, evsel) {
> +			if (evsel->attr.type != j)
> +				continue;
> +
> +			attr = &evsel->attr;
>   
> -		if (attr->sample_type & PERF_SAMPLE_CALLCHAIN) {
> -			output[j].fields |= PERF_OUTPUT_IP;
> -			output[j].fields |= PERF_OUTPUT_SYM;
> -			output[j].fields |= PERF_OUTPUT_DSO;
> -			set_print_ip_opts(attr);
> +			if (attr->sample_type & PERF_SAMPLE_CALLCHAIN) {
> +				output[j].fields |= PERF_OUTPUT_IP;
> +				output[j].fields |= PERF_OUTPUT_SYM;
> +				output[j].fields |= PERF_OUTPUT_DSO;
> +				set_print_ip_opts(attr);
> +				goto out;
> +			}
>   		}
>   	}
>   

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

* Re: [PATCH] perf script: Fix display inconsitency when call-graph config is used
  2016-06-03  8:38 ` Wangnan (F)
@ 2016-06-03 14:39   ` Arnaldo Carvalho de Melo
  0 siblings, 0 replies; 5+ messages in thread
From: Arnaldo Carvalho de Melo @ 2016-06-03 14:39 UTC (permalink / raw)
  To: Wangnan (F)
  Cc: alexander.shishkin, dsahern, He Kuang, peterz, mingo, linux-kernel

Em Fri, Jun 03, 2016 at 04:38:04PM +0800, Wangnan (F) escreveu:
> Hi, Arnaldo and David,
> 
> Could you please have a look at this patch? It solves a perf script problem
> when
> dealing with mixed call-graph and no-call-graph events.

Sorry for the delay, I reproduced the problem and applied the patch,
thanks a lot!

- Arnaldo
 
> Thank you.
> 
> On 2016/5/16 12:51, He Kuang wrote:
> > There's a display inconsistency when 'call-graph' config event appears
> > in different position. The problem can be reproduced like this:
> > 
> > We record signal_deliver with call-graph and signal_generate without it.
> > 
> >    $ perf record -g -a -e signal:signal_deliver -e signal:signal_generate/call-graph=no/
> > 
> >    [ perf record: Captured and wrote 0.017 MB perf.data (2 samples) ]
> > 
> >    $ perf script
> > 
> >    kworker/u2:1    13 [000]  6563.875949: signal:signal_generate: sig=2 errno=0 code=128 comm=perf pid=1313 grp=1 res=0 ff61cc __send_signal+0x3ec ([kernel.kallsyms])
> >    perf  1313 [000]  6563.877584:  signal:signal_deliver: sig=2 errno=0 code=128 sa_handler=43115e sa_flags=14000000
> >                7ffff314 get_signal+0x80007f0023a4 ([kernel.kallsyms])
> >                7fffe358 do_signal+0x80007f002028 ([kernel.kallsyms])
> >                7fffa5e8 exit_to_usermode_loop+0x80007f002053 ([kernel.kallsyms])
> >                ...
> > 
> > Then we exchange the order of these two events in commandline, and keep
> > signal_generate without call-graph.
> > 
> >    $ perf record -g -a -e signal:signal_generate/call-graph=no/ -e signal:signal_deliver
> > 
> >    [ perf record: Captured and wrote 0.017 MB perf.data (2 samples) ]
> > 
> >    $ perf script
> > 
> >      kworker/u2:2  1314 [000]  6933.353060: signal:signal_generate: sig=2 errno=0 code=128 comm=perf pid=1321 grp=1 res=0
> >              perf  1321 [000]  6933.353872:  signal:signal_deliver: sig=2 errno=0 code=128 sa_handler=43115e sa_flags=14000000
> > 
> > This time, the callchain of the event signal_deliver disappeared. The
> > problem is caused by that perf only checks for the first evsel in evlist
> > and decides if callchain should be printed.
> > 
> > This patch travseres all evsels in evlist to see if any of them have
> > callchains, and shows the right result:
> > 
> >    $ perf script
> > 
> >    kworker/u2:2  1314 [000]  6933.353060: signal:signal_generate: sig=2 errno=0 code=128 comm=perf pid=1321 grp=1 res=0 ff61cc __send_signal+0x3ec ([kernel.kallsyms])
> >    perf  1321 [000]  6933.353872:  signal:signal_deliver: sig=2 errno=0 code=128 sa_handler=43115e sa_flags=14000000
> >                7ffff314 get_signal+0x80007f0023a4 ([kernel.kallsyms])
> >                7fffe358 do_signal+0x80007f002028 ([kernel.kallsyms])
> >                7fffa5e8 exit_to_usermode_loop+0x80007f002053 ([kernel.kallsyms])
> >                ...
> > 
> > Signed-off-by: He Kuang <hekuang@huawei.com>
> > ---
> >   tools/perf/builtin-script.c | 23 +++++++++++++----------
> >   1 file changed, 13 insertions(+), 10 deletions(-)
> > 
> > diff --git a/tools/perf/builtin-script.c b/tools/perf/builtin-script.c
> > index efca816..7a18b92 100644
> > --- a/tools/perf/builtin-script.c
> > +++ b/tools/perf/builtin-script.c
> > @@ -339,7 +339,7 @@ static void set_print_ip_opts(struct perf_event_attr *attr)
> >    */
> >   static int perf_session__check_output_opt(struct perf_session *session)
> >   {
> > -	int j;
> > +	unsigned int j;
> >   	struct perf_evsel *evsel;
> >   	for (j = 0; j < PERF_TYPE_MAX; ++j) {
> > @@ -388,17 +388,20 @@ static int perf_session__check_output_opt(struct perf_session *session)
> >   		struct perf_event_attr *attr;
> >   		j = PERF_TYPE_TRACEPOINT;
> > -		evsel = perf_session__find_first_evtype(session, j);
> > -		if (evsel == NULL)
> > -			goto out;
> > -		attr = &evsel->attr;
> > +		evlist__for_each(session->evlist, evsel) {
> > +			if (evsel->attr.type != j)
> > +				continue;
> > +
> > +			attr = &evsel->attr;
> > -		if (attr->sample_type & PERF_SAMPLE_CALLCHAIN) {
> > -			output[j].fields |= PERF_OUTPUT_IP;
> > -			output[j].fields |= PERF_OUTPUT_SYM;
> > -			output[j].fields |= PERF_OUTPUT_DSO;
> > -			set_print_ip_opts(attr);
> > +			if (attr->sample_type & PERF_SAMPLE_CALLCHAIN) {
> > +				output[j].fields |= PERF_OUTPUT_IP;
> > +				output[j].fields |= PERF_OUTPUT_SYM;
> > +				output[j].fields |= PERF_OUTPUT_DSO;
> > +				set_print_ip_opts(attr);
> > +				goto out;
> > +			}
> >   		}
> >   	}
> 

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

* [tip:perf/core] perf script: Show call graphs when 1st event doesn't have it but some other has
  2016-05-16  4:51 [PATCH] perf script: Fix display inconsitency when call-graph config is used He Kuang
  2016-05-27  3:47 ` Hekuang
  2016-06-03  8:38 ` Wangnan (F)
@ 2016-06-08  8:37 ` tip-bot for He Kuang
  2 siblings, 0 replies; 5+ messages in thread
From: tip-bot for He Kuang @ 2016-06-08  8:37 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: alexander.shishkin, hpa, wangnan0, hekuang, acme, peterz, mingo,
	linux-kernel, tglx, mingo

Commit-ID:  40f20e5074b035c7111e135aa939d1d1a96a2480
Gitweb:     http://git.kernel.org/tip/40f20e5074b035c7111e135aa939d1d1a96a2480
Author:     He Kuang <hekuang@huawei.com>
AuthorDate: Mon, 16 May 2016 04:51:19 +0000
Committer:  Arnaldo Carvalho de Melo <acme@redhat.com>
CommitDate: Fri, 3 Jun 2016 14:53:46 -0300

perf script: Show call graphs when 1st event doesn't have it but some other has

There's a display inconsistency when there are multiple tracepoint
events, some of which have the 'call-graph' config option set but the
first one hasn't, i.e. the whole logic for call graph processing is
enabled only if the first tracepoint event has call-graph set.

For instance, if we record signal_deliver with call-graph and
signal_generate without:

  $ perf record -g -a -e signal:signal_deliver -e signal:signal_generate/call-graph=no/

  [ perf record: Captured and wrote 0.017 MB perf.data (2 samples) ]

  $ perf script

  kworker/u2:1    13 [000]  6563.875949: signal:signal_generate: sig=2 errno=0 code=128 comm=perf pid=1313 grp=1 res=0 ff61cc __send_signal+0x3ec ([kernel.kallsyms])
  perf  1313 [000]  6563.877584:  signal:signal_deliver: sig=2 errno=0 code=128 sa_handler=43115e sa_flags=14000000
              7ffff314 get_signal+0x80007f0023a4 ([kernel.kallsyms])
              7fffe358 do_signal+0x80007f002028 ([kernel.kallsyms])
              7fffa5e8 exit_to_usermode_loop+0x80007f002053 ([kernel.kallsyms])
              ...

Then we exchange the order of these two events in commandline, and keep
signal_generate without call-graph.

  $ perf record -g -a -e signal:signal_generate/call-graph=no/ -e signal:signal_deliver

  [ perf record: Captured and wrote 0.017 MB perf.data (2 samples) ]

  $ perf script

    kworker/u2:2  1314 [000]  6933.353060: signal:signal_generate: sig=2 errno=0 code=128 comm=perf pid=1321 grp=1 res=0
            perf  1321 [000]  6933.353872:  signal:signal_deliver: sig=2 errno=0 code=128 sa_handler=43115e sa_flags=14000000

This time, the callchain of the event signal_deliver disappeared. The
problem is caused by that perf only checks for the first evsel in evlist
and decides if callchain should be printed.

This patch traverses all evsels in evlist to see if any of them have
callchains, and shows the right result:

  $ perf script

  kworker/u2:2  1314 [000]  6933.353060: signal:signal_generate: sig=2 errno=0 code=128 comm=perf pid=1321 grp=1 res=0 ff61cc __send_signal+0x3ec ([kernel.kallsyms])
  perf  1321 [000]  6933.353872:  signal:signal_deliver: sig=2 errno=0 code=128 sa_handler=43115e sa_flags=14000000
              7ffff314 get_signal+0x80007f0023a4 ([kernel.kallsyms])
              7fffe358 do_signal+0x80007f002028 ([kernel.kallsyms])
              7fffa5e8 exit_to_usermode_loop+0x80007f002053 ([kernel.kallsyms])
              ...

Signed-off-by: He Kuang <hekuang@huawei.com>
Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Wang Nan <wangnan0@huawei.com>
Link: http://lkml.kernel.org/r/1463374279-97209-1-git-send-email-hekuang@huawei.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 tools/perf/builtin-script.c | 23 +++++++++++++----------
 1 file changed, 13 insertions(+), 10 deletions(-)

diff --git a/tools/perf/builtin-script.c b/tools/perf/builtin-script.c
index e3ce2f3..4601123 100644
--- a/tools/perf/builtin-script.c
+++ b/tools/perf/builtin-script.c
@@ -339,7 +339,7 @@ static void set_print_ip_opts(struct perf_event_attr *attr)
  */
 static int perf_session__check_output_opt(struct perf_session *session)
 {
-	int j;
+	unsigned int j;
 	struct perf_evsel *evsel;
 
 	for (j = 0; j < PERF_TYPE_MAX; ++j) {
@@ -388,17 +388,20 @@ static int perf_session__check_output_opt(struct perf_session *session)
 		struct perf_event_attr *attr;
 
 		j = PERF_TYPE_TRACEPOINT;
-		evsel = perf_session__find_first_evtype(session, j);
-		if (evsel == NULL)
-			goto out;
 
-		attr = &evsel->attr;
+		evlist__for_each(session->evlist, evsel) {
+			if (evsel->attr.type != j)
+				continue;
+
+			attr = &evsel->attr;
 
-		if (attr->sample_type & PERF_SAMPLE_CALLCHAIN) {
-			output[j].fields |= PERF_OUTPUT_IP;
-			output[j].fields |= PERF_OUTPUT_SYM;
-			output[j].fields |= PERF_OUTPUT_DSO;
-			set_print_ip_opts(attr);
+			if (attr->sample_type & PERF_SAMPLE_CALLCHAIN) {
+				output[j].fields |= PERF_OUTPUT_IP;
+				output[j].fields |= PERF_OUTPUT_SYM;
+				output[j].fields |= PERF_OUTPUT_DSO;
+				set_print_ip_opts(attr);
+				goto out;
+			}
 		}
 	}
 

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

end of thread, other threads:[~2016-06-08  8:38 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-05-16  4:51 [PATCH] perf script: Fix display inconsitency when call-graph config is used He Kuang
2016-05-27  3:47 ` Hekuang
2016-06-03  8:38 ` Wangnan (F)
2016-06-03 14:39   ` Arnaldo Carvalho de Melo
2016-06-08  8:37 ` [tip:perf/core] perf script: Show call graphs when 1st event doesn't have it but some other has tip-bot for He Kuang

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).