Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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: Andi Kleen <ak@linux.intel.com>
Acked-by: Jiri Olsa <jolsa@kernel.org>
Link: http://lkml.kernel.org/r/1438039491-22091-1-git-send-email-andi@firstfloor.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>

authored by

Andi Kleen and committed by
Arnaldo Carvalho de Melo
54976285 00a2916f

+3 -5
+3 -5
tools/perf/util/stat-shadow.c
··· 85 85 else if (perf_evsel__match(counter, HARDWARE, HW_CPU_CYCLES)) 86 86 update_stats(&runtime_cycles_stats[ctx][cpu], count[0]); 87 87 else if (perf_stat_evsel__is(counter, CYCLES_IN_TX)) 88 - update_stats(&runtime_transaction_stats[ctx][cpu], count[0]); 88 + update_stats(&runtime_cycles_in_tx_stats[ctx][cpu], count[0]); 89 89 else if (perf_stat_evsel__is(counter, TRANSACTION_START)) 90 90 update_stats(&runtime_transaction_stats[ctx][cpu], count[0]); 91 91 else if (perf_stat_evsel__is(counter, ELISION_START)) ··· 398 398 " # %5.2f%% aborted cycles ", 399 399 100.0 * ((total2-avg) / total)); 400 400 } else if (perf_stat_evsel__is(evsel, TRANSACTION_START) && 401 - avg > 0 && 402 401 runtime_cycles_in_tx_stats[ctx][cpu].n != 0) { 403 402 total = avg_stats(&runtime_cycles_in_tx_stats[ctx][cpu]); 404 403 405 - if (total) 404 + if (avg) 406 405 ratio = total / avg; 407 406 408 407 fprintf(out, " # %8.0f cycles / transaction ", ratio); 409 408 } else if (perf_stat_evsel__is(evsel, ELISION_START) && 410 - avg > 0 && 411 409 runtime_cycles_in_tx_stats[ctx][cpu].n != 0) { 412 410 total = avg_stats(&runtime_cycles_in_tx_stats[ctx][cpu]); 413 411 414 - if (total) 412 + if (avg) 415 413 ratio = total / avg; 416 414 417 415 fprintf(out, " # %8.0f cycles / elision ", ratio);