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

perf stat: Add --metric-only support for -A

Add metric only support for -A too. This requires a new print function
that prints the metrics in the right order.

v2: Fix manpage
v3: Simplify nrcpus computation

Signed-off-by: Andi Kleen <ak@linux.intel.com>
Acked-by: Jiri Olsa <jolsa@kernel.org>
Link: http://lkml.kernel.org/r/1457049458-28956-7-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
206cab65 54b50916

+38 -9
+1 -1
tools/perf/Documentation/perf-stat.txt
··· 149 149 150 150 --metric-only:: 151 151 Only print computed metrics. Print them in a single line. 152 - Don't show any raw values. Not supported with -A or --per-thread. 152 + Don't show any raw values. Not supported with --per-thread. 153 153 154 154 --per-socket:: 155 155 Aggregate counts per processor socket for system-wide mode measurements. This
+37 -8
tools/perf/builtin-stat.c
··· 1250 1250 } 1251 1251 } 1252 1252 1253 + static void print_no_aggr_metric(char *prefix) 1254 + { 1255 + int cpu; 1256 + int nrcpus = 0; 1257 + struct perf_evsel *counter; 1258 + u64 ena, run, val; 1259 + double uval; 1260 + 1261 + nrcpus = evsel_list->cpus->nr; 1262 + for (cpu = 0; cpu < nrcpus; cpu++) { 1263 + bool first = true; 1264 + 1265 + if (prefix) 1266 + fputs(prefix, stat_config.output); 1267 + evlist__for_each(evsel_list, counter) { 1268 + if (first) { 1269 + aggr_printout(counter, cpu, 0); 1270 + first = false; 1271 + } 1272 + val = perf_counts(counter->counts, cpu, 0)->val; 1273 + ena = perf_counts(counter->counts, cpu, 0)->ena; 1274 + run = perf_counts(counter->counts, cpu, 0)->run; 1275 + 1276 + uval = val * counter->scale; 1277 + printout(cpu, 0, counter, uval, prefix, run, ena, 1.0); 1278 + } 1279 + fputc('\n', stat_config.output); 1280 + } 1281 + } 1282 + 1253 1283 static int aggr_header_lens[] = { 1254 1284 [AGGR_CORE] = 18, 1255 1285 [AGGR_SOCKET] = 12, 1256 - [AGGR_NONE] = 15, 1286 + [AGGR_NONE] = 6, 1257 1287 [AGGR_THREAD] = 24, 1258 1288 [AGGR_GLOBAL] = 0, 1259 1289 }; ··· 1438 1408 fputc('\n', stat_config.output); 1439 1409 break; 1440 1410 case AGGR_NONE: 1441 - evlist__for_each(evsel_list, counter) 1442 - print_counter(counter, prefix); 1411 + if (metric_only) 1412 + print_no_aggr_metric(prefix); 1413 + else { 1414 + evlist__for_each(evsel_list, counter) 1415 + print_counter(counter, prefix); 1416 + } 1443 1417 break; 1444 1418 case AGGR_UNSET: 1445 1419 default: ··· 2209 2175 2210 2176 if (metric_only && stat_config.aggr_mode == AGGR_THREAD) { 2211 2177 fprintf(stderr, "--metric-only is not supported with --per-thread\n"); 2212 - goto out; 2213 - } 2214 - 2215 - if (metric_only && stat_config.aggr_mode == AGGR_NONE) { 2216 - fprintf(stderr, "--metric-only is not supported with -A\n"); 2217 2178 goto out; 2218 2179 } 2219 2180