Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1347103 > unrolled thread

[PATCH] perf, tools, stat: Avoid crash with --per-thread

Started byAndi Kleen <andi@firstfloor.org>
First post2016-03-02 00:40 +0100
Last post2016-03-02 13:20 +0100
Articles 3 — 3 participants

Back to article view | Back to linux.kernel


Contents

  [PATCH] perf, tools, stat: Avoid crash with --per-thread Andi Kleen <andi@firstfloor.org> - 2016-03-02 00:40 +0100
    Re: [PATCH] perf, tools, stat: Avoid crash with --per-thread Jiri Olsa <jolsa@redhat.com> - 2016-03-02 07:40 +0100
      Re: [PATCH] perf, tools, stat: Avoid crash with --per-thread Arnaldo Carvalho de Melo <acme@kernel.org> - 2016-03-02 13:20 +0100

#1347103 — [PATCH] perf, tools, stat: Avoid crash with --per-thread

FromAndi Kleen <andi@firstfloor.org>
Date2016-03-02 00:40 +0100
Subject[PATCH] perf, tools, stat: Avoid crash with --per-thread
Message-ID<r823v-7Ff-13@gated-at.bofh.it>
From: Andi Kleen <ak@linux.intel.com>

Bug fix:

The earlier metrics changes broke --per-thread causing a segfault.
Handle this case correctly. We actually don't print metrics
in per thread mode, so using a 0 shadow CPU is fine.

Could be folded into
"perf, tools, stat: Support metrics in --per-core/socket mode"

Signed-off-by: Andi Kleen <ak@linux.intel.com>
---
 tools/perf/builtin-stat.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/tools/perf/builtin-stat.c b/tools/perf/builtin-stat.c
index c11374b..52a37a5 100644
--- a/tools/perf/builtin-stat.c
+++ b/tools/perf/builtin-stat.c
@@ -977,6 +977,9 @@ static int first_shadow_cpu(struct perf_evsel *evsel, int id)
 {
 	int i;
 
+	if (!aggr_get_id)
+		return 0;
+
 	if (stat_config.aggr_mode == AGGR_NONE)
 		return id;
 
-- 
2.5.0

[toc] | [next] | [standalone]


#1347805

FromJiri Olsa <jolsa@redhat.com>
Date2016-03-02 07:40 +0100
Message-ID<r88BY-3Mu-3@gated-at.bofh.it>
In reply to#1347103
On Tue, Mar 01, 2016 at 03:32:37PM -0800, Andi Kleen wrote:
> From: Andi Kleen <ak@linux.intel.com>
> 
> Bug fix:
> 
> The earlier metrics changes broke --per-thread causing a segfault.
> Handle this case correctly. We actually don't print metrics
> in per thread mode, so using a 0 shadow CPU is fine.

right, so --per-thread paths go through perf_stat__print_shadow_stats
but never actually collect shadow data, so it does not print anything

we would need somehow map each thread to the shadow cpu.. I'll try
to come up with something.. however:

Acked-by: Jiri Olsa <jolsa@kernel.org>

thanks,
jirka


> 
> Could be folded into
> "perf, tools, stat: Support metrics in --per-core/socket mode"
> 
> Signed-off-by: Andi Kleen <ak@linux.intel.com>
> ---
>  tools/perf/builtin-stat.c | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/tools/perf/builtin-stat.c b/tools/perf/builtin-stat.c
> index c11374b..52a37a5 100644
> --- a/tools/perf/builtin-stat.c
> +++ b/tools/perf/builtin-stat.c
> @@ -977,6 +977,9 @@ static int first_shadow_cpu(struct perf_evsel *evsel, int id)
>  {
>  	int i;
>  
> +	if (!aggr_get_id)
> +		return 0;
> +
>  	if (stat_config.aggr_mode == AGGR_NONE)
>  		return id;
>  
> -- 
> 2.5.0
> 

[toc] | [prev] | [next] | [standalone]


#1347995

FromArnaldo Carvalho de Melo <acme@kernel.org>
Date2016-03-02 13:20 +0100
Message-ID<r8dV0-7rI-15@gated-at.bofh.it>
In reply to#1347805
Em Wed, Mar 02, 2016 at 07:36:59AM +0100, Jiri Olsa escreveu:
> On Tue, Mar 01, 2016 at 03:32:37PM -0800, Andi Kleen wrote:
> > From: Andi Kleen <ak@linux.intel.com>
> > 
> > Bug fix:
> > 
> > The earlier metrics changes broke --per-thread causing a segfault.
> > Handle this case correctly. We actually don't print metrics
> > in per thread mode, so using a 0 shadow CPU is fine.
> 
> right, so --per-thread paths go through perf_stat__print_shadow_stats
> but never actually collect shadow data, so it does not print anything
> 
> we would need somehow map each thread to the shadow cpu.. I'll try
> to come up with something.. however:
> 
> Acked-by: Jiri Olsa <jolsa@kernel.org>

Kept the ack for the previous commit ("Support metrics in
--per-core/socket mode")

> > Could be folded into
> > "perf, tools, stat: Support metrics in --per-core/socket mode"

And used 'git rebase --interactive' to 'fixup' this into it, i.e. do
what Andi suggested to avoid breaking the 'perf stat --per-thread'
bisection since this one hasn't been pushed to Ingo yet.

Thanks,

- Arnaldo

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web