Commit 54976285 authored by Andi Kleen's avatar Andi Kleen Committed by Arnaldo Carvalho de Melo

perf stat: Fix transaction lenght metrics

The transaction length metrics in perf stat -T broke recently.

It would not match the metric correctly and always print K/sec.

This was caused by a incorrect update of the cycles_in_tx statistics.

Update the correct variable.

Also the check for zero division was reversed, which resulted in K/sec
being printed for no transactions. Fix this also up.
Signed-off-by: default avatarAndi Kleen <ak@linux.intel.com>
Acked-by: default avatarJiri Olsa <jolsa@kernel.org>
Link: http://lkml.kernel.org/r/1438039491-22091-1-git-send-email-andi@firstfloor.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
parent 00a2916f
...@@ -85,7 +85,7 @@ void perf_stat__update_shadow_stats(struct perf_evsel *counter, u64 *count, ...@@ -85,7 +85,7 @@ void perf_stat__update_shadow_stats(struct perf_evsel *counter, u64 *count,
else if (perf_evsel__match(counter, HARDWARE, HW_CPU_CYCLES)) else if (perf_evsel__match(counter, HARDWARE, HW_CPU_CYCLES))
update_stats(&runtime_cycles_stats[ctx][cpu], count[0]); update_stats(&runtime_cycles_stats[ctx][cpu], count[0]);
else if (perf_stat_evsel__is(counter, CYCLES_IN_TX)) else if (perf_stat_evsel__is(counter, CYCLES_IN_TX))
update_stats(&runtime_transaction_stats[ctx][cpu], count[0]); update_stats(&runtime_cycles_in_tx_stats[ctx][cpu], count[0]);
else if (perf_stat_evsel__is(counter, TRANSACTION_START)) else if (perf_stat_evsel__is(counter, TRANSACTION_START))
update_stats(&runtime_transaction_stats[ctx][cpu], count[0]); update_stats(&runtime_transaction_stats[ctx][cpu], count[0]);
else if (perf_stat_evsel__is(counter, ELISION_START)) else if (perf_stat_evsel__is(counter, ELISION_START))
...@@ -398,20 +398,18 @@ void perf_stat__print_shadow_stats(FILE *out, struct perf_evsel *evsel, ...@@ -398,20 +398,18 @@ void perf_stat__print_shadow_stats(FILE *out, struct perf_evsel *evsel,
" # %5.2f%% aborted cycles ", " # %5.2f%% aborted cycles ",
100.0 * ((total2-avg) / total)); 100.0 * ((total2-avg) / total));
} else if (perf_stat_evsel__is(evsel, TRANSACTION_START) && } else if (perf_stat_evsel__is(evsel, TRANSACTION_START) &&
avg > 0 &&
runtime_cycles_in_tx_stats[ctx][cpu].n != 0) { runtime_cycles_in_tx_stats[ctx][cpu].n != 0) {
total = avg_stats(&runtime_cycles_in_tx_stats[ctx][cpu]); total = avg_stats(&runtime_cycles_in_tx_stats[ctx][cpu]);
if (total) if (avg)
ratio = total / avg; ratio = total / avg;
fprintf(out, " # %8.0f cycles / transaction ", ratio); fprintf(out, " # %8.0f cycles / transaction ", ratio);
} else if (perf_stat_evsel__is(evsel, ELISION_START) && } else if (perf_stat_evsel__is(evsel, ELISION_START) &&
avg > 0 &&
runtime_cycles_in_tx_stats[ctx][cpu].n != 0) { runtime_cycles_in_tx_stats[ctx][cpu].n != 0) {
total = avg_stats(&runtime_cycles_in_tx_stats[ctx][cpu]); total = avg_stats(&runtime_cycles_in_tx_stats[ctx][cpu]);
if (total) if (avg)
ratio = total / avg; ratio = total / avg;
fprintf(out, " # %8.0f cycles / elision ", ratio); fprintf(out, " # %8.0f cycles / elision ", ratio);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment