aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJiri Olsa <jolsa@kernel.org>2015-06-03 10:25:57 -0400
committerArnaldo Carvalho de Melo <acme@redhat.com>2015-06-08 09:30:31 -0400
commit4d982740cd598bdd876d9a396cc919724af32bc9 (patch)
tree3e1c260e493afabeeb985442ec73ec601d65c82d
parent556b1fb7f9c1a9fd43ea4dacd5d14ec39ac6296a (diff)
perf stat: Add output file argument to print_shadow_stats function
As preparation for moving shadow counters code into its own object. Signed-off-by: Jiri Olsa <jolsa@kernel.org> Cc: Andi Kleen <ak@linux.intel.com> Cc: David Ahern <dsahern@gmail.com> Cc: Namhyung Kim <namhyung@kernel.org> Cc: Peter Zijlstra <a.p.zijlstra@chello.nl> Cc: Stephane Eranian <eranian@google.com> Link: http://lkml.kernel.org/r/1433341559-31848-8-git-send-email-jolsa@kernel.org Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
-rw-r--r--tools/perf/builtin-stat.c112
1 files changed, 56 insertions, 56 deletions
diff --git a/tools/perf/builtin-stat.c b/tools/perf/builtin-stat.c
index 2ff2e22aa140..14a75ddb60c7 100644
--- a/tools/perf/builtin-stat.c
+++ b/tools/perf/builtin-stat.c
@@ -899,7 +899,7 @@ static const char *get_ratio_color(enum grc_type type, double ratio)
899 return color; 899 return color;
900} 900}
901 901
902static void print_stalled_cycles_frontend(int cpu, 902static void print_stalled_cycles_frontend(FILE *out, int cpu,
903 struct perf_evsel *evsel 903 struct perf_evsel *evsel
904 __maybe_unused, double avg) 904 __maybe_unused, double avg)
905{ 905{
@@ -914,12 +914,12 @@ static void print_stalled_cycles_frontend(int cpu,
914 914
915 color = get_ratio_color(GRC_STALLED_CYCLES_FE, ratio); 915 color = get_ratio_color(GRC_STALLED_CYCLES_FE, ratio);
916 916
917 fprintf(output, " # "); 917 fprintf(out, " # ");
918 color_fprintf(output, color, "%6.2f%%", ratio); 918 color_fprintf(out, color, "%6.2f%%", ratio);
919 fprintf(output, " frontend cycles idle "); 919 fprintf(out, " frontend cycles idle ");
920} 920}
921 921
922static void print_stalled_cycles_backend(int cpu, 922static void print_stalled_cycles_backend(FILE *out, int cpu,
923 struct perf_evsel *evsel 923 struct perf_evsel *evsel
924 __maybe_unused, double avg) 924 __maybe_unused, double avg)
925{ 925{
@@ -934,12 +934,12 @@ static void print_stalled_cycles_backend(int cpu,
934 934
935 color = get_ratio_color(GRC_STALLED_CYCLES_BE, ratio); 935 color = get_ratio_color(GRC_STALLED_CYCLES_BE, ratio);
936 936
937 fprintf(output, " # "); 937 fprintf(out, " # ");
938 color_fprintf(output, color, "%6.2f%%", ratio); 938 color_fprintf(out, color, "%6.2f%%", ratio);
939 fprintf(output, " backend cycles idle "); 939 fprintf(out, " backend cycles idle ");
940} 940}
941 941
942static void print_branch_misses(int cpu, 942static void print_branch_misses(FILE *out, int cpu,
943 struct perf_evsel *evsel __maybe_unused, 943 struct perf_evsel *evsel __maybe_unused,
944 double avg) 944 double avg)
945{ 945{
@@ -954,12 +954,12 @@ static void print_branch_misses(int cpu,
954 954
955 color = get_ratio_color(GRC_CACHE_MISSES, ratio); 955 color = get_ratio_color(GRC_CACHE_MISSES, ratio);
956 956
957 fprintf(output, " # "); 957 fprintf(out, " # ");
958 color_fprintf(output, color, "%6.2f%%", ratio); 958 color_fprintf(out, color, "%6.2f%%", ratio);
959 fprintf(output, " of all branches "); 959 fprintf(out, " of all branches ");
960} 960}
961 961
962static void print_l1_dcache_misses(int cpu, 962static void print_l1_dcache_misses(FILE *out, int cpu,
963 struct perf_evsel *evsel __maybe_unused, 963 struct perf_evsel *evsel __maybe_unused,
964 double avg) 964 double avg)
965{ 965{
@@ -974,12 +974,12 @@ static void print_l1_dcache_misses(int cpu,
974 974
975 color = get_ratio_color(GRC_CACHE_MISSES, ratio); 975 color = get_ratio_color(GRC_CACHE_MISSES, ratio);
976 976
977 fprintf(output, " # "); 977 fprintf(out, " # ");
978 color_fprintf(output, color, "%6.2f%%", ratio); 978 color_fprintf(out, color, "%6.2f%%", ratio);
979 fprintf(output, " of all L1-dcache hits "); 979 fprintf(out, " of all L1-dcache hits ");
980} 980}
981 981
982static void print_l1_icache_misses(int cpu, 982static void print_l1_icache_misses(FILE *out, int cpu,
983 struct perf_evsel *evsel __maybe_unused, 983 struct perf_evsel *evsel __maybe_unused,
984 double avg) 984 double avg)
985{ 985{
@@ -994,12 +994,12 @@ static void print_l1_icache_misses(int cpu,
994 994
995 color = get_ratio_color(GRC_CACHE_MISSES, ratio); 995 color = get_ratio_color(GRC_CACHE_MISSES, ratio);
996 996
997 fprintf(output, " # "); 997 fprintf(out, " # ");
998 color_fprintf(output, color, "%6.2f%%", ratio); 998 color_fprintf(out, color, "%6.2f%%", ratio);
999 fprintf(output, " of all L1-icache hits "); 999 fprintf(out, " of all L1-icache hits ");
1000} 1000}
1001 1001
1002static void print_dtlb_cache_misses(int cpu, 1002static void print_dtlb_cache_misses(FILE *out, int cpu,
1003 struct perf_evsel *evsel __maybe_unused, 1003 struct perf_evsel *evsel __maybe_unused,
1004 double avg) 1004 double avg)
1005{ 1005{
@@ -1014,12 +1014,12 @@ static void print_dtlb_cache_misses(int cpu,
1014 1014
1015 color = get_ratio_color(GRC_CACHE_MISSES, ratio); 1015 color = get_ratio_color(GRC_CACHE_MISSES, ratio);
1016 1016
1017 fprintf(output, " # "); 1017 fprintf(out, " # ");
1018 color_fprintf(output, color, "%6.2f%%", ratio); 1018 color_fprintf(out, color, "%6.2f%%", ratio);
1019 fprintf(output, " of all dTLB cache hits "); 1019 fprintf(out, " of all dTLB cache hits ");
1020} 1020}
1021 1021
1022static void print_itlb_cache_misses(int cpu, 1022static void print_itlb_cache_misses(FILE *out, int cpu,
1023 struct perf_evsel *evsel __maybe_unused, 1023 struct perf_evsel *evsel __maybe_unused,
1024 double avg) 1024 double avg)
1025{ 1025{
@@ -1034,12 +1034,12 @@ static void print_itlb_cache_misses(int cpu,
1034 1034
1035 color = get_ratio_color(GRC_CACHE_MISSES, ratio); 1035 color = get_ratio_color(GRC_CACHE_MISSES, ratio);
1036 1036
1037 fprintf(output, " # "); 1037 fprintf(out, " # ");
1038 color_fprintf(output, color, "%6.2f%%", ratio); 1038 color_fprintf(out, color, "%6.2f%%", ratio);
1039 fprintf(output, " of all iTLB cache hits "); 1039 fprintf(out, " of all iTLB cache hits ");
1040} 1040}
1041 1041
1042static void print_ll_cache_misses(int cpu, 1042static void print_ll_cache_misses(FILE *out, int cpu,
1043 struct perf_evsel *evsel __maybe_unused, 1043 struct perf_evsel *evsel __maybe_unused,
1044 double avg) 1044 double avg)
1045{ 1045{
@@ -1054,12 +1054,12 @@ static void print_ll_cache_misses(int cpu,
1054 1054
1055 color = get_ratio_color(GRC_CACHE_MISSES, ratio); 1055 color = get_ratio_color(GRC_CACHE_MISSES, ratio);
1056 1056
1057 fprintf(output, " # "); 1057 fprintf(out, " # ");
1058 color_fprintf(output, color, "%6.2f%%", ratio); 1058 color_fprintf(out, color, "%6.2f%%", ratio);
1059 fprintf(output, " of all LL-cache hits "); 1059 fprintf(out, " of all LL-cache hits ");
1060} 1060}
1061 1061
1062static void print_shadow_stats(struct perf_evsel *evsel, double avg, int cpu) 1062static void print_shadow_stats(FILE *out, struct perf_evsel *evsel, double avg, int cpu)
1063{ 1063{
1064 double total, ratio = 0.0, total2; 1064 double total, ratio = 0.0, total2;
1065 int ctx = evsel_context(evsel); 1065 int ctx = evsel_context(evsel);
@@ -1068,59 +1068,59 @@ static void print_shadow_stats(struct perf_evsel *evsel, double avg, int cpu)
1068 total = avg_stats(&runtime_cycles_stats[ctx][cpu]); 1068 total = avg_stats(&runtime_cycles_stats[ctx][cpu]);
1069 if (total) { 1069 if (total) {
1070 ratio = avg / total; 1070 ratio = avg / total;
1071 fprintf(output, " # %5.2f insns per cycle ", ratio); 1071 fprintf(out, " # %5.2f insns per cycle ", ratio);
1072 } else { 1072 } else {
1073 fprintf(output, " "); 1073 fprintf(out, " ");
1074 } 1074 }
1075 total = avg_stats(&runtime_stalled_cycles_front_stats[ctx][cpu]); 1075 total = avg_stats(&runtime_stalled_cycles_front_stats[ctx][cpu]);
1076 total = max(total, avg_stats(&runtime_stalled_cycles_back_stats[ctx][cpu])); 1076 total = max(total, avg_stats(&runtime_stalled_cycles_back_stats[ctx][cpu]));
1077 1077
1078 if (total && avg) { 1078 if (total && avg) {
1079 ratio = total / avg; 1079 ratio = total / avg;
1080 fprintf(output, "\n"); 1080 fprintf(out, "\n");
1081 if (aggr_mode == AGGR_NONE) 1081 if (aggr_mode == AGGR_NONE)
1082 fprintf(output, " "); 1082 fprintf(out, " ");
1083 fprintf(output, " # %5.2f stalled cycles per insn", ratio); 1083 fprintf(out, " # %5.2f stalled cycles per insn", ratio);
1084 } 1084 }
1085 1085
1086 } else if (perf_evsel__match(evsel, HARDWARE, HW_BRANCH_MISSES) && 1086 } else if (perf_evsel__match(evsel, HARDWARE, HW_BRANCH_MISSES) &&
1087 runtime_branches_stats[ctx][cpu].n != 0) { 1087 runtime_branches_stats[ctx][cpu].n != 0) {
1088 print_branch_misses(cpu, evsel, avg); 1088 print_branch_misses(out, cpu, evsel, avg);
1089 } else if ( 1089 } else if (
1090 evsel->attr.type == PERF_TYPE_HW_CACHE && 1090 evsel->attr.type == PERF_TYPE_HW_CACHE &&
1091 evsel->attr.config == ( PERF_COUNT_HW_CACHE_L1D | 1091 evsel->attr.config == ( PERF_COUNT_HW_CACHE_L1D |
1092 ((PERF_COUNT_HW_CACHE_OP_READ) << 8) | 1092 ((PERF_COUNT_HW_CACHE_OP_READ) << 8) |
1093 ((PERF_COUNT_HW_CACHE_RESULT_MISS) << 16)) && 1093 ((PERF_COUNT_HW_CACHE_RESULT_MISS) << 16)) &&
1094 runtime_l1_dcache_stats[ctx][cpu].n != 0) { 1094 runtime_l1_dcache_stats[ctx][cpu].n != 0) {
1095 print_l1_dcache_misses(cpu, evsel, avg); 1095 print_l1_dcache_misses(out, cpu, evsel, avg);
1096 } else if ( 1096 } else if (
1097 evsel->attr.type == PERF_TYPE_HW_CACHE && 1097 evsel->attr.type == PERF_TYPE_HW_CACHE &&
1098 evsel->attr.config == ( PERF_COUNT_HW_CACHE_L1I | 1098 evsel->attr.config == ( PERF_COUNT_HW_CACHE_L1I |
1099 ((PERF_COUNT_HW_CACHE_OP_READ) << 8) | 1099 ((PERF_COUNT_HW_CACHE_OP_READ) << 8) |
1100 ((PERF_COUNT_HW_CACHE_RESULT_MISS) << 16)) && 1100 ((PERF_COUNT_HW_CACHE_RESULT_MISS) << 16)) &&
1101 runtime_l1_icache_stats[ctx][cpu].n != 0) { 1101 runtime_l1_icache_stats[ctx][cpu].n != 0) {
1102 print_l1_icache_misses(cpu, evsel, avg); 1102 print_l1_icache_misses(out, cpu, evsel, avg);
1103 } else if ( 1103 } else if (
1104 evsel->attr.type == PERF_TYPE_HW_CACHE && 1104 evsel->attr.type == PERF_TYPE_HW_CACHE &&
1105 evsel->attr.config == ( PERF_COUNT_HW_CACHE_DTLB | 1105 evsel->attr.config == ( PERF_COUNT_HW_CACHE_DTLB |
1106 ((PERF_COUNT_HW_CACHE_OP_READ) << 8) | 1106 ((PERF_COUNT_HW_CACHE_OP_READ) << 8) |
1107 ((PERF_COUNT_HW_CACHE_RESULT_MISS) << 16)) && 1107 ((PERF_COUNT_HW_CACHE_RESULT_MISS) << 16)) &&
1108 runtime_dtlb_cache_stats[ctx][cpu].n != 0) { 1108 runtime_dtlb_cache_stats[ctx][cpu].n != 0) {
1109 print_dtlb_cache_misses(cpu, evsel, avg); 1109 print_dtlb_cache_misses(out, cpu, evsel, avg);
1110 } else if ( 1110 } else if (
1111 evsel->attr.type == PERF_TYPE_HW_CACHE && 1111 evsel->attr.type == PERF_TYPE_HW_CACHE &&
1112 evsel->attr.config == ( PERF_COUNT_HW_CACHE_ITLB | 1112 evsel->attr.config == ( PERF_COUNT_HW_CACHE_ITLB |
1113 ((PERF_COUNT_HW_CACHE_OP_READ) << 8) | 1113 ((PERF_COUNT_HW_CACHE_OP_READ) << 8) |
1114 ((PERF_COUNT_HW_CACHE_RESULT_MISS) << 16)) && 1114 ((PERF_COUNT_HW_CACHE_RESULT_MISS) << 16)) &&
1115 runtime_itlb_cache_stats[ctx][cpu].n != 0) { 1115 runtime_itlb_cache_stats[ctx][cpu].n != 0) {
1116 print_itlb_cache_misses(cpu, evsel, avg); 1116 print_itlb_cache_misses(out, cpu, evsel, avg);
1117 } else if ( 1117 } else if (
1118 evsel->attr.type == PERF_TYPE_HW_CACHE && 1118 evsel->attr.type == PERF_TYPE_HW_CACHE &&
1119 evsel->attr.config == ( PERF_COUNT_HW_CACHE_LL | 1119 evsel->attr.config == ( PERF_COUNT_HW_CACHE_LL |
1120 ((PERF_COUNT_HW_CACHE_OP_READ) << 8) | 1120 ((PERF_COUNT_HW_CACHE_OP_READ) << 8) |
1121 ((PERF_COUNT_HW_CACHE_RESULT_MISS) << 16)) && 1121 ((PERF_COUNT_HW_CACHE_RESULT_MISS) << 16)) &&
1122 runtime_ll_cache_stats[ctx][cpu].n != 0) { 1122 runtime_ll_cache_stats[ctx][cpu].n != 0) {
1123 print_ll_cache_misses(cpu, evsel, avg); 1123 print_ll_cache_misses(out, cpu, evsel, avg);
1124 } else if (perf_evsel__match(evsel, HARDWARE, HW_CACHE_MISSES) && 1124 } else if (perf_evsel__match(evsel, HARDWARE, HW_CACHE_MISSES) &&
1125 runtime_cacherefs_stats[ctx][cpu].n != 0) { 1125 runtime_cacherefs_stats[ctx][cpu].n != 0) {
1126 total = avg_stats(&runtime_cacherefs_stats[ctx][cpu]); 1126 total = avg_stats(&runtime_cacherefs_stats[ctx][cpu]);
@@ -1128,25 +1128,25 @@ static void print_shadow_stats(struct perf_evsel *evsel, double avg, int cpu)
1128 if (total) 1128 if (total)
1129 ratio = avg * 100 / total; 1129 ratio = avg * 100 / total;
1130 1130
1131 fprintf(output, " # %8.3f %% of all cache refs ", ratio); 1131 fprintf(out, " # %8.3f %% of all cache refs ", ratio);
1132 1132
1133 } else if (perf_evsel__match(evsel, HARDWARE, HW_STALLED_CYCLES_FRONTEND)) { 1133 } else if (perf_evsel__match(evsel, HARDWARE, HW_STALLED_CYCLES_FRONTEND)) {
1134 print_stalled_cycles_frontend(cpu, evsel, avg); 1134 print_stalled_cycles_frontend(out, cpu, evsel, avg);
1135 } else if (perf_evsel__match(evsel, HARDWARE, HW_STALLED_CYCLES_BACKEND)) { 1135 } else if (perf_evsel__match(evsel, HARDWARE, HW_STALLED_CYCLES_BACKEND)) {
1136 print_stalled_cycles_backend(cpu, evsel, avg); 1136 print_stalled_cycles_backend(out, cpu, evsel, avg);
1137 } else if (perf_evsel__match(evsel, HARDWARE, HW_CPU_CYCLES)) { 1137 } else if (perf_evsel__match(evsel, HARDWARE, HW_CPU_CYCLES)) {
1138 total = avg_stats(&runtime_nsecs_stats[cpu]); 1138 total = avg_stats(&runtime_nsecs_stats[cpu]);
1139 1139
1140 if (total) { 1140 if (total) {
1141 ratio = avg / total; 1141 ratio = avg / total;
1142 fprintf(output, " # %8.3f GHz ", ratio); 1142 fprintf(out, " # %8.3f GHz ", ratio);
1143 } else { 1143 } else {
1144 fprintf(output, " "); 1144 fprintf(out, " ");
1145 } 1145 }
1146 } else if (perf_stat_evsel__is(evsel, CYCLES_IN_TX)) { 1146 } else if (perf_stat_evsel__is(evsel, CYCLES_IN_TX)) {
1147 total = avg_stats(&runtime_cycles_stats[ctx][cpu]); 1147 total = avg_stats(&runtime_cycles_stats[ctx][cpu]);
1148 if (total) 1148 if (total)
1149 fprintf(output, 1149 fprintf(out,
1150 " # %5.2f%% transactional cycles ", 1150 " # %5.2f%% transactional cycles ",
1151 100.0 * (avg / total)); 1151 100.0 * (avg / total));
1152 } else if (perf_stat_evsel__is(evsel, CYCLES_IN_TX_CP)) { 1152 } else if (perf_stat_evsel__is(evsel, CYCLES_IN_TX_CP)) {
@@ -1155,7 +1155,7 @@ static void print_shadow_stats(struct perf_evsel *evsel, double avg, int cpu)
1155 if (total2 < avg) 1155 if (total2 < avg)
1156 total2 = avg; 1156 total2 = avg;
1157 if (total) 1157 if (total)
1158 fprintf(output, 1158 fprintf(out,
1159 " # %5.2f%% aborted cycles ", 1159 " # %5.2f%% aborted cycles ",
1160 100.0 * ((total2-avg) / total)); 1160 100.0 * ((total2-avg) / total));
1161 } else if (perf_stat_evsel__is(evsel, TRANSACTION_START) && 1161 } else if (perf_stat_evsel__is(evsel, TRANSACTION_START) &&
@@ -1166,7 +1166,7 @@ static void print_shadow_stats(struct perf_evsel *evsel, double avg, int cpu)
1166 if (total) 1166 if (total)
1167 ratio = total / avg; 1167 ratio = total / avg;
1168 1168
1169 fprintf(output, " # %8.0f cycles / transaction ", ratio); 1169 fprintf(out, " # %8.0f cycles / transaction ", ratio);
1170 } else if (perf_stat_evsel__is(evsel, ELISION_START) && 1170 } else if (perf_stat_evsel__is(evsel, ELISION_START) &&
1171 avg > 0 && 1171 avg > 0 &&
1172 runtime_cycles_in_tx_stats[ctx][cpu].n != 0) { 1172 runtime_cycles_in_tx_stats[ctx][cpu].n != 0) {
@@ -1175,7 +1175,7 @@ static void print_shadow_stats(struct perf_evsel *evsel, double avg, int cpu)
1175 if (total) 1175 if (total)
1176 ratio = total / avg; 1176 ratio = total / avg;
1177 1177
1178 fprintf(output, " # %8.0f cycles / elision ", ratio); 1178 fprintf(out, " # %8.0f cycles / elision ", ratio);
1179 } else if (runtime_nsecs_stats[cpu].n != 0) { 1179 } else if (runtime_nsecs_stats[cpu].n != 0) {
1180 char unit = 'M'; 1180 char unit = 'M';
1181 1181
@@ -1188,9 +1188,9 @@ static void print_shadow_stats(struct perf_evsel *evsel, double avg, int cpu)
1188 unit = 'K'; 1188 unit = 'K';
1189 } 1189 }
1190 1190
1191 fprintf(output, " # %8.3f %c/sec ", ratio, unit); 1191 fprintf(out, " # %8.3f %c/sec ", ratio, unit);
1192 } else { 1192 } else {
1193 fprintf(output, " "); 1193 fprintf(out, " ");
1194 } 1194 }
1195} 1195}
1196 1196
@@ -1229,7 +1229,7 @@ static void abs_printout(int id, int nr, struct perf_evsel *evsel, double avg)
1229 if (csv_output || interval) 1229 if (csv_output || interval)
1230 return; 1230 return;
1231 1231
1232 print_shadow_stats(evsel, avg, cpu); 1232 print_shadow_stats(output, evsel, avg, cpu);
1233} 1233}
1234 1234
1235static void print_aggr(char *prefix) 1235static void print_aggr(char *prefix)