Skip to contentSkip to conversation

perf, tools, stat: Avoid crash with --per-thread

PATCH In review Andi Kleen 3 participants 3 messages Mar 1, 2016 – Mar 2, 2016 perf events

lore
Share & tools
lore

Andi Kleen

author
#0 lore raw

PATCH 1/1 perf, tools, stat: Avoid crash with --per-thread

From: Andi Kleen <[email protected]>

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"

---
 tools/perf/builtin-stat.c | 3 +++
 1 file changed, 3 insertions(+)
tools/perf/builtin-stat.c +3 -0
index c11374b..52a37a5 100644
@@ -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;
 
Signature · 1 line
2.5.0
Acked-by on v1 1/1
#1 lore raw
Quoted 7 lines · Andi Kleen

From: Andi Kleen <[email protected]>

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:

thanks,
jirka

Quoted 26 lines

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

---
 tools/perf/builtin-stat.c | 3 +++
 1 file changed, 3 insertions(+)
tools/perf/builtin-stat.c +3 -0
index c11374b..52a37a5 100644
@@ -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;
 
Signature · 1 line
2.5.0
#2 lore raw

Em Wed, Mar 02, 2016 at 07:36:59AM +0100, Jiri Olsa escreveu:

Quoted 9 lines · Andi Kleen
Quoted 7 lines

From: Andi Kleen <[email protected]>

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.

Quoted 7 lines

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:

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

Quoted 2 lines
Quoted 2 lines

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