Skip to content

Commit b4229e9

Browse files
Andi Kleenacmel
authored andcommitted
perf stat: Handle partially bad results with merging
When any result that is being merged is bad, mark them all bad to give consistent output in interval mode. No before/after, because the issue was only found in theoretical review and it is hard to reproduce Signed-off-by: Andi Kleen <[email protected]> Acked-by: Jiri Olsa <[email protected]> Link: http://lkml.kernel.org/r/[email protected] Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
1 parent 430daf2 commit b4229e9

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

tools/perf/builtin-stat.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1237,6 +1237,16 @@ static void aggr_cb(struct perf_evsel *counter, void *data, bool first)
12371237
if (first)
12381238
ad->nr++;
12391239
counts = perf_counts(counter->counts, cpu, 0);
1240+
/*
1241+
* When any result is bad, make them all to give
1242+
* consistent output in interval mode.
1243+
*/
1244+
if (counts->ena == 0 || counts->run == 0 ||
1245+
counter->counts->scaled == -1) {
1246+
ad->ena = 0;
1247+
ad->run = 0;
1248+
break;
1249+
}
12401250
ad->val += counts->val;
12411251
ad->ena += counts->ena;
12421252
ad->run += counts->run;

0 commit comments

Comments
 (0)