Lines Matching +full:cpu +full:- +full:core

1 // SPDX-License-Identifier: GPL-2.0-only
3 * builtin-stat.c
6 * overview about any workload, CPU or specific PID.
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>
46 #include <subcmd/parse-options.h>
47 #include "util/parse-events.h"
64 #include "util/synthetic-events.h"
66 #include "util/time-utils.h"
94 #define FREEZE_ON_SMI_PATH "devices/cpu/freeze_on_smi"
98 /* Default events used for perf stat -T */
100 "task-clock,"
104 "cpu/cycles-t/,"
105 "cpu/tx-start/,"
106 "cpu/el-start/,"
107 "cpu/cycles-ct/"
111 /* More limited version when the CPU does not have all events. */
113 "task-clock,"
117 "cpu/cycles-t/,"
118 "cpu/tx-start/"
123 "topdown-total-slots",
124 "topdown-slots-retired",
125 "topdown-recovery-bubbles",
126 "topdown-fetch-bubbles",
127 "topdown-slots-issued",
133 "topdown-retiring",
134 "topdown-bad-spec",
135 "topdown-fe-bound",
136 "topdown-be-bound",
156 static volatile pid_t child_pid = -1;
162 static int big_num_opt = -1;
200 .ctl_fd = -1,
201 .ctl_fd_ack = -1
206 if (!a->core.cpus && !b->core.cpus) in cpus_map_matched()
209 if (!a->core.cpus || !b->core.cpus) in cpus_map_matched()
212 if (a->core.cpus->nr != b->core.cpus->nr) in cpus_map_matched()
215 for (int i = 0; i < a->core.cpus->nr; i++) { in cpus_map_matched()
216 if (a->core.cpus->map[i] != b->core.cpus->map[i]) in cpus_map_matched()
229 leader = evsel->leader; in evlist__check_cpu_maps()
243 cpu_map__snprint(leader->core.cpus, buf, sizeof(buf)); in evlist__check_cpu_maps()
244 pr_warning(" %s: %s\n", leader->name, buf); in evlist__check_cpu_maps()
245 cpu_map__snprint(evsel->core.cpus, buf, sizeof(buf)); in evlist__check_cpu_maps()
246 pr_warning(" %s: %s\n", evsel->name, buf); in evlist__check_cpu_maps()
250 pos->leader = pos; in evlist__check_cpu_maps()
251 pos->core.nr_members = 0; in evlist__check_cpu_maps()
253 evsel->leader->core.nr_members = 0; in evlist__check_cpu_maps()
260 r->tv_sec = a->tv_sec - b->tv_sec; in diff_timespec()
261 if (a->tv_nsec < b->tv_nsec) { in diff_timespec()
262 r->tv_nsec = a->tv_nsec + NSEC_PER_SEC - b->tv_nsec; in diff_timespec()
263 r->tv_sec--; in diff_timespec()
265 r->tv_nsec = a->tv_nsec - b->tv_nsec ; in diff_timespec()
285 if (perf_data__write(&perf_stat.data, event, event->header.size) < 0) { in process_synthesized_event()
287 return -1; in process_synthesized_event()
290 perf_stat.bytes_written += event->header.size; in process_synthesized_event()
304 #define SID(e, x, y) xyarray__entry(e->core.sample_id, x, y)
306 static int evsel__write_stat_event(struct evsel *counter, u32 cpu, u32 thread, in evsel__write_stat_event() argument
309 struct perf_sample_id *sid = SID(counter, cpu, thread); in evsel__write_stat_event()
311 return perf_event__synthesize_stat(NULL, cpu, thread, sid->id, count, in evsel__write_stat_event()
315 static int read_single_counter(struct evsel *counter, int cpu, in read_single_counter() argument
318 if (counter->tool_event == PERF_TOOL_DURATION_TIME) { in read_single_counter()
319 u64 val = rs->tv_nsec + rs->tv_sec*1000000000ULL; in read_single_counter()
321 perf_counts(counter->counts, cpu, thread); in read_single_counter()
322 count->ena = count->run = val; in read_single_counter()
323 count->val = val; in read_single_counter()
326 return evsel__read_counter(counter, cpu, thread); in read_single_counter()
331 * do not aggregate counts across CPUs in system-wide mode
333 static int read_counter_cpu(struct evsel *counter, struct timespec *rs, int cpu) in read_counter_cpu() argument
335 int nthreads = perf_thread_map__nr(evsel_list->core.threads); in read_counter_cpu()
338 if (!counter->supported) in read_counter_cpu()
339 return -ENOENT; in read_counter_cpu()
341 if (counter->core.system_wide) in read_counter_cpu()
347 count = perf_counts(counter->counts, cpu, thread); in read_counter_cpu()
351 * (via evsel__read_counter()) and sets their count->loaded. in read_counter_cpu()
353 if (!perf_counts__is_loaded(counter->counts, cpu, thread) && in read_counter_cpu()
354 read_single_counter(counter, cpu, thread, rs)) { in read_counter_cpu()
355 counter->counts->scaled = -1; in read_counter_cpu()
356 perf_counts(counter->counts, cpu, thread)->ena = 0; in read_counter_cpu()
357 perf_counts(counter->counts, cpu, thread)->run = 0; in read_counter_cpu()
358 return -1; in read_counter_cpu()
361 perf_counts__set_loaded(counter->counts, cpu, thread, false); in read_counter_cpu()
364 if (evsel__write_stat_event(counter, cpu, thread, count)) { in read_counter_cpu()
366 return -1; in read_counter_cpu()
374 cpu, in read_counter_cpu()
375 count->val, count->ena, count->run); in read_counter_cpu()
386 int i, ncpus, cpu; in read_affinity_counters() local
389 return -1; in read_affinity_counters()
391 ncpus = perf_cpu_map__nr(evsel_list->core.all_cpus); in read_affinity_counters()
394 evlist__for_each_cpu(evsel_list, i, cpu) { in read_affinity_counters()
397 affinity__set(&affinity, cpu); in read_affinity_counters()
400 if (evsel__cpu_iter_skip(counter, cpu)) in read_affinity_counters()
402 if (!counter->err) { in read_affinity_counters()
403 counter->err = read_counter_cpu(counter, rs, in read_affinity_counters()
404 counter->cpu_iter - 1); in read_affinity_counters()
420 if (counter->err) in read_counters()
421 pr_debug("failed to read counter %s\n", counter->name); in read_counters()
422 if (counter->err == 0 && perf_stat_process_counter(&stat_config, counter)) in read_counters()
423 pr_warning("failed to process counter %s\n", counter->name); in read_counters()
424 counter->err = 0; in read_counters()
432 config->stats = calloc(nthreads, sizeof(struct runtime_stat)); in runtime_stat_new()
433 if (!config->stats) in runtime_stat_new()
434 return -1; in runtime_stat_new()
436 config->stats_num = nthreads; in runtime_stat_new()
439 runtime_stat__init(&config->stats[i]); in runtime_stat_new()
448 if (!config->stats) in runtime_stat_delete()
451 for (i = 0; i < config->stats_num; i++) in runtime_stat_delete()
452 runtime_stat__exit(&config->stats[i]); in runtime_stat_delete()
454 zfree(&config->stats); in runtime_stat_delete()
461 if (!config->stats) in runtime_stat_reset()
464 for (i = 0; i < config->stats_num; i++) in runtime_stat_reset()
465 perf_stat__reset_shadow_per_stat(&config->stats[i]); in runtime_stat_reset()
493 if (interval_count && !(--(*times))) in handle_interval()
513 * - we don't have tracee (attaching to task or cpu) in enable_counters()
514 * - we have initial delay configured in enable_counters()
526 * If we don't have tracee (attaching to task or cpu), counters may in disable_counters()
544 workload_exec_errno = info->si_value.sival_int; in workload_exec_failed_signal()
549 return STAT_RECORD || counter->core.attr.read_format & PERF_FORMAT_ID; in evsel__should_store_id()
561 for (i = 0; i < threads->nr; i++) { in is_target_alive()
565 threads->map[i].pid); in is_target_alive()
607 tts -= time_diff.tv_sec * MSEC_PER_SEC + in compute_tts()
635 child_exited = !is_target_alive(&target, evsel_list->core.threads) ? 1 : 0; in dispatch_events()
674 counter->supported = false; in stat_handle_error()
677 * cpu event had a problem and needs to be reexamined. in stat_handle_error()
679 counter->errored = true; in stat_handle_error()
681 if ((counter->leader != counter) || in stat_handle_error()
682 !(counter->leader->core.nr_members > 1)) in stat_handle_error()
689 evsel_list->core.threads && in stat_handle_error()
690 evsel_list->core.threads->err_thread != -1) { in stat_handle_error()
692 * For global --per-thread case, skip current in stat_handle_error()
695 if (!thread_map__remove(evsel_list->core.threads, in stat_handle_error()
696 evsel_list->core.threads->err_thread)) { in stat_handle_error()
697 evsel_list->core.threads->err_thread = -1; in stat_handle_error()
705 if (child_pid != -1) in stat_handle_error()
723 int i, cpu; in __run_perf_stat() local
730 return -1; in __run_perf_stat()
732 child_pid = evsel_list->workload.pid; in __run_perf_stat()
739 return -1; in __run_perf_stat()
741 evlist__for_each_cpu (evsel_list, i, cpu) { in __run_perf_stat()
742 affinity__set(&affinity, cpu); in __run_perf_stat()
745 if (evsel__cpu_iter_skip(counter, cpu)) in __run_perf_stat()
747 if (counter->reset_group || counter->errored) in __run_perf_stat()
751 counter->cpu_iter - 1) < 0) { in __run_perf_stat()
761 counter->leader != counter && in __run_perf_stat()
762 counter->weak_group) { in __run_perf_stat()
764 assert(counter->reset_group); in __run_perf_stat()
771 return -1; in __run_perf_stat()
781 counter->supported = true; in __run_perf_stat()
791 evlist__for_each_cpu(evsel_list, i, cpu) { in __run_perf_stat()
792 affinity__set(&affinity, cpu); in __run_perf_stat()
795 if (!counter->reset_group && !counter->errored) in __run_perf_stat()
797 if (evsel__cpu_iter_skip_no_inc(counter, cpu)) in __run_perf_stat()
799 perf_evsel__close_cpu(&counter->core, counter->cpu_iter); in __run_perf_stat()
803 if (!counter->reset_group && !counter->errored) in __run_perf_stat()
805 if (evsel__cpu_iter_skip(counter, cpu)) in __run_perf_stat()
807 if (!counter->reset_group) in __run_perf_stat()
812 counter->cpu_iter - 1) < 0) { in __run_perf_stat()
816 return -1; in __run_perf_stat()
825 counter->supported = true; in __run_perf_stat()
832 if (!counter->supported) { in __run_perf_stat()
833 perf_evsel__free_fd(&counter->core); in __run_perf_stat()
837 l = strlen(counter->unit); in __run_perf_stat()
843 return -1; in __run_perf_stat()
848 counter->filter, evsel__name(counter), errno, in __run_perf_stat()
850 return -1; in __run_perf_stat()
884 if (child_pid != -1) { in __run_perf_stat()
893 return -1; in __run_perf_stat()
908 stat_config.walltime_run[run_idx] = t1 - t0; in __run_perf_stat()
914 update_stats(&walltime_nsecs_stats, t1 - t0); in __run_perf_stat()
924 update_stats(&walltime_nsecs_stats, t1 - t0); in __run_perf_stat()
932 read_counters(&(struct timespec) { .tv_nsec = t1-t0 }); in __run_perf_stat()
980 static volatile int signr = -1;
984 if ((child_pid == -1) || stat_config.interval) in skip_signal()
994 child_pid = -1; in skip_signal()
1011 if (child_pid != -1) in sig_atexit()
1016 if (signr == -1) in sig_atexit()
1058 struct perf_stat_config *config = opt->value; in parse_control_option()
1060 return evlist__parse_control(str, &config->ctl_fd, &config->ctl_fd_ack, &config->ctl_fd_close); in parse_control_option()
1067 pr_err("--cgroup and --for-each-cgroup cannot be used together\n"); in parse_stat_cgroups()
1068 return -1; in parse_stat_cgroups()
1082 OPT_BOOLEAN('i', "no-inherit", &stat_config.no_inherit,
1088 OPT_BOOLEAN('a', "all-cpus", &target.system_wide,
1089 "system-wide collection from all CPUs"),
1093 "Use --no-scale to disable counter scaling for multiplexing"),
1099 "display details about each run (only with -r option)"),
1101 "null run - dont start any counters"),
1103 "detailed run - start a lot of events"),
1106 OPT_CALLBACK_NOOPT('B', "big-num", NULL, NULL,
1109 OPT_STRING('C', "cpu", &target.cpu_list, "cpu",
1110 "list of cpus to monitor in system-wide"),
1111 OPT_SET_UINT('A', "no-aggr", &stat_config.aggr_mode,
1112 "disable CPU count aggregation", AGGR_NONE),
1113 OPT_BOOLEAN(0, "no-merge", &stat_config.no_merge, "Do not merge identical named events"),
1114 OPT_STRING('x', "field-separator", &stat_config.csv_sep, "separator",
1118 OPT_STRING(0, "for-each-cgroup", &stat_config.cgroup_list, "name",
1122 OPT_INTEGER(0, "log-fd", &output_fd,
1128 OPT_UINTEGER('I', "interval-print", &stat_config.interval,
1131 OPT_INTEGER(0, "interval-count", &stat_config.times,
1133 OPT_BOOLEAN(0, "interval-clear", &stat_config.interval_clear,
1137 OPT_SET_UINT(0, "per-socket", &stat_config.aggr_mode,
1139 OPT_SET_UINT(0, "per-die", &stat_config.aggr_mode,
1141 OPT_SET_UINT(0, "per-core", &stat_config.aggr_mode,
1142 "aggregate counts per physical processor core", AGGR_CORE),
1143 OPT_SET_UINT(0, "per-thread", &stat_config.aggr_mode,
1145 OPT_SET_UINT(0, "per-node", &stat_config.aggr_mode,
1148 … "ms to wait before starting measurement after program start (-1: start with events disabled)"),
1149 OPT_CALLBACK_NOOPT(0, "metric-only", &stat_config.metric_only, NULL,
1151 OPT_BOOLEAN(0, "metric-no-group", &stat_config.metric_no_group,
1153 OPT_BOOLEAN(0, "metric-no-merge", &stat_config.metric_no_merge,
1157 OPT_BOOLEAN(0, "smi-cost", &smi_cost,
1162 OPT_BOOLEAN_FLAG(0, "all-kernel", &stat_config.all_kernel,
1165 OPT_BOOLEAN_FLAG(0, "all-user", &stat_config.all_user,
1168 OPT_BOOLEAN(0, "percore-show-thread", &stat_config.percore_show_thread,
1171 "threads of same physical core"),
1175 OPT_CALLBACK(0, "pfm-events", &evsel_list, "event",
1179 OPT_CALLBACK(0, "control", &stat_config, "fd:ctl-fd[,ack-fd] or fifo:ctl-fifo[,ack-fifo]",
1180 …"Listen on ctl-fd descriptor for command to control measurement ('enable': enable events, 'disable…
1181 "\t\t\t Optionally send control command completion ('ack\\n') to ack-fd descriptor.\n"
1182 "\t\t\t Alternatively, ctl-fifo / ack-fifo will be opened and used as ctl-fd / ack-fd.",
1188 struct perf_cpu_map *map, int cpu) in perf_stat__get_socket() argument
1190 return cpu_map__get_socket(map, cpu, NULL); in perf_stat__get_socket()
1194 struct perf_cpu_map *map, int cpu) in perf_stat__get_die() argument
1196 return cpu_map__get_die(map, cpu, NULL); in perf_stat__get_die()
1200 struct perf_cpu_map *map, int cpu) in perf_stat__get_core() argument
1202 return cpu_map__get_core(map, cpu, NULL); in perf_stat__get_core()
1206 struct perf_cpu_map *map, int cpu) in perf_stat__get_node() argument
1208 return cpu_map__get_node(map, cpu, NULL); in perf_stat__get_node()
1214 int cpu; in perf_stat__get_aggr() local
1216 if (idx >= map->nr) in perf_stat__get_aggr()
1217 return -1; in perf_stat__get_aggr()
1219 cpu = map->map[idx]; in perf_stat__get_aggr()
1221 if (config->cpus_aggr_map->map[cpu] == -1) in perf_stat__get_aggr()
1222 config->cpus_aggr_map->map[cpu] = get_id(config, map, idx); in perf_stat__get_aggr()
1224 return config->cpus_aggr_map->map[cpu]; in perf_stat__get_aggr()
1256 if (counter->percore) in term_percore_set()
1269 if (cpu_map__build_socket_map(evsel_list->core.cpus, &stat_config.aggr_map)) { in perf_stat_init_aggr_mode()
1271 return -1; in perf_stat_init_aggr_mode()
1276 if (cpu_map__build_die_map(evsel_list->core.cpus, &stat_config.aggr_map)) { in perf_stat_init_aggr_mode()
1278 return -1; in perf_stat_init_aggr_mode()
1283 if (cpu_map__build_core_map(evsel_list->core.cpus, &stat_config.aggr_map)) { in perf_stat_init_aggr_mode()
1284 perror("cannot build core map"); in perf_stat_init_aggr_mode()
1285 return -1; in perf_stat_init_aggr_mode()
1290 if (cpu_map__build_node_map(evsel_list->core.cpus, &stat_config.aggr_map)) { in perf_stat_init_aggr_mode()
1291 perror("cannot build core map"); in perf_stat_init_aggr_mode()
1292 return -1; in perf_stat_init_aggr_mode()
1298 if (cpu_map__build_core_map(evsel_list->core.cpus, in perf_stat_init_aggr_mode()
1300 perror("cannot build core map"); in perf_stat_init_aggr_mode()
1301 return -1; in perf_stat_init_aggr_mode()
1314 * The evsel_list->cpus is the base we operate on, in perf_stat_init_aggr_mode()
1315 * taking the highest cpu number to be the size of in perf_stat_init_aggr_mode()
1318 nr = perf_cpu_map__max(evsel_list->core.cpus); in perf_stat_init_aggr_mode()
1320 return stat_config.cpus_aggr_map ? 0 : -ENOMEM; in perf_stat_init_aggr_mode()
1333 int cpu; in perf_env__get_cpu() local
1335 if (idx > map->nr) in perf_env__get_cpu()
1336 return -1; in perf_env__get_cpu()
1338 cpu = map->map[idx]; in perf_env__get_cpu()
1340 if (cpu >= env->nr_cpus_avail) in perf_env__get_cpu()
1341 return -1; in perf_env__get_cpu()
1343 return cpu; in perf_env__get_cpu()
1349 int cpu = perf_env__get_cpu(env, map, idx); in perf_env__get_socket() local
1351 return cpu == -1 ? -1 : env->cpu[cpu].socket_id; in perf_env__get_socket()
1357 int die_id = -1, cpu = perf_env__get_cpu(env, map, idx); in perf_env__get_die() local
1359 if (cpu != -1) { in perf_env__get_die()
1366 if (WARN_ONCE(env->cpu[cpu].socket_id >> 8, "The socket id number is too big.\n")) in perf_env__get_die()
1367 return -1; in perf_env__get_die()
1369 if (WARN_ONCE(env->cpu[cpu].die_id >> 8, "The die id number is too big.\n")) in perf_env__get_die()
1370 return -1; in perf_env__get_die()
1372 die_id = (env->cpu[cpu].socket_id << 8) | (env->cpu[cpu].die_id & 0xff); in perf_env__get_die()
1381 int core = -1, cpu = perf_env__get_cpu(env, map, idx); in perf_env__get_core() local
1383 if (cpu != -1) { in perf_env__get_core()
1389 * socket + die id + core id in perf_env__get_core()
1391 if (WARN_ONCE(env->cpu[cpu].socket_id >> 8, "The socket id number is too big.\n")) in perf_env__get_core()
1392 return -1; in perf_env__get_core()
1394 if (WARN_ONCE(env->cpu[cpu].die_id >> 8, "The die id number is too big.\n")) in perf_env__get_core()
1395 return -1; in perf_env__get_core()
1397 if (WARN_ONCE(env->cpu[cpu].core_id >> 16, "The core id number is too big.\n")) in perf_env__get_core()
1398 return -1; in perf_env__get_core()
1400 core = (env->cpu[cpu].socket_id << 24) | in perf_env__get_core()
1401 (env->cpu[cpu].die_id << 16) | in perf_env__get_core()
1402 (env->cpu[cpu].core_id & 0xffff); in perf_env__get_core()
1405 return core; in perf_env__get_core()
1410 int cpu = perf_env__get_cpu(data, map, idx); in perf_env__get_node() local
1412 return perf_env__numa_node(data, cpu); in perf_env__get_node()
1442 return perf_env__get_socket(map, idx, &perf_stat.session->header.env); in perf_stat__get_socket_file()
1447 return perf_env__get_die(map, idx, &perf_stat.session->header.env); in perf_stat__get_die_file()
1453 return perf_env__get_core(map, idx, &perf_stat.session->header.env); in perf_stat__get_core_file()
1459 return perf_env__get_node(map, idx, &perf_stat.session->header.env); in perf_stat__get_node_file()
1464 struct perf_env *env = &st->session->header.env; in perf_stat_init_aggr_mode_file()
1468 if (perf_env__build_socket_map(env, evsel_list->core.cpus, &stat_config.aggr_map)) { in perf_stat_init_aggr_mode_file()
1470 return -1; in perf_stat_init_aggr_mode_file()
1475 if (perf_env__build_die_map(env, evsel_list->core.cpus, &stat_config.aggr_map)) { in perf_stat_init_aggr_mode_file()
1477 return -1; in perf_stat_init_aggr_mode_file()
1482 if (perf_env__build_core_map(env, evsel_list->core.cpus, &stat_config.aggr_map)) { in perf_stat_init_aggr_mode_file()
1483 perror("cannot build core map"); in perf_stat_init_aggr_mode_file()
1484 return -1; in perf_stat_init_aggr_mode_file()
1489 if (perf_env__build_node_map(env, evsel_list->core.cpus, &stat_config.aggr_map)) { in perf_stat_init_aggr_mode_file()
1490 perror("cannot build core map"); in perf_stat_init_aggr_mode_file()
1491 return -1; in perf_stat_init_aggr_mode_file()
1508 * if -d/--detailed, -d -d or -d -d -d is used:
1536 * Detailed stats (-d), covering the L1 and last level data caches: in add_default_attributes()
1566 * Very detailed stats (-d -d), covering the instruction cache and the TLB caches: in add_default_attributes()
1609 * Very, very detailed stats (-d -d -d), adding prefetch events: in add_default_attributes()
1633 /* Handle -T as -M transaction. Once platform specific metrics in add_default_attributes()
1647 if (pmu_have_event("cpu", "cycles-ct") && in add_default_attributes()
1648 pmu_have_event("cpu", "el-start")) in add_default_attributes()
1658 return -1; in add_default_attributes()
1668 return -1; in add_default_attributes()
1674 return -1; in add_default_attributes()
1686 "msr/aperf/, msr/smi/ and cpu/cycles/ support\n"); in add_default_attributes()
1688 return -1; in add_default_attributes()
1693 return -1; in add_default_attributes()
1707 return -1; in add_default_attributes()
1713 "Please print the result regularly, e.g. -I1000\n"); in add_default_attributes()
1722 pr_err("top down event configuration requires --per-core mode\n"); in add_default_attributes()
1723 return -1; in add_default_attributes()
1727 pr_err("top down event configuration requires system-wide mode (-a)\n"); in add_default_attributes()
1728 return -1; in add_default_attributes()
1734 return -1; in add_default_attributes()
1747 return -1; in add_default_attributes()
1751 return -1; in add_default_attributes()
1756 if (!evsel_list->core.nr_entries) { in add_default_attributes()
1761 return -1; in add_default_attributes()
1762 if (pmu_have_event("cpu", "stalled-cycles-frontend")) { in add_default_attributes()
1764 return -1; in add_default_attributes()
1766 if (pmu_have_event("cpu", "stalled-cycles-backend")) { in add_default_attributes()
1768 return -1; in add_default_attributes()
1771 return -1; in add_default_attributes()
1781 return -1; in add_default_attributes()
1788 return -1; in add_default_attributes()
1807 perf_header__set_feat(&session->header, feat); in init_features()
1809 perf_header__clear_feat(&session->header, HEADER_DIR_FORMAT); in init_features()
1810 perf_header__clear_feat(&session->header, HEADER_BUILD_ID); in init_features()
1811 perf_header__clear_feat(&session->header, HEADER_TRACING_DATA); in init_features()
1812 perf_header__clear_feat(&session->header, HEADER_BRANCH_STACK); in init_features()
1813 perf_header__clear_feat(&session->header, HEADER_AUXTRACE); in init_features()
1825 data->path = output_name; in __cmd_record()
1828 pr_err("Cannot use -r option with perf stat record.\n"); in __cmd_record()
1829 return -1; in __cmd_record()
1840 session->evlist = evsel_list; in __cmd_record()
1849 struct perf_record_stat_round *stat_round = &event->stat_round; in process_stat_round_event()
1852 const char **argv = session->header.env.cmdline_argv; in process_stat_round_event()
1853 int argc = session->header.env.nr_cmdline; in process_stat_round_event()
1858 if (stat_round->type == PERF_STAT_ROUND_TYPE__FINAL) in process_stat_round_event()
1859 update_stats(&walltime_nsecs_stats, stat_round->time); in process_stat_round_event()
1861 if (stat_config.interval && stat_round->time) { in process_stat_round_event()
1862 tsh.tv_sec = stat_round->time / NSEC_PER_SEC; in process_stat_round_event()
1863 tsh.tv_nsec = stat_round->time % NSEC_PER_SEC; in process_stat_round_event()
1875 struct perf_tool *tool = session->tool; in process_stat_config_event()
1878 perf_event__read_stat_config(&stat_config, &event->stat_config); in process_stat_config_event()
1880 if (perf_cpu_map__empty(st->cpus)) { in process_stat_config_event()
1881 if (st->aggr_mode != AGGR_UNSET) in process_stat_config_event()
1886 if (st->aggr_mode != AGGR_UNSET) in process_stat_config_event()
1887 stat_config.aggr_mode = st->aggr_mode; in process_stat_config_event()
1899 if (!st->cpus || !st->threads) in set_maps()
1902 if (WARN_ONCE(st->maps_allocated, "stats double allocation\n")) in set_maps()
1903 return -EINVAL; in set_maps()
1905 perf_evlist__set_maps(&evsel_list->core, st->cpus, st->threads); in set_maps()
1908 return -ENOMEM; in set_maps()
1910 st->maps_allocated = true; in set_maps()
1918 struct perf_tool *tool = session->tool; in process_thread_map_event()
1921 if (st->threads) { in process_thread_map_event()
1926 st->threads = thread_map__new_event(&event->thread_map); in process_thread_map_event()
1927 if (!st->threads) in process_thread_map_event()
1928 return -ENOMEM; in process_thread_map_event()
1937 struct perf_tool *tool = session->tool; in process_cpu_map_event()
1941 if (st->cpus) { in process_cpu_map_event()
1942 pr_warning("Extra cpu map event, ignoring.\n"); in process_cpu_map_event()
1946 cpus = cpu_map__new_data(&event->cpu_map.data); in process_cpu_map_event()
1948 return -ENOMEM; in process_cpu_map_event()
1950 st->cpus = cpus; in process_cpu_map_event()
1977 OPT_SET_UINT(0, "per-socket", &perf_stat.aggr_mode, in __cmd_report()
1979 OPT_SET_UINT(0, "per-die", &perf_stat.aggr_mode, in __cmd_report()
1981 OPT_SET_UINT(0, "per-core", &perf_stat.aggr_mode, in __cmd_report()
1982 "aggregate counts per physical processor core", AGGR_CORE), in __cmd_report()
1983 OPT_SET_UINT(0, "per-node", &perf_stat.aggr_mode, in __cmd_report()
1985 OPT_SET_UINT('A', "no-aggr", &perf_stat.aggr_mode, in __cmd_report()
1986 "disable CPU count aggregation", AGGR_NONE), in __cmd_report()
1996 input_name = "-"; in __cmd_report()
2010 evsel_list = session->evlist; in __cmd_report()
2023 * Make system wide (-a) the default target if in setup_system_wide()
2027 * - there's no workload specified in setup_system_wide()
2028 * - there is workload specified but all requested in setup_system_wide()
2040 if (!counter->core.system_wide && in setup_system_wide()
2041 strcmp(counter->name, "duration_time")) { in setup_system_wide()
2046 if (evsel_list->core.nr_entries) in setup_system_wide()
2057 int status = -EINVAL, run_idx; in cmd_stat()
2067 return -ENOMEM; in cmd_stat()
2071 /* String-parsing callback-based options would segfault when negated */ in cmd_stat()
2092 return -1; in cmd_stat()
2100 * For record command the -o is already taken care of. in cmd_stat()
2102 if (!STAT_RECORD && output_name && strcmp(output_name, "-")) in cmd_stat()
2106 fprintf(stderr, "cannot use both --output and --log-fd\n"); in cmd_stat()
2108 parse_options_usage(NULL, stat_options, "log-fd", 0); in cmd_stat()
2113 fprintf(stderr, "--metric-only is not supported with --per-thread\n"); in cmd_stat()
2118 fprintf(stderr, "--metric-only is not supported with -r\n"); in cmd_stat()
2123 fprintf(stderr, "--table is only supported with -r\n"); in cmd_stat()
2130 fprintf(stderr, "argument to --log-fd must be a > 0\n"); in cmd_stat()
2131 parse_options_usage(stat_usage, stat_options, "log-fd", 0); in cmd_stat()
2142 return -1; in cmd_stat()
2151 return -errno; in cmd_stat()
2158 * let the spreadsheet do the pretty-printing in cmd_stat()
2161 /* User explicitly passed -B? */ in cmd_stat()
2163 fprintf(stderr, "-B option not supported with -x\n"); in cmd_stat()
2169 } else if (big_num_opt == 0) /* User passed --no-big-num */ in cmd_stat()
2193 pr_err("failed to setup -r option"); in cmd_stat()
2201 fprintf(stderr, "The --per-thread option is only " in cmd_stat()
2202 "available when monitoring via -p -t -a " in cmd_stat()
2203 "options or only --per-thread.\n"); in cmd_stat()
2211 * no_aggr, cgroup are for system-wide only in cmd_stat()
2212 * --per-thread is aggregated per thread, we dont mix it with cpu mode in cmd_stat()
2217 fprintf(stderr, "both cgroup and no-aggregation " in cmd_stat()
2218 "modes only available in system-wide mode\n"); in cmd_stat()
2231 pr_err("--cgroup and --for-each-cgroup cannot be used together\n"); in cmd_stat()
2233 parse_options_usage(NULL, stat_options, "for-each-cgroup", 0); in cmd_stat()
2267 thread_map__read_comms(evsel_list->core.threads); in cmd_stat()
2270 perf_thread_map__nr(evsel_list->core.threads))) { in cmd_stat()
2282 pr_err("interval-count option should be used together with " in cmd_stat()
2283 "interval-print.\n"); in cmd_stat()
2284 parse_options_usage(stat_usage, stat_options, "interval-count", 0); in cmd_stat()
2300 pr_err("timeout option is not supported with interval-print.\n"); in cmd_stat()
2318 * by attr->sample_type != 0, and we can't run it on in cmd_stat()
2324 * We dont want to block the signals - that would cause in cmd_stat()
2325 * child tasks to inherit that and Ctrl-C would not work. in cmd_stat()
2326 * What we want is for Ctrl-C to work in the exec()-ed in cmd_stat()
2349 if (forever && status != -1 && !interval) { in cmd_stat()
2355 if (!forever && status != -1 && (!interval || stat_config.summary)) in cmd_stat()
2371 * tools remain -acme in cmd_stat()
2376 &perf_stat.session->machines.host); in cmd_stat()
2388 perf_stat.session->header.data_size += perf_stat.bytes_written; in cmd_stat()