Lines Matching full:config

28 static void print_running(struct perf_stat_config *config,  in print_running()  argument
36 if (config->json_output) in print_running()
37 fprintf(config->output, in print_running()
40 else if (config->csv_output) in print_running()
41 fprintf(config->output, in print_running()
42 "%s%" PRIu64 "%s%.2f", config->csv_sep, in print_running()
43 run, config->csv_sep, enabled_percent); in print_running()
45 fprintf(config->output, " (%.2f%%)", 100.0 * run / ena); in print_running()
48 static void print_noise_pct(struct perf_stat_config *config, in print_noise_pct() argument
53 if (config->json_output) in print_noise_pct()
54 fprintf(config->output, "\"variance\" : %.2f, ", pct); in print_noise_pct()
55 else if (config->csv_output) in print_noise_pct()
56 fprintf(config->output, "%s%.2f%%", config->csv_sep, pct); in print_noise_pct()
58 fprintf(config->output, " ( +-%6.2f%% )", pct); in print_noise_pct()
61 static void print_noise(struct perf_stat_config *config, in print_noise() argument
66 if (config->run_count == 1) in print_noise()
70 print_noise_pct(config, stddev_stats(&ps->res_stats), avg); in print_noise()
73 static void print_cgroup(struct perf_stat_config *config, struct evsel *evsel) in print_cgroup() argument
78 if (config->json_output) in print_cgroup()
79 fprintf(config->output, "\"cgroup\" : \"%s\", ", cgrp_name); in print_cgroup()
81 fprintf(config->output, "%s%s", config->csv_sep, cgrp_name); in print_cgroup()
86 static void aggr_printout(struct perf_stat_config *config, in aggr_printout() argument
91 if (config->json_output && !config->interval) in aggr_printout()
92 fprintf(config->output, "{"); in aggr_printout()
94 switch (config->aggr_mode) { in aggr_printout()
96 if (config->json_output) { in aggr_printout()
97 fprintf(config->output, in aggr_printout()
104 fprintf(config->output, "S%d-D%d-C%*d%s%*d%s", in aggr_printout()
107 config->csv_output ? 0 : -8, in aggr_printout()
109 config->csv_sep, in aggr_printout()
110 config->csv_output ? 0 : 4, in aggr_printout()
112 config->csv_sep); in aggr_printout()
116 if (config->json_output) { in aggr_printout()
117 fprintf(config->output, in aggr_printout()
123 fprintf(config->output, "S%d-D%*d%s%*d%s", in aggr_printout()
125 config->csv_output ? 0 : -8, in aggr_printout()
127 config->csv_sep, in aggr_printout()
128 config->csv_output ? 0 : 4, in aggr_printout()
130 config->csv_sep); in aggr_printout()
134 if (config->json_output) { in aggr_printout()
135 fprintf(config->output, in aggr_printout()
140 fprintf(config->output, "S%*d%s%*d%s", in aggr_printout()
141 config->csv_output ? 0 : -5, in aggr_printout()
143 config->csv_sep, in aggr_printout()
144 config->csv_output ? 0 : 4, in aggr_printout()
146 config->csv_sep); in aggr_printout()
150 if (config->json_output) { in aggr_printout()
151 fprintf(config->output, "\"node\" : \"N%d\", \"aggregate-number\" : %d, ", in aggr_printout()
155 fprintf(config->output, "N%*d%s%*d%s", in aggr_printout()
156 config->csv_output ? 0 : -5, in aggr_printout()
158 config->csv_sep, in aggr_printout()
159 config->csv_output ? 0 : 4, in aggr_printout()
161 config->csv_sep); in aggr_printout()
165 if (config->json_output) { in aggr_printout()
166 if (evsel->percore && !config->percore_show_thread) { in aggr_printout()
167 fprintf(config->output, "\"core\" : \"S%d-D%d-C%d\"", in aggr_printout()
172 fprintf(config->output, "\"cpu\" : \"%d\", ", in aggr_printout()
176 if (evsel->percore && !config->percore_show_thread) { in aggr_printout()
177 fprintf(config->output, "S%d-D%d-C%*d%s", in aggr_printout()
180 config->csv_output ? 0 : -3, in aggr_printout()
181 id.core, config->csv_sep); in aggr_printout()
183 fprintf(config->output, "CPU%*d%s", in aggr_printout()
184 config->csv_output ? 0 : -7, in aggr_printout()
185 id.cpu.cpu, config->csv_sep); in aggr_printout()
190 if (config->json_output) { in aggr_printout()
191 fprintf(config->output, "\"thread\" : \"%s-%d\", ", in aggr_printout()
195 fprintf(config->output, "%*s-%*d%s", in aggr_printout()
196 config->csv_output ? 0 : 16, in aggr_printout()
198 config->csv_output ? 0 : -8, in aggr_printout()
200 config->csv_sep); in aggr_printout()
223 static void new_line_std(struct perf_stat_config *config __maybe_unused, in new_line_std()
231 static void do_new_line_std(struct perf_stat_config *config, in do_new_line_std() argument
236 aggr_printout(config, os->evsel, os->id, os->nr); in do_new_line_std()
237 if (config->aggr_mode == AGGR_NONE) in do_new_line_std()
242 static void print_metric_std(struct perf_stat_config *config, in print_metric_std() argument
259 do_new_line_std(config, os); in print_metric_std()
269 static void new_line_csv(struct perf_stat_config *config, void *ctx) in new_line_csv() argument
277 aggr_printout(config, os->evsel, os->id, os->nr); in new_line_csv()
279 fputs(config->csv_sep, os->fh); in new_line_csv()
282 static void print_metric_csv(struct perf_stat_config *config __maybe_unused, in print_metric_csv()
292 fprintf(out, "%s%s", config->csv_sep, config->csv_sep); in print_metric_csv()
300 fprintf(out, "%s%s%s%s", config->csv_sep, vals, config->csv_sep, skip_spaces(unit)); in print_metric_csv()
303 static void print_metric_json(struct perf_stat_config *config __maybe_unused, in print_metric_json()
314 if (!config->metric_only) in print_metric_json()
318 static void new_line_json(struct perf_stat_config *config, void *ctx) in new_line_json() argument
325 aggr_printout(config, os->evsel, os->id, os->nr); in new_line_json()
351 static void print_metric_only(struct perf_stat_config *config, in print_metric_only() argument
358 unsigned mlen = config->metric_only_len; in print_metric_only()
373 static void print_metric_only_csv(struct perf_stat_config *config __maybe_unused, in print_metric_only_csv()
391 fprintf(out, "%s%s", vals, config->csv_sep); in print_metric_only_csv()
394 static void print_metric_only_json(struct perf_stat_config *config __maybe_unused, in print_metric_only_json()
415 static void new_line_metric(struct perf_stat_config *config __maybe_unused, in new_line_metric()
420 static void print_metric_header(struct perf_stat_config *config, in print_metric_header() argument
429 if (config->iostat_run && in print_metric_header()
433 if (!valid_only_metric(unit) && !config->json_output) in print_metric_header()
437 if (config->json_output) in print_metric_header()
439 else if (config->csv_output) in print_metric_header()
440 fprintf(os->fh, "%s%s", unit, config->csv_sep); in print_metric_header()
442 fprintf(os->fh, "%*s ", config->metric_only_len, unit); in print_metric_header()
445 static int first_shadow_map_idx(struct perf_stat_config *config, in first_shadow_map_idx() argument
452 if (config->aggr_mode == AGGR_NONE) in first_shadow_map_idx()
455 if (config->aggr_mode == AGGR_THREAD) in first_shadow_map_idx()
458 if (!config->aggr_get_id) in first_shadow_map_idx()
462 struct aggr_cpu_id cpu_id = config->aggr_get_id(config, cpu); in first_shadow_map_idx()
470 static void abs_printout(struct perf_stat_config *config, in abs_printout() argument
473 FILE *output = config->output; in abs_printout()
477 if (config->csv_output) { in abs_printout()
480 if (config->big_num) in abs_printout()
486 aggr_printout(config, evsel, id, nr); in abs_printout()
488 if (config->json_output) in abs_printout()
491 fprintf(output, fmt, avg, config->csv_sep); in abs_printout()
493 if (config->json_output) { in abs_printout()
501 config->csv_output ? 0 : config->unit_width, in abs_printout()
502 evsel->unit, config->csv_sep); in abs_printout()
505 if (config->json_output) in abs_printout()
508 fprintf(output, "%-*s", config->csv_output ? 0 : 32, evsel__name(evsel)); in abs_printout()
510 print_cgroup(config, evsel); in abs_printout()
537 static void printout(struct perf_stat_config *config, struct aggr_cpu_id id, int nr, in printout() argument
544 .fh = config->output, in printout()
553 if (config->csv_output) { in printout()
565 pm = config->metric_only ? print_metric_only_csv : print_metric_csv; in printout()
566 nl = config->metric_only ? new_line_metric : new_line_csv; in printout()
567 os.nfields = 3 + aggr_fields[config->aggr_mode] + (counter->cgrp ? 1 : 0); in printout()
568 } else if (config->json_output) { in printout()
569 pm = config->metric_only ? print_metric_only_json : print_metric_json; in printout()
570 nl = config->metric_only ? new_line_metric : new_line_json; in printout()
572 pm = config->metric_only ? print_metric_only : print_metric_std; in printout()
573 nl = config->metric_only ? new_line_metric : new_line_std; in printout()
576 if (!config->no_csv_summary && config->csv_output && in printout()
577 config->summary && !config->interval) { in printout()
578 fprintf(config->output, "%16s%s", "summary", config->csv_sep); in printout()
582 if (config->metric_only) { in printout()
583 pm(config, &os, NULL, "", "", 0); in printout()
586 aggr_printout(config, counter, id, nr); in printout()
588 if (config->json_output) { in printout()
589 fprintf(config->output, "\"counter-value\" : \"%s\", ", in printout()
592 fprintf(config->output, "%*s%s", in printout()
593 config->csv_output ? 0 : 18, in printout()
595 config->csv_sep); in printout()
600 config->print_free_counters_hint = 1; in printout()
602 config->print_mixed_hw_group_error = 1; in printout()
606 if (config->json_output) { in printout()
607 fprintf(config->output, "\"unit\" : \"%s\", ", counter->unit); in printout()
609 fprintf(config->output, "%-*s%s", in printout()
610 config->csv_output ? 0 : config->unit_width, in printout()
611 counter->unit, config->csv_sep); in printout()
614 if (config->json_output) { in printout()
615 fprintf(config->output, "\"event\" : \"%s\", ", in printout()
618 fprintf(config->output, "%*s", in printout()
619 config->csv_output ? 0 : -25, evsel__name(counter)); in printout()
622 print_cgroup(config, counter); in printout()
624 if (!config->csv_output && !config->json_output) in printout()
625 pm(config, &os, NULL, NULL, "", 0); in printout()
626 print_noise(config, counter, noise); in printout()
627 print_running(config, run, ena); in printout()
628 if (config->csv_output) in printout()
629 pm(config, &os, NULL, NULL, "", 0); in printout()
630 else if (config->json_output) in printout()
631 pm(config, &os, NULL, NULL, "", 0); in printout()
635 if (!config->metric_only) in printout()
636 abs_printout(config, id, nr, counter, uval); in printout()
643 if (config->csv_output && !config->metric_only) { in printout()
644 print_noise(config, counter, noise); in printout()
645 print_running(config, run, ena); in printout()
646 } else if (config->json_output && !config->metric_only) { in printout()
647 print_noise(config, counter, noise); in printout()
648 print_running(config, run, ena); in printout()
651 perf_stat__print_shadow_stats(config, counter, uval, in printout()
652 first_shadow_map_idx(config, counter, &id), in printout()
653 &out, &config->metric_events, st); in printout()
654 if (!config->csv_output && !config->metric_only && !config->json_output) { in printout()
655 print_noise(config, counter, noise); in printout()
656 print_running(config, run, ena); in printout()
660 static void aggr_update_shadow(struct perf_stat_config *config, in aggr_update_shadow() argument
670 for (s = 0; s < config->aggr_map->nr; s++) { in aggr_update_shadow()
671 id = config->aggr_map->map[s]; in aggr_update_shadow()
676 s2 = config->aggr_get_id(config, cpu); in aggr_update_shadow()
682 first_shadow_map_idx(config, counter, &id), in aggr_update_shadow()
691 char *config; in uniquify_event_name() local
699 config = strchr(counter->name, '/'); in uniquify_event_name()
700 if (config) { in uniquify_event_name()
702 "%s%s", counter->pmu_name, config) > 0) { in uniquify_event_name()
724 static void collect_all_aliases(struct perf_stat_config *config, struct evsel *counter, in collect_all_aliases() argument
725 void (*cb)(struct perf_stat_config *config, struct evsel *counter, void *data, in collect_all_aliases() argument
742 cb(config, alias, data, false); in collect_all_aliases()
759 static bool hybrid_merge(struct evsel *counter, struct perf_stat_config *config, in hybrid_merge() argument
764 return config && config->hybrid_merge; in hybrid_merge()
766 return config && !config->hybrid_merge; in hybrid_merge()
772 static bool collect_data(struct perf_stat_config *config, struct evsel *counter, in collect_data() argument
773 void (*cb)(struct perf_stat_config *config, struct evsel *counter, void *data, in collect_data() argument
779 cb(config, counter, data, true); in collect_data()
780 if (config->no_merge || hybrid_merge(counter, config, false)) in collect_data()
782 else if (counter->auto_merge_stats || hybrid_merge(counter, config, true)) in collect_data()
783 collect_all_aliases(config, counter, cb, data); in collect_data()
794 static void aggr_cb(struct perf_stat_config *config, in aggr_cb() argument
807 s2 = config->aggr_get_id(config, cpu); in aggr_cb()
829 static void print_counter_aggrdata(struct perf_stat_config *config, in print_counter_aggrdata() argument
835 FILE *output = config->output; in print_counter_aggrdata()
841 ad.id = id = config->aggr_map->map[s]; in print_counter_aggrdata()
844 if (!collect_data(config, counter, aggr_cb, &ad)) in print_counter_aggrdata()
856 aggr_printout(config, counter, id, nr); in print_counter_aggrdata()
865 printout(config, id, nr, counter, uval, in print_counter_aggrdata()
871 static void print_aggr(struct perf_stat_config *config, in print_aggr() argument
875 bool metric_only = config->metric_only; in print_aggr()
876 FILE *output = config->output; in print_aggr()
881 if (!config->aggr_map || !config->aggr_get_id) in print_aggr()
884 aggr_update_shadow(config, evlist); in print_aggr()
890 for (s = 0; s < config->aggr_map->nr; s++) { in print_aggr()
896 print_counter_aggrdata(config, counter, s, in print_aggr()
965 static void print_aggr_thread(struct perf_stat_config *config, in print_aggr_thread() argument
969 FILE *output = config->output; in print_aggr_thread()
985 printout(config, id, 0, buf[thread].counter, buf[thread].uval, in print_aggr_thread()
998 static void counter_aggr_cb(struct perf_stat_config *config __maybe_unused, in counter_aggr_cb()
1014 static void print_counter_aggr(struct perf_stat_config *config, in print_counter_aggr() argument
1017 bool metric_only = config->metric_only; in print_counter_aggr()
1018 FILE *output = config->output; in print_counter_aggr()
1022 if (!collect_data(config, counter, counter_aggr_cb, &cd)) in print_counter_aggr()
1029 printout(config, aggr_cpu_id__empty(), 0, counter, uval, prefix, cd.avg_running, in print_counter_aggr()
1035 static void counter_cb(struct perf_stat_config *config __maybe_unused, in counter_cb()
1050 static void print_counter(struct perf_stat_config *config, in print_counter() argument
1053 FILE *output = config->output; in print_counter()
1063 if (!collect_data(config, counter, counter_cb, &ad)) in print_counter()
1074 printout(config, id, 0, counter, uval, prefix, in print_counter()
1081 static void print_no_aggr_metric(struct perf_stat_config *config, in print_no_aggr_metric() argument
1104 fputs(prefix, config->output); in print_no_aggr_metric()
1105 aggr_printout(config, counter, id, 0); in print_no_aggr_metric()
1113 printout(config, id, 0, counter, uval, prefix, in print_no_aggr_metric()
1117 fputc('\n', config->output); in print_no_aggr_metric()
1141 static void print_metric_headers(struct perf_stat_config *config, in print_metric_headers() argument
1148 .fh = config->output in print_metric_headers()
1152 if (config->json_output && !config->interval) in print_metric_headers()
1153 fprintf(config->output, "{"); in print_metric_headers()
1155 if (prefix && !config->json_output) in print_metric_headers()
1156 fprintf(config->output, "%s", prefix); in print_metric_headers()
1158 if (!config->csv_output && !no_indent) in print_metric_headers()
1159 fprintf(config->output, "%*s", in print_metric_headers()
1160 aggr_header_lens[config->aggr_mode], ""); in print_metric_headers()
1161 if (config->csv_output) { in print_metric_headers()
1162 if (config->interval) in print_metric_headers()
1163 fputs("time,", config->output); in print_metric_headers()
1164 if (!config->iostat_run) in print_metric_headers()
1165 fputs(aggr_header_csv[config->aggr_mode], config->output); in print_metric_headers()
1167 if (config->iostat_run) in print_metric_headers()
1168 iostat_print_header_prefix(config); in print_metric_headers()
1175 if (!first && config->json_output) in print_metric_headers()
1176 fprintf(config->output, ", "); in print_metric_headers()
1180 perf_stat__print_shadow_stats(config, counter, 0, in print_metric_headers()
1183 &config->metric_events, in print_metric_headers()
1186 if (config->json_output) in print_metric_headers()
1187 fprintf(config->output, "}"); in print_metric_headers()
1188 fputc('\n', config->output); in print_metric_headers()
1191 static void print_interval(struct perf_stat_config *config, in print_interval() argument
1195 bool metric_only = config->metric_only; in print_interval()
1196 unsigned int unit_width = config->unit_width; in print_interval()
1197 FILE *output = config->output; in print_interval()
1200 if (config->interval_clear) in print_interval()
1203 if (!config->iostat_run && !config->json_output) in print_interval()
1205 ts->tv_nsec, config->csv_sep); in print_interval()
1206 if (!config->iostat_run && config->json_output && !config->metric_only) in print_interval()
1209 if (!config->iostat_run && config->json_output && config->metric_only) in print_interval()
1213 if ((num_print_interval == 0 && !config->csv_output && !config->json_output) in print_interval()
1214 || config->interval_clear) { in print_interval()
1215 switch (config->aggr_mode) { in print_interval()
1248 if (!config->iostat_run) { in print_interval()
1259 if ((num_print_interval == 0 || config->interval_clear) in print_interval()
1260 && metric_only && !config->json_output) in print_interval()
1261 print_metric_headers(config, evlist, " ", true); in print_interval()
1262 if ((num_print_interval == 0 || config->interval_clear) in print_interval()
1263 && metric_only && config->json_output) { in print_interval()
1265 print_metric_headers(config, evlist, " ", true); in print_interval()
1271 static void print_header(struct perf_stat_config *config, in print_header() argument
1275 FILE *output = config->output; in print_header()
1280 if (!config->csv_output && !config->json_output) { in print_header()
1299 if (config->run_count > 1) in print_header()
1300 fprintf(output, " (%d runs)", config->run_count); in print_header()
1313 static void print_table(struct perf_stat_config *config, in print_table() argument
1325 for (idx = 0; idx < config->run_count; idx++) { in print_table()
1326 double run = (double) config->walltime_run[idx] / NSEC_PER_SEC; in print_table()
1346 static void print_footer(struct perf_stat_config *config) in print_footer() argument
1348 double avg = avg_stats(config->walltime_nsecs_stats) / NSEC_PER_SEC; in print_footer()
1349 FILE *output = config->output; in print_footer()
1351 if (!config->null_run) in print_footer()
1354 if (config->run_count == 1) { in print_footer()
1357 if (config->ru_display) { in print_footer()
1358 double ru_utime = timeval2double(&config->ru_data.ru_utime); in print_footer()
1359 double ru_stime = timeval2double(&config->ru_data.ru_stime); in print_footer()
1366 double sd = stddev_stats(config->walltime_nsecs_stats) / NSEC_PER_SEC; in print_footer()
1373 if (config->walltime_run_table) in print_footer()
1374 print_table(config, output, precision, avg); in print_footer()
1379 print_noise_pct(config, sd, avg); in print_footer()
1383 if (config->print_free_counters_hint && sysctl__nmi_watchdog_enabled()) in print_footer()
1390 if (config->print_mixed_hw_group_error) in print_footer()
1396 static void print_percore_thread(struct perf_stat_config *config, in print_percore_thread() argument
1408 s2 = config->aggr_get_id(config, cpu); in print_percore_thread()
1409 for (s = 0; s < config->aggr_map->nr; s++) { in print_percore_thread()
1410 id = config->aggr_map->map[s]; in print_percore_thread()
1415 print_counter_aggrdata(config, counter, s, in print_percore_thread()
1421 static void print_percore(struct perf_stat_config *config, in print_percore() argument
1424 bool metric_only = config->metric_only; in print_percore()
1425 FILE *output = config->output; in print_percore()
1429 if (!config->aggr_map || !config->aggr_get_id) in print_percore()
1432 if (config->percore_show_thread) in print_percore()
1433 return print_percore_thread(config, counter, prefix); in print_percore()
1435 for (s = 0; s < config->aggr_map->nr; s++) { in print_percore()
1439 print_counter_aggrdata(config, counter, s, in print_percore()
1448 void evlist__print_counters(struct evlist *evlist, struct perf_stat_config *config, in evlist__print_counters() argument
1451 bool metric_only = config->metric_only; in evlist__print_counters()
1452 int interval = config->interval; in evlist__print_counters()
1456 if (config->iostat_run) in evlist__print_counters()
1460 print_interval(config, evlist, prefix = buf, ts); in evlist__print_counters()
1462 print_header(config, _target, argc, argv); in evlist__print_counters()
1468 print_metric_headers(config, evlist, prefix, false); in evlist__print_counters()
1471 if (config->aggr_mode == AGGR_GLOBAL && prefix && !config->iostat_run) in evlist__print_counters()
1472 fprintf(config->output, "%s", prefix); in evlist__print_counters()
1474 if (config->json_output && !config->metric_only) in evlist__print_counters()
1475 fprintf(config->output, "}"); in evlist__print_counters()
1478 switch (config->aggr_mode) { in evlist__print_counters()
1483 print_aggr(config, evlist, prefix); in evlist__print_counters()
1487 print_aggr_thread(config, _target, counter, prefix); in evlist__print_counters()
1491 if (config->iostat_run) in evlist__print_counters()
1492 iostat_print_counters(evlist, config, ts, prefix = buf, in evlist__print_counters()
1496 print_counter_aggr(config, counter, prefix); in evlist__print_counters()
1499 fputc('\n', config->output); in evlist__print_counters()
1504 print_no_aggr_metric(config, evlist, prefix); in evlist__print_counters()
1508 print_percore(config, counter, prefix); in evlist__print_counters()
1510 print_counter(config, counter, prefix); in evlist__print_counters()
1520 if (!interval && !config->csv_output && !config->json_output) in evlist__print_counters()
1521 print_footer(config); in evlist__print_counters()
1523 fflush(config->output); in evlist__print_counters()