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

From: Jiri Olsa
Date: Wed Mar 02 2016 - 01:37:10 EST


On Tue, Mar 01, 2016 at 03:32:37PM -0800, Andi Kleen wrote:
> From: Andi Kleen <ak@xxxxxxxxxxxxxxx>
>
> 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@xxxxxxxxxx>

thanks,
jirka


>
> Could be folded into
> "perf, tools, stat: Support metrics in --per-core/socket mode"
>
> Signed-off-by: Andi Kleen <ak@xxxxxxxxxxxxxxx>
> ---
> 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
>