Lines Matching +full:smi +full:- +full:based
1 // SPDX-License-Identifier: GPL-2.0-only
3 * builtin-stat.c
16 1708.761321 task-clock # 11.037 CPUs utilized
17 41,190 context-switches # 0.024 M/sec
18 6,735 CPU-migrations # 0.004 M/sec
19 17,318 page-faults # 0.010 M/sec
21 3,856,436,920 stalled-cycles-frontend # 74.09% frontend cycles idle
22 1,600,790,871 stalled-cycles-backend # 30.75% backend cycles idle
26 6,388,934 branch-misses # 1.32% of all branches
31 * Copyright (C) 2008-2011, Red Hat Inc, Ingo Molnar <mingo@redhat.com>
45 #include <subcmd/parse-options.h>
46 #include "util/parse-events.h"
65 #include "util/synthetic-events.h"
67 #include "util/time-utils.h"
74 #include "util/intel-tpebs.h"
113 static volatile sig_atomic_t child_pid = -1;
119 static int big_num_opt = -1;
160 if (opt_mode->node) in opt_aggr_mode_to_aggr_mode()
162 if (opt_mode->socket) in opt_aggr_mode_to_aggr_mode()
164 if (opt_mode->die) in opt_aggr_mode_to_aggr_mode()
166 if (opt_mode->cluster) in opt_aggr_mode_to_aggr_mode()
168 if (opt_mode->cache) in opt_aggr_mode_to_aggr_mode()
170 if (opt_mode->core) in opt_aggr_mode_to_aggr_mode()
172 if (opt_mode->thread) in opt_aggr_mode_to_aggr_mode()
174 if (opt_mode->no_aggr) in opt_aggr_mode_to_aggr_mode()
189 if (perf_cpu_map__equal(leader->core.cpus, evsel->core.cpus)) in evlist__check_cpu_maps()
206 cpu_map__snprint(leader->core.cpus, buf, sizeof(buf)); in evlist__check_cpu_maps()
207 pr_warning(" %s: %s\n", leader->name, buf); in evlist__check_cpu_maps()
208 cpu_map__snprint(evsel->core.cpus, buf, sizeof(buf)); in evlist__check_cpu_maps()
209 pr_warning(" %s: %s\n", evsel->name, buf); in evlist__check_cpu_maps()
219 r->tv_sec = a->tv_sec - b->tv_sec; in diff_timespec()
220 if (a->tv_nsec < b->tv_nsec) { in diff_timespec()
221 r->tv_nsec = a->tv_nsec + NSEC_PER_SEC - b->tv_nsec; in diff_timespec()
222 r->tv_sec--; in diff_timespec()
224 r->tv_nsec = a->tv_nsec - b->tv_nsec ; in diff_timespec()
239 if (perf_data__write(&perf_stat.data, event, event->header.size) < 0) { in process_synthesized_event()
241 return -1; in process_synthesized_event()
244 perf_stat.bytes_written += event->header.size; in process_synthesized_event()
258 #define SID(e, x, y) xyarray__entry(e->core.sample_id, x, y)
266 return perf_event__synthesize_stat(NULL, cpu, thread, sid->id, count, in evsel__write_stat_event()
283 perf_counts(counter->counts, cpu_map_idx, thread); in read_single_counter()
285 start_time = xyarray__entry(counter->start_times, cpu_map_idx, thread); in read_single_counter()
290 count->ena = count->run = *start_time + val; in read_single_counter()
291 count->val = val; in read_single_counter()
299 * do not aggregate counts across CPUs in system-wide mode
303 int nthreads = perf_thread_map__nr(evsel_list->core.threads); in read_counter_cpu()
306 if (!counter->supported) in read_counter_cpu()
307 return -ENOENT; in read_counter_cpu()
312 count = perf_counts(counter->counts, cpu_map_idx, thread); in read_counter_cpu()
316 * (via evsel__read_counter()) and sets their count->loaded. in read_counter_cpu()
318 if (!perf_counts__is_loaded(counter->counts, cpu_map_idx, thread) && in read_counter_cpu()
320 counter->counts->scaled = -1; in read_counter_cpu()
321 perf_counts(counter->counts, cpu_map_idx, thread)->ena = 0; in read_counter_cpu()
322 perf_counts(counter->counts, cpu_map_idx, thread)->run = 0; in read_counter_cpu()
323 return -1; in read_counter_cpu()
326 perf_counts__set_loaded(counter->counts, cpu_map_idx, thread, false); in read_counter_cpu()
331 return -1; in read_counter_cpu()
341 count->val, count->ena, count->run); in read_counter_cpu()
359 return -1; in read_affinity_counters()
369 if (!counter->err) in read_affinity_counters()
370 counter->err = read_counter_cpu(counter, evlist_cpu_itr.cpu_map_idx); in read_affinity_counters()
399 return -1; in read_counters()
409 if (counter->err) in process_counters()
410 pr_debug("failed to read counter %s\n", counter->name); in process_counters()
411 if (counter->err == 0 && perf_stat_process_counter(&stat_config, counter)) in process_counters()
412 pr_warning("failed to process counter %s\n", counter->name); in process_counters()
413 counter->err = 0; in process_counters()
446 if (interval_count && !(--(*times))) in handle_interval()
500 workload_exec_errno = info->si_value.sival_int; in workload_exec_failed_signal()
505 return STAT_RECORD || counter->core.attr.read_format & PERF_FORMAT_ID; in evsel__should_store_id()
517 for (i = 0; i < threads->nr; i++) { in is_target_alive()
521 threads->map[i].pid); in is_target_alive()
562 tts -= time_diff.tv_sec * MSEC_PER_SEC + in compute_tts()
590 child_exited = !is_target_alive(&target, evsel_list->core.threads) ? 1 : 0; in dispatch_events()
619 assert(!counter->supported); in stat_handle_error()
635 counter->supported = true; in stat_handle_error()
639 evsel_list->core.threads && evsel_list->core.threads->err_thread != -1) { in stat_handle_error()
641 * For global --per-thread case, skip current in stat_handle_error()
644 if (!thread_map__remove(evsel_list->core.threads, in stat_handle_error()
645 evsel_list->core.threads->err_thread)) { in stat_handle_error()
646 evsel_list->core.threads->err_thread = -1; in stat_handle_error()
647 counter->supported = true; in stat_handle_error()
664 struct perf_event_attr *attr = &evsel->core.attr; in create_perf_stat_counter()
668 attr->read_format = PERF_FORMAT_TOTAL_TIME_ENABLED | in create_perf_stat_counter()
676 if (leader->core.nr_members > 1) in create_perf_stat_counter()
677 attr->read_format |= PERF_FORMAT_ID|PERF_FORMAT_GROUP; in create_perf_stat_counter()
679 attr->inherit = !config->no_inherit && list_empty(&evsel->bpf_counter_list); in create_perf_stat_counter()
685 attr->sample_period = 0; in create_perf_stat_counter()
687 if (config->identifier) in create_perf_stat_counter()
688 attr->sample_type = PERF_SAMPLE_IDENTIFIER; in create_perf_stat_counter()
690 if (config->all_user) { in create_perf_stat_counter()
691 attr->exclude_kernel = 1; in create_perf_stat_counter()
692 attr->exclude_user = 0; in create_perf_stat_counter()
695 if (config->all_kernel) { in create_perf_stat_counter()
696 attr->exclude_kernel = 0; in create_perf_stat_counter()
697 attr->exclude_user = 1; in create_perf_stat_counter()
706 attr->disabled = 1; in create_perf_stat_counter()
709 attr->enable_on_exec = 1; in create_perf_stat_counter()
713 evsel->core.threads); in create_perf_stat_counter()
736 return -1; in __run_perf_stat()
738 child_pid = evsel_list->workload.pid; in __run_perf_stat()
741 if (!cpu_map__is_dummy(evsel_list->core.user_requested_cpus)) { in __run_perf_stat()
743 err = -1; in __run_perf_stat()
750 counter->reset_group = false; in __run_perf_stat()
752 err = -1; in __run_perf_stat()
771 if (counter->reset_group || !counter->supported) in __run_perf_stat()
791 counter->weak_group) { in __run_perf_stat()
793 assert(counter->reset_group); in __run_perf_stat()
794 counter->supported = true; in __run_perf_stat()
814 if (!counter->reset_group && counter->supported) in __run_perf_stat()
817 perf_evsel__close_cpu(&counter->core, evlist_cpu_itr.cpu_map_idx); in __run_perf_stat()
823 if (!counter->reset_group) in __run_perf_stat()
843 if (!counter->supported) { in __run_perf_stat()
844 perf_evsel__free_fd(&counter->core); in __run_perf_stat()
849 l = strlen(counter->unit); in __run_perf_stat()
855 err = -1; in __run_perf_stat()
864 if (child_pid != -1) in __run_perf_stat()
866 err = -1; in __run_perf_stat()
872 counter->filter, evsel__name(counter), errno, in __run_perf_stat()
874 return -1; in __run_perf_stat()
902 err = -1; in __run_perf_stat()
915 err = -1; in __run_perf_stat()
928 if (child_pid != -1) { in __run_perf_stat()
937 err = -1; in __run_perf_stat()
952 stat_config.walltime_run[run_idx] = t1 - t0; in __run_perf_stat()
958 update_stats(&walltime_nsecs_stats, t1 - t0); in __run_perf_stat()
964 update_stats(&walltime_nsecs_stats, t1 - t0); in __run_perf_stat()
995 * Returns -1 for fatal errors which signifies to not continue
998 * Returns < -1 error codes when stat record is used. These
1039 static volatile sig_atomic_t signr = -1;
1043 if ((child_pid == -1) || stat_config.interval) in skip_signal()
1053 child_pid = -1; in skip_signal()
1070 if (child_pid != -1) in sig_atexit()
1075 if (signr == -1) in sig_atexit()
1106 return -ENOMEM; in append_metric_groups()
1112 return -ENOMEM; in append_metric_groups()
1121 struct perf_stat_config *config = opt->value; in parse_control_option()
1123 return evlist__parse_control(str, &config->ctl_fd, &config->ctl_fd_ack, &config->ctl_fd_close); in parse_control_option()
1130 pr_err("--cgroup and --for-each-cgroup cannot be used together\n"); in parse_stat_cgroups()
1131 return -1; in parse_stat_cgroups()
1142 struct evlist *evlist = *(struct evlist **)opt->value; in parse_cputype()
1144 if (!list_empty(&evlist->core.entries)) { in parse_cputype()
1146 return -1; in parse_cputype()
1151 fprintf(stderr, "--cputype %s is not supported!\n", str); in parse_cputype()
1152 return -1; in parse_cputype()
1154 parse_events_option_args.pmu_filter = pmu->name; in parse_cputype()
1164 struct opt_aggr_mode *opt_aggr_mode = (struct opt_aggr_mode *)opt->value; in parse_cache_level()
1165 u32 *aggr_level = (u32 *)opt->data; in parse_cache_level()
1168 * If no string is specified, aggregate based on the topology of in parse_cache_level()
1183 pr_err("Cache level must be of form L[1-%d], or l[1-%d]\n", in parse_cache_level()
1186 return -EINVAL; in parse_cache_level()
1191 pr_err("Cache level must be of form L[1-%d], or l[1-%d]\n", in parse_cache_level()
1194 return -EINVAL; in parse_cache_level()
1200 return -EINVAL; in parse_cache_level()
1203 opt_aggr_mode->cache = true; in parse_cache_level()
1224 if (id == -1) in cpu__get_cache_id_from_map()
1234 * cpu__get_cache_id - Returns 0 if successful in populating the
1247 cache->cache_lvl = (cache_level > MAX_CACHE_LVL) ? 0 : cache_level; in cpu__get_cache_details()
1248 cache->cache = -1; in cpu__get_cache_details()
1264 return -1; in cpu__get_cache_details()
1278 cache->cache_lvl = caches[max_level_index].level; in cpu__get_cache_details()
1279 cache->cache = cpu__get_cache_id_from_map(cpu, caches[max_level_index].map); in cpu__get_cache_details()
1288 cache->cache_lvl = cache_level; in cpu__get_cache_details()
1289 cache->cache = cpu__get_cache_id_from_map(cpu, caches[i].map); in cpu__get_cache_details()
1306 * aggr_cpu_id__cache - Create an aggr_cpu_id with cache instache ID, cache
1396 /* per-process mode - should use global aggr mode */ in perf_stat__get_aggr()
1397 if (cpu.cpu == -1 || cpu.cpu >= config->cpus_aggr_map->nr) in perf_stat__get_aggr()
1400 if (aggr_cpu_id__is_empty(&config->cpus_aggr_map->map[cpu.cpu])) in perf_stat__get_aggr()
1401 config->cpus_aggr_map->map[cpu.cpu] = get_id(config, cpu); in perf_stat__get_aggr()
1403 id = config->cpus_aggr_map->map[cpu.cpu]; in perf_stat__get_aggr()
1516 stat_config.aggr_map = cpu_aggr_map__new(evsel_list->core.user_requested_cpus, in perf_stat_init_aggr_mode()
1520 return -1; in perf_stat_init_aggr_mode()
1526 nr = perf_thread_map__nr(evsel_list->core.threads); in perf_stat_init_aggr_mode()
1529 return -ENOMEM; in perf_stat_init_aggr_mode()
1535 stat_config.aggr_map->map[s] = id; in perf_stat_init_aggr_mode()
1541 * The evsel_list->cpus is the base we operate on, in perf_stat_init_aggr_mode()
1545 nr = perf_cpu_map__max(evsel_list->core.all_cpus).cpu + 1; in perf_stat_init_aggr_mode()
1547 return stat_config.cpus_aggr_map ? 0 : -ENOMEM; in perf_stat_init_aggr_mode()
1568 if (cpu.cpu != -1) in perf_env__get_socket_aggr_by_cpu()
1569 id.socket = env->cpu[cpu.cpu].socket_id; in perf_env__get_socket_aggr_by_cpu()
1579 if (cpu.cpu != -1) { in perf_env__get_die_aggr_by_cpu()
1585 id.socket = env->cpu[cpu.cpu].socket_id; in perf_env__get_die_aggr_by_cpu()
1586 id.die = env->cpu[cpu.cpu].die_id; in perf_env__get_die_aggr_by_cpu()
1596 int caches_cnt = env->caches_cnt; in perf_env__get_cache_id_for_cpu()
1597 struct cpu_cache_level *caches = env->caches; in perf_env__get_cache_id_for_cpu()
1599 id->cache_lvl = (cache_level > MAX_CACHE_LVL) ? 0 : cache_level; in perf_env__get_cache_id_for_cpu()
1600 id->cache = -1; in perf_env__get_cache_id_for_cpu()
1605 for (i = caches_cnt - 1; i > -1; --i) { in perf_env__get_cache_id_for_cpu()
1621 if (map_contains_cpu != -1) { in perf_env__get_cache_id_for_cpu()
1622 id->cache_lvl = caches[i].level; in perf_env__get_cache_id_for_cpu()
1623 id->cache = cpu__get_cache_id_from_map(cpu, caches[i].map); in perf_env__get_cache_id_for_cpu()
1635 if (cpu.cpu != -1) { in perf_env__get_cache_aggr_by_cpu()
1638 id.socket = env->cpu[cpu.cpu].socket_id; in perf_env__get_cache_aggr_by_cpu()
1639 id.die = env->cpu[cpu.cpu].die_id; in perf_env__get_cache_aggr_by_cpu()
1652 if (cpu.cpu != -1) { in perf_env__get_cluster_aggr_by_cpu()
1653 id.socket = env->cpu[cpu.cpu].socket_id; in perf_env__get_cluster_aggr_by_cpu()
1654 id.die = env->cpu[cpu.cpu].die_id; in perf_env__get_cluster_aggr_by_cpu()
1655 id.cluster = env->cpu[cpu.cpu].cluster_id; in perf_env__get_cluster_aggr_by_cpu()
1666 if (cpu.cpu != -1) { in perf_env__get_core_aggr_by_cpu()
1671 id.socket = env->cpu[cpu.cpu].socket_id; in perf_env__get_core_aggr_by_cpu()
1672 id.die = env->cpu[cpu.cpu].die_id; in perf_env__get_core_aggr_by_cpu()
1673 id.cluster = env->cpu[cpu.cpu].cluster_id; in perf_env__get_core_aggr_by_cpu()
1674 id.core = env->cpu[cpu.cpu].core_id; in perf_env__get_core_aggr_by_cpu()
1685 if (cpu.cpu != -1) { in perf_env__get_cpu_aggr_by_cpu()
1691 id.socket = env->cpu[cpu.cpu].socket_id; in perf_env__get_cpu_aggr_by_cpu()
1692 id.die = env->cpu[cpu.cpu].die_id; in perf_env__get_cpu_aggr_by_cpu()
1693 id.core = env->cpu[cpu.cpu].core_id; in perf_env__get_cpu_aggr_by_cpu()
1821 struct perf_env *env = perf_session__env(st->session); in perf_stat_init_aggr_mode_file()
1826 int nr = perf_thread_map__nr(evsel_list->core.threads); in perf_stat_init_aggr_mode_file()
1830 return -ENOMEM; in perf_stat_init_aggr_mode_file()
1836 stat_config.aggr_map->map[s] = id; in perf_stat_init_aggr_mode_file()
1844 stat_config.aggr_map = cpu_aggr_map__new(evsel_list->core.user_requested_cpus, in perf_stat_init_aggr_mode_file()
1848 return -1; in perf_stat_init_aggr_mode_file()
1856 * if -d/--detailed, -d -d or -d -d -d is used:
1867 return -ENOMEM; in add_default_events()
1876 /* Handle -T as -M transaction. Once platform specific metrics in add_default_events()
1883 ret = -1; in add_default_events()
1897 int smi; in add_default_events() local
1899 if (sysfs__read_int(FREEZE_ON_SMI_PATH, &smi) < 0) { in add_default_events()
1901 ret = -1; in add_default_events()
1905 if (!smi) { in add_default_events()
1908 ret = -1; in add_default_events()
1914 if (!metricgroup__has_metric_or_groups(pmu, "smi")) { in add_default_events()
1915 pr_err("Missing smi metrics\n"); in add_default_events()
1916 ret = -1; in add_default_events()
1923 ret = metricgroup__parse_groups(evlist, pmu, "smi", in add_default_events()
1943 ret = -1; in add_default_events()
1947 pr_err("Invalid top-down metrics level. The max level is %u.\n", max_level); in add_default_events()
1948 ret = -1; in add_default_events()
1956 "Please print the result regularly, e.g. -I1000\n"); in add_default_events()
1967 ret = -1; in add_default_events()
1975 if (!evlist->core.nr_entries && !evsel_list->core.nr_entries) { in add_default_events()
1978 ret = parse_events(evlist, "cpu-clock", &err); in add_default_events()
1980 ret = parse_events(evlist, "task-clock", &err); in add_default_events()
1985 "context-switches," in add_default_events()
1986 "cpu-migrations," in add_default_events()
1987 "page-faults," in add_default_events()
1990 "stalled-cycles-frontend," in add_default_events()
1991 "stalled-cycles-backend," in add_default_events()
1993 "branch-misses", in add_default_events()
2006 ret = -ENOMEM; in add_default_events()
2016 ret = -1; in add_default_events()
2021 evsel->default_metricgroup = true; in add_default_events()
2023 evlist__splice_list_tail(evlist, &metric_evlist->core.entries); in add_default_events()
2025 &evlist->metric_events, in add_default_events()
2026 &metric_evlist->metric_events); in add_default_events()
2035 * Detailed stats (-d), covering the L1 and last level data in add_default_events()
2039 "L1-dcache-loads," in add_default_events()
2040 "L1-dcache-load-misses," in add_default_events()
2041 "LLC-loads," in add_default_events()
2042 "LLC-load-misses", in add_default_events()
2047 * Very detailed stats (-d -d), covering the instruction cache in add_default_events()
2051 "L1-icache-loads," in add_default_events()
2052 "L1-icache-load-misses," in add_default_events()
2053 "dTLB-loads," in add_default_events()
2054 "dTLB-load-misses," in add_default_events()
2055 "iTLB-loads," in add_default_events()
2056 "iTLB-load-misses", in add_default_events()
2061 * Very, very detailed stats (-d -d -d), adding prefetch events: in add_default_events()
2064 "L1-dcache-prefetches," in add_default_events()
2065 "L1-dcache-prefetch-misses", in add_default_events()
2072 * Make at least one event non-skippable so fatal errors are visible. in add_default_events()
2073 * 'cycles' always used to be default and non-skippable, so use that. in add_default_events()
2076 evsel->skippable = true; in add_default_events()
2080 evlist__splice_list_tail(evsel_list, &evlist->core.entries); in add_default_events()
2082 &evsel_list->metric_events, in add_default_events()
2083 &evlist->metric_events); in add_default_events()
2098 perf_header__set_feat(&session->header, feat); in init_features()
2100 perf_header__clear_feat(&session->header, HEADER_DIR_FORMAT); in init_features()
2101 perf_header__clear_feat(&session->header, HEADER_BUILD_ID); in init_features()
2102 perf_header__clear_feat(&session->header, HEADER_TRACING_DATA); in init_features()
2103 perf_header__clear_feat(&session->header, HEADER_BRANCH_STACK); in init_features()
2104 perf_header__clear_feat(&session->header, HEADER_AUXTRACE); in init_features()
2118 data->path = output_name; in __cmd_record()
2121 pr_err("Cannot use -r option with perf stat record.\n"); in __cmd_record()
2122 return -1; in __cmd_record()
2133 session->evlist = evsel_list; in __cmd_record()
2142 struct perf_record_stat_round *stat_round = &event->stat_round; in process_stat_round_event()
2145 const char **argv = env->cmdline_argv; in process_stat_round_event()
2146 int argc = env->nr_cmdline; in process_stat_round_event()
2150 if (stat_round->type == PERF_STAT_ROUND_TYPE__FINAL) in process_stat_round_event()
2151 update_stats(&walltime_nsecs_stats, stat_round->time); in process_stat_round_event()
2153 if (stat_config.interval && stat_round->time) { in process_stat_round_event()
2154 tsh.tv_sec = stat_round->time / NSEC_PER_SEC; in process_stat_round_event()
2155 tsh.tv_nsec = stat_round->time % NSEC_PER_SEC; in process_stat_round_event()
2167 const struct perf_tool *tool = session->tool; in process_stat_config_event()
2170 perf_event__read_stat_config(&stat_config, &event->stat_config); in process_stat_config_event()
2172 if (perf_cpu_map__is_empty(st->cpus)) { in process_stat_config_event()
2173 if (st->aggr_mode != AGGR_UNSET) in process_stat_config_event()
2175 } else if (st->aggr_mode != AGGR_UNSET) { in process_stat_config_event()
2176 stat_config.aggr_mode = st->aggr_mode; in process_stat_config_event()
2185 int nr_aggr = stat_config.aggr_map->nr; in process_stat_config_event()
2187 if (evlist__alloc_aggr_stats(session->evlist, nr_aggr) < 0) { in process_stat_config_event()
2189 return -1; in process_stat_config_event()
2197 if (!st->cpus || !st->threads) in set_maps()
2200 if (WARN_ONCE(st->maps_allocated, "stats double allocation\n")) in set_maps()
2201 return -EINVAL; in set_maps()
2203 perf_evlist__set_maps(&evsel_list->core, st->cpus, st->threads); in set_maps()
2206 return -ENOMEM; in set_maps()
2208 st->maps_allocated = true; in set_maps()
2216 const struct perf_tool *tool = session->tool; in process_thread_map_event()
2219 if (st->threads) { in process_thread_map_event()
2224 st->threads = thread_map__new_event(&event->thread_map); in process_thread_map_event()
2225 if (!st->threads) in process_thread_map_event()
2226 return -ENOMEM; in process_thread_map_event()
2235 const struct perf_tool *tool = session->tool; in process_cpu_map_event()
2239 if (st->cpus) { in process_cpu_map_event()
2244 cpus = cpu_map__new_data(&event->cpu_map.data); in process_cpu_map_event()
2246 return -ENOMEM; in process_cpu_map_event()
2248 st->cpus = cpus; in process_cpu_map_event()
2267 OPT_SET_UINT(0, "per-socket", &perf_stat.aggr_mode, in __cmd_report()
2269 OPT_SET_UINT(0, "per-die", &perf_stat.aggr_mode, in __cmd_report()
2271 OPT_SET_UINT(0, "per-cluster", &perf_stat.aggr_mode, in __cmd_report()
2273 OPT_CALLBACK_OPTARG(0, "per-cache", &perf_stat.aggr_mode, &perf_stat.aggr_level, in __cmd_report()
2277 OPT_SET_UINT(0, "per-core", &perf_stat.aggr_mode, in __cmd_report()
2279 OPT_SET_UINT(0, "per-node", &perf_stat.aggr_mode, in __cmd_report()
2281 OPT_SET_UINT('A', "no-aggr", &perf_stat.aggr_mode, in __cmd_report()
2292 input_name = "-"; in __cmd_report()
2316 evsel_list = session->evlist; in __cmd_report()
2329 * Make system wide (-a) the default target if in setup_system_wide()
2333 * - there's no workload specified in setup_system_wide()
2334 * - there is workload specified but all requested in setup_system_wide()
2346 if (!counter->core.requires_cpu && in setup_system_wide()
2352 if (evsel_list->core.nr_entries) in setup_system_wide()
2361 enum tpebs_mode *mode = opt->value; in parse_tpebs_mode()
2379 return -1; in parse_tpebs_mode()
2394 OPT_BOOLEAN('i', "no-inherit", &stat_config.no_inherit, in cmd_stat()
2401 OPT_STRING('b', "bpf-prog", &target.bpf_str, "bpf-prog-id", in cmd_stat()
2403 OPT_BOOLEAN(0, "bpf-counters", &target.use_bpf, in cmd_stat()
2405 OPT_STRING(0, "bpf-attr-map", &target.attr_map, "attr-map-path", in cmd_stat()
2408 OPT_BOOLEAN('a', "all-cpus", &target.system_wide, in cmd_stat()
2409 "system-wide collection from all CPUs"), in cmd_stat()
2411 "Use --no-scale to disable counter scaling for multiplexing"), in cmd_stat()
2417 "display details about each run (only with -r option)"), in cmd_stat()
2419 "null run - dont start any counters"), in cmd_stat()
2421 "detailed run - start a lot of events"), in cmd_stat()
2424 OPT_CALLBACK_NOOPT('B', "big-num", NULL, NULL, in cmd_stat()
2428 "list of cpus to monitor in system-wide"), in cmd_stat()
2429 OPT_BOOLEAN('A', "no-aggr", &opt_mode.no_aggr, in cmd_stat()
2431 OPT_BOOLEAN(0, "no-merge", &opt_mode.no_aggr, in cmd_stat()
2432 "disable aggregation the same as -A or -no-aggr"), in cmd_stat()
2433 OPT_BOOLEAN(0, "hybrid-merge", &stat_config.hybrid_merge, in cmd_stat()
2435 OPT_STRING('x', "field-separator", &stat_config.csv_sep, "separator", in cmd_stat()
2437 OPT_BOOLEAN('j', "json-output", &stat_config.json_output, in cmd_stat()
2441 OPT_STRING(0, "for-each-cgroup", &stat_config.cgroup_list, "name", in cmd_stat()
2445 OPT_INTEGER(0, "log-fd", &output_fd, in cmd_stat()
2451 OPT_UINTEGER('I', "interval-print", &stat_config.interval, in cmd_stat()
2454 OPT_INTEGER(0, "interval-count", &stat_config.times, in cmd_stat()
2456 OPT_BOOLEAN(0, "interval-clear", &stat_config.interval_clear, in cmd_stat()
2460 OPT_BOOLEAN(0, "per-socket", &opt_mode.socket, in cmd_stat()
2462 OPT_BOOLEAN(0, "per-die", &opt_mode.die, "aggregate counts per processor die"), in cmd_stat()
2463 OPT_BOOLEAN(0, "per-cluster", &opt_mode.cluster, in cmd_stat()
2465 OPT_CALLBACK_OPTARG(0, "per-cache", &opt_mode, &stat_config.aggr_level, in cmd_stat()
2468 OPT_BOOLEAN(0, "per-core", &opt_mode.core, in cmd_stat()
2470 OPT_BOOLEAN(0, "per-thread", &opt_mode.thread, "aggregate counts per thread"), in cmd_stat()
2471 OPT_BOOLEAN(0, "per-node", &opt_mode.node, "aggregate counts per numa node"), in cmd_stat()
2473 "ms to wait before starting measurement after program start (-1: start with events disabled)"), in cmd_stat()
2474 OPT_CALLBACK_NOOPT(0, "metric-only", &stat_config.metric_only, NULL, in cmd_stat()
2476 OPT_BOOLEAN(0, "metric-no-group", &stat_config.metric_no_group, in cmd_stat()
2478 OPT_BOOLEAN(0, "metric-no-merge", &stat_config.metric_no_merge, in cmd_stat()
2480 OPT_BOOLEAN(0, "metric-no-threshold", &stat_config.metric_no_threshold, in cmd_stat()
2483 "measure top-down statistics"), in cmd_stat()
2485 OPT_BOOLEAN(0, "record-tpebs", &tpebs_recording, in cmd_stat()
2487 OPT_CALLBACK(0, "tpebs-mode", &tpebs_mode, "tpebs-mode", in cmd_stat()
2491 OPT_UINTEGER(0, "td-level", &stat_config.topdown_level, in cmd_stat()
2492 "Set the metrics level for the top-down statistics (0: max level)"), in cmd_stat()
2493 OPT_BOOLEAN(0, "smi-cost", &smi_cost, in cmd_stat()
2494 "measure SMI cost"), in cmd_stat()
2498 OPT_BOOLEAN_FLAG(0, "all-kernel", &stat_config.all_kernel, in cmd_stat()
2501 OPT_BOOLEAN_FLAG(0, "all-user", &stat_config.all_user, in cmd_stat()
2504 OPT_BOOLEAN(0, "percore-show-thread", &stat_config.percore_show_thread, in cmd_stat()
2510 OPT_BOOLEAN(0, "no-csv-summary", &stat_config.no_csv_summary, in cmd_stat()
2519 OPT_CALLBACK(0, "pfm-events", &evsel_list, "event", in cmd_stat()
2523 OPT_CALLBACK(0, "control", &stat_config, "fd:ctl-fd[,ack-fd] or fifo:ctl-fifo[,ack-fifo]", in cmd_stat()
2524 …"Listen on ctl-fd descriptor for command to control measurement ('enable': enable events, 'disable… in cmd_stat()
2525 "\t\t\t Optionally send control command completion ('ack\\n') to ack-fd descriptor.\n" in cmd_stat()
2526 "\t\t\t Alternatively, ctl-fifo / ack-fifo will be opened and used as ctl-fd / ack-fd.", in cmd_stat()
2537 int status = -EINVAL, run_idx, err; in cmd_stat()
2548 return -ENOMEM; in cmd_stat()
2552 /* String-parsing callback-based options would segfault when negated */ in cmd_stat()
2573 return -1; in cmd_stat()
2581 * For record command the -o is already taken care of. in cmd_stat()
2583 if (!STAT_RECORD && output_name && strcmp(output_name, "-")) in cmd_stat()
2587 fprintf(stderr, "cannot use both --output and --log-fd\n"); in cmd_stat()
2589 parse_options_usage(NULL, stat_options, "log-fd", 0); in cmd_stat()
2594 fprintf(stderr, "--metric-only is not supported with --per-thread\n"); in cmd_stat()
2599 fprintf(stderr, "--metric-only is not supported with -r\n"); in cmd_stat()
2605 * Current CSV and metric-only JSON output doesn't display the in cmd_stat()
2612 fprintf(stderr, "--table is only supported with -r\n"); in cmd_stat()
2619 fprintf(stderr, "argument to --log-fd must be a > 0\n"); in cmd_stat()
2620 parse_options_usage(stat_usage, stat_options, "log-fd", 0); in cmd_stat()
2631 return -1; in cmd_stat()
2642 return -errno; in cmd_stat()
2647 fprintf(stderr, "--interval-clear does not work with output\n"); in cmd_stat()
2649 parse_options_usage(NULL, stat_options, "log-fd", 0); in cmd_stat()
2650 parse_options_usage(NULL, stat_options, "interval-clear", 0); in cmd_stat()
2651 return -1; in cmd_stat()
2657 * let the spreadsheet do the pretty-printing in cmd_stat()
2660 /* User explicitly passed -B? */ in cmd_stat()
2662 fprintf(stderr, "-B option not supported with -x\n"); in cmd_stat()
2668 } else if (big_num_opt == 0) /* User passed --no-big-num */ in cmd_stat()
2699 pr_err("failed to setup -r option"); in cmd_stat()
2707 fprintf(stderr, "The --per-thread option is only " in cmd_stat()
2708 "available when monitoring via -p -t -a " in cmd_stat()
2709 "options or only --per-thread.\n"); in cmd_stat()
2717 * no_aggr, cgroup are for system-wide only in cmd_stat()
2718 * --per-thread is aggregated per thread, we dont mix it with cpu mode in cmd_stat()
2724 fprintf(stderr, "both cgroup and no-aggregation " in cmd_stat()
2725 "modes only available in system-wide mode\n"); in cmd_stat()
2730 parse_options_usage(NULL, stat_options, "for-each-cgroup", 0); in cmd_stat()
2754 status = -ENOMEM; in cmd_stat()
2761 * knowing the target is system-wide. in cmd_stat()
2785 pr_err("--cgroup and --for-each-cgroup cannot be used together\n"); in cmd_stat()
2787 parse_options_usage(NULL, stat_options, "for-each-cgroup", 0); in cmd_stat()
2793 "for-each-cgroup", 0); in cmd_stat()
2820 thread_map__read_comms(evsel_list->core.threads); in cmd_stat()
2829 pr_err("interval-count option should be used together with " in cmd_stat()
2830 "interval-print.\n"); in cmd_stat()
2831 parse_options_usage(stat_usage, stat_options, "interval-count", 0); in cmd_stat()
2847 pr_err("timeout option is not supported with interval-print.\n"); in cmd_stat()
2865 * by attr->sample_type != 0, and we can't run it on in cmd_stat()
2871 * We dont want to block the signals - that would cause in cmd_stat()
2872 * child tasks to inherit that and Ctrl-C would not work. in cmd_stat()
2873 * What we want is for Ctrl-C to work in the exec()-ed in cmd_stat()
2886 /* Enable ignoring missing threads when -p option is defined. */ in cmd_stat()
2887 evlist__first(evsel_list)->ignore_missing_thread = target.pid; in cmd_stat()
2898 if (status == -1) in cmd_stat()
2907 if (!forever && status != -1 && (!interval || stat_config.summary)) { in cmd_stat()
2926 * tools remain -acme in cmd_stat()
2932 &perf_stat.session->machines.host); in cmd_stat()
2944 perf_stat.session->header.data_size += perf_stat.bytes_written; in cmd_stat()