perf, tools, stat: Fix perf stat -T
PATCH 1/1 perf, tools, stat: Fix perf stat -T
From: Andi Kleen <[email protected]>
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.
--- tools/perf/util/stat-shadow.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-)
tools/perf/util/stat-shadow.c +3 -5
@@ -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 ))update_stats (&runtime_cycles_stats[ctx][cpu], count[0 ]);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 ))update_stats (&runtime_transaction_stats[ctx][cpu], count[0 ]);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," # %5.2f%% aborted cycles " , 100.0 * ((total2-avg) / total)); }else if (perf_stat_evsel__is (evsel,TRANSACTION_START ) && - avg >0 && runtime_cycles_in_tx_stats[ctx][cpu].n !=0 ) { total =avg_stats (&runtime_cycles_in_tx_stats[ctx][cpu]); -if (total) +if (avg) ratio = total / avg;fprintf (out," # %8.0f cycles / transaction " , ratio); }else if (perf_stat_evsel__is (evsel,ELISION_START ) && - avg >0 && runtime_cycles_in_tx_stats[ctx][cpu].n !=0 ) { total =avg_stats (&runtime_cycles_in_tx_stats[ctx][cpu]); -if (total) +if (avg) ratio = total / avg;fprintf (out," # %8.0f cycles / elision " , ratio);
Signature · 1 line
2.4.3
Quoted 21 lines · Andi Kleen
From: Andi Kleen <[email protected]>
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_txstatistics. 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 <[email protected]>--- tools/perf/util/stat-shadow.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-)tools/perf/util/stat-shadow.c +0
-0
tools/perf/util/stat-shadow.c void perf_stat__update_shadow_stats(struct perf_evsel *counter, u64 *count, · line 88
Quoted 5 lines
tools/perf/util/stat-shadow.c +1
-1@@ -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 ))update_stats (&runtime_cycles_stats[ctx][cpu], count[0 ]);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 ]);
oops, looks like copy&paste issue.. thanks
Quoted 17 lines
tools/perf/util/stat-shadow.c +1
-2else if (perf_stat_evsel__is (counter,TRANSACTION_START ))update_stats (&runtime_transaction_stats[ctx][cpu], count[0 ]);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," # %5.2f%% aborted cycles " , 100.0 * ((total2-avg) / total)); }else if (perf_stat_evsel__is (evsel,TRANSACTION_START ) && - avg >0 && runtime_cycles_in_tx_stats[ctx][cpu].n !=0 ) { total =avg_stats (&runtime_cycles_in_tx_stats[ctx][cpu]); -if (total) +if (avg) ratio = total / avg;fprintf (out," # %8.0f cycles / transaction " , ratio);
tools/perf/util/stat-shadow.c void perf_stat__print_shadow_stats(FILE *out, struct perf_evsel *evsel, · line 415
Quoted 10 lines
tools/perf/util/stat-shadow.c +1
-2}else if (perf_stat_evsel__is (evsel,ELISION_START ) && - avg >0 && runtime_cycles_in_tx_stats[ctx][cpu].n !=0 ) { total =avg_stats (&runtime_cycles_in_tx_stats[ctx][cpu]); -if (total) +if (avg) ratio = total / avg;fprintf (out," # %8.0f cycles / elision " , ratio);
we now print comment line if the avg is 0, but I think it's ok
thanks,
jirka
Arnaldo Carvalho de Melo
maintainerEm Tue, Jul 28, 2015 at 04:10:06PM +0200, Jiri Olsa escreveu:
Quoted 31 lines · Andi Kleen
Quoted 21 lines
From: Andi Kleen <[email protected]>
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_txstatistics. 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 <[email protected]>--- tools/perf/util/stat-shadow.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-)tools/perf/util/stat-shadow.c +0
-0tools/perf/util/stat-shadow.c void perf_stat__update_shadow_stats(struct perf_evsel *counter, u64 *count, · line 88
Quoted 5 lines
tools/perf/util/stat-shadow.c +1
-1@@ -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 ))update_stats (&runtime_cycles_stats[ctx][cpu], count[0 ]);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 ]);oops, looks like copy&paste issue.. thanks
Quoted 3 lines
we now print comment line if the avg is 0, but I think it's ok
Acked-by Jiri Olsa <[email protected]>
This affects just perf/core, right?
Quoted 32 lines · Arnaldo Carvalho de Melo
Em Tue, Jul 28, 2015 at 04:10:06PM +0200, Jiri Olsa escreveu:
Quoted 31 lines · Andi Kleen
Quoted 21 lines
From: Andi Kleen <[email protected]>
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_txstatistics. 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 <[email protected]>--- tools/perf/util/stat-shadow.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-)tools/perf/util/stat-shadow.c +0
-0tools/perf/util/stat-shadow.c void perf_stat__update_shadow_stats(struct perf_evsel *counter, u64 *count, · line 88
Quoted 5 lines
tools/perf/util/stat-shadow.c +1
-1@@ -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 ))update_stats (&runtime_cycles_stats[ctx][cpu], count[0 ]);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 ]);oops, looks like copy&paste issue.. thanks
Quoted 5 lines
Quoted 3 lines
we now print comment line if the avg is 0, but I think it's ok
Acked-by Jiri Olsa <[email protected]>This affects just perf/core, right?
I guess, dont think it's an urgent one.. Andi, please speak up ;-)
jirka
Arnaldo Carvalho de Melo
maintainerEm Tue, Jul 28, 2015 at 04:30:18PM +0200, Jiri Olsa escreveu:
Quoted 8 lines · Arnaldo Carvalho de Melo
Quoted 6 lines
Em Tue, Jul 28, 2015 at 04:10:06PM +0200, Jiri Olsa escreveu:
Quoted 5 lines · Andi Kleen
tools/perf/util/stat-shadow.c void perf_stat__update_shadow_stats(struct perf_evsel *counter, u64 *count, · line 88
Quoted 2 lines
+++
b/tools/perf/util/stat-shadow.ctools/perf/util/stat-shadow.c +1
-0+update_stats (&runtime_cycles_in_tx_stats[ctx][cpu], count[0 ]);oops, looks like copy&paste issue.. thanks
Quoted 7 lines
Quoted 5 lines
Quoted 3 lines
we now print comment line if the avg is 0, but I think it's ok
Acked-by Jiri Olsa <[email protected]>This affects just perf/core, right?
I guess, dont think it's an urgent one.. Andi, please speak up ;-)
I'm not talking about it being urgent or not, I'm talking about it being a bug present only in perf/core or if this is something that is in perf/urgent, i.e. affects what is in Linus's upstream tree, etc.
- Arnaldo
Quoted 13 lines · Arnaldo Carvalho de Melo
Em Tue, Jul 28, 2015 at 04:30:18PM +0200, Jiri Olsa escreveu:
Quoted 11 lines · Arnaldo Carvalho de Melo
Quoted 10 lines
Em Tue, Jul 28, 2015 at 04:10:06PM +0200, Jiri Olsa escreveu:
Quoted 9 lines · Andi Kleen
tools/perf/util/stat-shadow.c void perf_stat__update_shadow_stats(struct perf_evsel *counter, u64 *count, · line 88
Quoted 2 lines
+++
b/tools/perf/util/stat-shadow.ctools/perf/util/stat-shadow.c +1
-0+update_stats (&runtime_cycles_in_tx_stats[ctx][cpu], count[0 ]);oops, looks like copy&paste issue.. thanks
we now print comment line if the avg is 0, but I think it's ok
Acked-by Jiri Olsa <[email protected]>
Quoted 7 lines
Quoted 3 lines
Quoted 1 line
This affects just perf/core, right?
I guess, dont think it's an urgent one.. Andi, please speak up ;-)
I'm not talking about it being urgent or not, I'm talking about it being a bug present only in perf/core or if this is something that is in perf/urgent, i.e. affects what is in Linus's upstream tree, etc.
ah ok, it affects perf/urgent as well
jirka
Quoted 5 lines
Quoted 3 lines
I'm not talking about it being urgent or not, I'm talking about it being a bug present only in perf/core or if this is something that is in perf/urgent, i.e. affects what is in Linus's upstream tree, etc.
ah ok, it affects perf/urgent as well
I think there are some more typos in the cache statistics. Compare perf stat -d -d -d -d output with an old perf.
-Andi
Signature · 1 line
[email protected] -- Speaking for myself only
tip-bot for Andi Kleen
merge bot[tip:perf/core] perf stat: Fix transaction lenght metrics
In reply to Andi Kleenperf stat: Fix transaction lenght metrics
Commit-ID: 5497628576a3c5f3dbab224fa5a5d027f43d8b50 Gitweb: http://git.kernel.org/tip/5497628576a3c5f3dbab224fa5a5d027f43d8b50 Author: Andi Kleen <[email protected]> AuthorDate: Mon, 27 Jul 2015 16:24:51 -0700 Committer: Arnaldo Carvalho de Melo <[email protected]> CommitDate: Tue, 28 Jul 2015 12:05:04 -0300
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.
--- tools/perf/util/stat-shadow.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-)
tools/perf/util/stat-shadow.c +3 -5
@@ -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 ))update_stats (&runtime_cycles_stats[ctx][cpu], count[0 ]);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 ))update_stats (&runtime_transaction_stats[ctx][cpu], count[0 ]);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," # %5.2f%% aborted cycles " , 100.0 * ((total2-avg) / total)); }else if (perf_stat_evsel__is (evsel,TRANSACTION_START ) && - avg >0 && runtime_cycles_in_tx_stats[ctx][cpu].n !=0 ) { total =avg_stats (&runtime_cycles_in_tx_stats[ctx][cpu]); -if (total) +if (avg) ratio = total / avg;fprintf (out," # %8.0f cycles / transaction " , ratio); }else if (perf_stat_evsel__is (evsel,ELISION_START ) && - avg >0 && runtime_cycles_in_tx_stats[ctx][cpu].n !=0 ) { total =avg_stats (&runtime_cycles_in_tx_stats[ctx][cpu]); -if (total) +if (avg) ratio = total / avg;fprintf (out," # %8.0f cycles / elision " , ratio);