Linux Perf
|
#include "perf.h"
#include "builtin.h"
#include "util/cgroup.h"
#include "util/util.h"
#include <subcmd/parse-options.h>
#include "util/parse-events.h"
#include "util/pmu.h"
#include "util/event.h"
#include "util/evlist.h"
#include "util/evsel.h"
#include "util/debug.h"
#include "util/drv_configs.h"
#include "util/color.h"
#include "util/stat.h"
#include "util/header.h"
#include "util/cpumap.h"
#include "util/thread.h"
#include "util/thread_map.h"
#include "util/counts.h"
#include "util/group.h"
#include "util/session.h"
#include "util/tool.h"
#include "util/string2.h"
#include "util/metricgroup.h"
#include "asm/bug.h"
#include <linux/time64.h>
#include <api/fs/fs.h>
#include <errno.h>
#include <signal.h>
#include <stdlib.h>
#include <sys/prctl.h>
#include <inttypes.h>
#include <locale.h>
#include <math.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/wait.h>
#include <unistd.h>
#include <sys/time.h>
#include <sys/resource.h>
#include "sane_ctype.h"
Go to the source code of this file.
Classes | |
struct | perf_stat |
struct | outstate |
struct | aggr_data |
struct | caggr_data |
Macros | |
#define | DEFAULT_SEPARATOR " " |
#define | CNTR_NOT_SUPPORTED "<not supported>" |
#define | CNTR_NOT_COUNTED "<not counted>" |
#define | FREEZE_ON_SMI_PATH "devices/cpu/freeze_on_smi" |
#define | STAT_RECORD perf_stat.record |
#define | WRITE_STAT_ROUND_EVENT(time, interval) write_stat_round_event(time, PERF_STAT_ROUND_TYPE__ ## interval) |
#define | SID(e, x, y) xyarray__entry(e->sample_id, x, y) |
#define | FD(e, x, y) (*(int *)xyarray__entry(e->fd, x, y)) |
#define | METRIC_LEN 35 |
#define | METRIC_ONLY_LEN 20 |
Typedefs | |
typedef int(* | aggr_get_id_t) (struct cpu_map *m, int cpu) |
Functions | |
static void | print_counters (struct timespec *ts, int argc, const char **argv) |
static bool | is_duration_time (struct perf_evsel *evsel) |
static void | diff_timespec (struct timespec *r, struct timespec *a, struct timespec *b) |
static void | perf_stat__reset_stats (void) |
static int | create_perf_stat_counter (struct perf_evsel *evsel) |
static int | nsec_counter (struct perf_evsel *evsel) |
static int | process_synthesized_event (struct perf_tool *tool __maybe_unused, union perf_event *event, struct perf_sample *sample __maybe_unused, struct machine *machine __maybe_unused) |
static int | write_stat_round_event (u64 tm, u64 type) |
static int | perf_evsel__write_stat_event (struct perf_evsel *counter, u32 cpu, u32 thread, struct perf_counts_values *count) |
static int | read_counter (struct perf_evsel *counter) |
static void | read_counters (void) |
static void | process_interval (void) |
static void | enable_counters (void) |
static void | disable_counters (void) |
static void | workload_exec_failed_signal (int signo __maybe_unused, siginfo_t *info, void *ucontext __maybe_unused) |
static int | perf_stat_synthesize_config (bool is_pipe) |
static int | __store_counter_ids (struct perf_evsel *counter) |
static int | store_counter_ids (struct perf_evsel *counter) |
static bool | perf_evsel__should_store_id (struct perf_evsel *counter) |
static struct perf_evsel * | perf_evsel__reset_weak_group (struct perf_evsel *evsel) |
static int | __run_perf_stat (int argc, const char **argv, int run_idx) |
static int | run_perf_stat (int argc, const char **argv, int run_idx) |
static void | print_running (u64 run, u64 ena) |
static void | print_noise_pct (double total, double avg) |
static void | print_noise (struct perf_evsel *evsel, double avg) |
static void | aggr_printout (struct perf_evsel *evsel, int id, int nr) |
static void | new_line_std (void *ctx) |
static void | do_new_line_std (struct outstate *os) |
static void | print_metric_std (void *ctx, const char *color, const char *fmt, const char *unit, double val) |
static void | new_line_csv (void *ctx) |
static void | print_metric_csv (void *ctx, const char *color __maybe_unused, const char *fmt, const char *unit, double val) |
static bool | valid_only_metric (const char *unit) |
static const char * | fixunit (char *buf, struct perf_evsel *evsel, const char *unit) |
static void | print_metric_only (void *ctx, const char *color, const char *fmt, const char *unit, double val) |
static void | print_metric_only_csv (void *ctx, const char *color __maybe_unused, const char *fmt, const char *unit, double val) |
static void | new_line_metric (void *ctx __maybe_unused) |
static void | print_metric_header (void *ctx, const char *color __maybe_unused, const char *fmt __maybe_unused, const char *unit, double val __maybe_unused) |
static void | nsec_printout (int id, int nr, struct perf_evsel *evsel, double avg) |
static int | first_shadow_cpu (struct perf_evsel *evsel, int id) |
static void | abs_printout (int id, int nr, struct perf_evsel *evsel, double avg) |
static bool | is_mixed_hw_group (struct perf_evsel *counter) |
static void | printout (int id, int nr, struct perf_evsel *counter, double uval, char *prefix, u64 run, u64 ena, double noise, struct runtime_stat *st) |
static void | aggr_update_shadow (void) |
static void | uniquify_event_name (struct perf_evsel *counter) |
static void | collect_all_aliases (struct perf_evsel *counter, void(*cb)(struct perf_evsel *counter, void *data, bool first), void *data) |
static bool | collect_data (struct perf_evsel *counter, void(*cb)(struct perf_evsel *counter, void *data, bool first), void *data) |
static void | aggr_cb (struct perf_evsel *counter, void *data, bool first) |
static void | print_aggr (char *prefix) |
static int | cmp_val (const void *a, const void *b) |
static struct perf_aggr_thread_value * | sort_aggr_thread (struct perf_evsel *counter, int nthreads, int ncpus, int *ret) |
static void | print_aggr_thread (struct perf_evsel *counter, char *prefix) |
static void | counter_aggr_cb (struct perf_evsel *counter, void *data, bool first __maybe_unused) |
static void | print_counter_aggr (struct perf_evsel *counter, char *prefix) |
static void | counter_cb (struct perf_evsel *counter, void *data, bool first __maybe_unused) |
static void | print_counter (struct perf_evsel *counter, char *prefix) |
static void | print_no_aggr_metric (char *prefix) |
static void | print_metric_headers (const char *prefix, bool no_indent) |
static void | print_interval (char *prefix, struct timespec *ts) |
static void | print_header (int argc, const char **argv) |
static int | get_precision (double num) |
static void | print_table (FILE *output, int precision, double avg) |
static double | timeval2double (struct timeval *t) |
static void | print_footer (void) |
static void | skip_signal (int signo) |
static void | sig_atexit (void) |
static int | stat__set_big_num (const struct option *opt __maybe_unused, const char *s __maybe_unused, int unset) |
static int | enable_metric_only (const struct option *opt __maybe_unused, const char *s __maybe_unused, int unset) |
static int | parse_metric_groups (const struct option *opt, const char *str, int unset __maybe_unused) |
static int | perf_stat__get_socket (struct cpu_map *map, int cpu) |
static int | perf_stat__get_core (struct cpu_map *map, int cpu) |
static int | cpu_map__get_max (struct cpu_map *map) |
static int | perf_stat__get_aggr (aggr_get_id_t get_id, struct cpu_map *map, int idx) |
static int | perf_stat__get_socket_cached (struct cpu_map *map, int idx) |
static int | perf_stat__get_core_cached (struct cpu_map *map, int idx) |
static int | perf_stat_init_aggr_mode (void) |
static void | perf_stat__exit_aggr_mode (void) |
static int | perf_env__get_cpu (struct perf_env *env, struct cpu_map *map, int idx) |
static int | perf_env__get_socket (struct cpu_map *map, int idx, void *data) |
static int | perf_env__get_core (struct cpu_map *map, int idx, void *data) |
static int | perf_env__build_socket_map (struct perf_env *env, struct cpu_map *cpus, struct cpu_map **sockp) |
static int | perf_env__build_core_map (struct perf_env *env, struct cpu_map *cpus, struct cpu_map **corep) |
static int | perf_stat__get_socket_file (struct cpu_map *map, int idx) |
static int | perf_stat__get_core_file (struct cpu_map *map, int idx) |
static int | perf_stat_init_aggr_mode_file (struct perf_stat *st) |
static int | topdown_filter_events (const char **attr, char **str, bool use_group) |
__weak bool | arch_topdown_check_group (bool *warn) |
__weak void | arch_topdown_group_warn (void) |
static int | add_default_attributes (void) |
static void | init_features (struct perf_session *session) |
static int | __cmd_record (int argc, const char **argv) |
static int | process_stat_round_event (struct perf_tool *tool __maybe_unused, union perf_event *event, struct perf_session *session) |
static int | process_stat_config_event (struct perf_tool *tool, union perf_event *event, struct perf_session *session __maybe_unused) |
static int | set_maps (struct perf_stat *st) |
static int | process_thread_map_event (struct perf_tool *tool, union perf_event *event, struct perf_session *session __maybe_unused) |
static int | process_cpu_map_event (struct perf_tool *tool, union perf_event *event, struct perf_session *session __maybe_unused) |
static int | runtime_stat_new (struct perf_stat_config *config, int nthreads) |
static void | runtime_stat_delete (struct perf_stat_config *config) |
static int | __cmd_report (int argc, const char **argv) |
static void | setup_system_wide (int forks) |
int | cmd_stat (int argc, const char **argv) |
Variables | |
static const char * | transaction_attrs |
static const char * | transaction_limited_attrs |
static const char * | topdown_attrs [] |
static const char * | smi_cost_attrs |
static struct perf_evlist * | evsel_list |
static struct rblist | metric_events |
static struct target | target |
static int | run_count = 1 |
static bool | no_inherit = false |
static volatile pid_t | child_pid = -1 |
static bool | null_run = false |
static int | detailed_run = 0 |
static bool | transaction_run |
static bool | topdown_run = false |
static bool | smi_cost = false |
static bool | smi_reset = false |
static bool | big_num = true |
static int | big_num_opt = -1 |
static const char * | csv_sep = NULL |
static bool | csv_output = false |
static bool | group = false |
static const char * | pre_cmd = NULL |
static const char * | post_cmd = NULL |
static bool | sync_run = false |
static unsigned int | initial_delay = 0 |
static unsigned int | unit_width = 4 |
static bool | forever = false |
static bool | metric_only = false |
static bool | force_metric_only = false |
static bool | no_merge = false |
static bool | walltime_run_table = false |
static struct timespec | ref_time |
static struct cpu_map * | aggr_map |
static aggr_get_id_t | aggr_get_id |
static bool | append_file |
static bool | interval_count |
static const char * | output_name |
static int | output_fd |
static int | print_free_counters_hint |
static int | print_mixed_hw_group_error |
static u64 * | walltime_run |
static bool | ru_display = false |
static struct rusage | ru_data |
static struct perf_stat | perf_stat |
static volatile int | done = 0 |
static struct perf_stat_config | stat_config |
static volatile int | workload_exec_errno |
static int | aggr_header_lens [] |
static const char * | aggr_header_csv [] |
static volatile int | signr = -1 |
static const struct option | stat_options [] |
static struct cpu_map * | cpus_aggr_map |
static const char *const | stat_record_usage [] |
static const char *const | stat_report_usage [] |
#define CNTR_NOT_COUNTED "<not counted>" |
Definition at line 91 of file builtin-stat.c.
#define CNTR_NOT_SUPPORTED "<not supported>" |
Definition at line 90 of file builtin-stat.c.
#define DEFAULT_SEPARATOR " " |
Definition at line 89 of file builtin-stat.c.
#define FD | ( | e, | |
x, | |||
y | |||
) | (*(int *)xyarray__entry(e->fd, x, y)) |
Definition at line 517 of file builtin-stat.c.
#define FREEZE_ON_SMI_PATH "devices/cpu/freeze_on_smi" |
Definition at line 92 of file builtin-stat.c.
#define METRIC_LEN 35 |
Definition at line 890 of file builtin-stat.c.
#define METRIC_ONLY_LEN 20 |
Definition at line 970 of file builtin-stat.c.
#define SID | ( | e, | |
x, | |||
y | |||
) | xyarray__entry(e->sample_id, x, y) |
Definition at line 330 of file builtin-stat.c.
#define STAT_RECORD perf_stat.record |
Definition at line 197 of file builtin-stat.c.
#define WRITE_STAT_ROUND_EVENT | ( | time, | |
interval | |||
) | write_stat_round_event(time, PERF_STAT_ROUND_TYPE__ ## interval) |
Definition at line 327 of file builtin-stat.c.
typedef int(* aggr_get_id_t) (struct cpu_map *m, int cpu) |
Definition at line 145 of file builtin-stat.c.
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
__weak bool arch_topdown_check_group | ( | bool * | warn | ) |
Definition at line 2310 of file builtin-stat.c.
__weak void arch_topdown_group_warn | ( | void | ) |
Definition at line 2316 of file builtin-stat.c.
int cmd_stat | ( | int | argc, |
const char ** | argv | ||
) |
|
static |
Definition at line 1447 of file builtin-stat.c.
|
static |
|
static |
|
static |
|
static |
|
static |
Definition at line 2092 of file builtin-stat.c.
|
static |
|
inlinestatic |
Definition at line 211 of file builtin-stat.c.
|
static |
|
static |
|
static |
|
static |
Definition at line 1989 of file builtin-stat.c.
|
static |
|
static |
|
static |
Definition at line 1777 of file builtin-stat.c.
|
static |
|
static |
Definition at line 206 of file builtin-stat.c.
|
static |
|
static |
|
static |
Definition at line 1040 of file builtin-stat.c.
|
static |
Definition at line 892 of file builtin-stat.c.
|
inlinestatic |
Definition at line 297 of file builtin-stat.c.
|
static |
|
static |
|
static |
Definition at line 2176 of file builtin-stat.c.
|
static |
|
static |
|
static |
Definition at line 548 of file builtin-stat.c.
|
static |
|
static |
|
static |
Definition at line 2106 of file builtin-stat.c.
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
Definition at line 805 of file builtin-stat.c.
|
static |
Definition at line 1785 of file builtin-stat.c.
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
Definition at line 1956 of file builtin-stat.c.
|
static |
Definition at line 1941 of file builtin-stat.c.
|
static |
|
static |
Definition at line 1982 of file builtin-stat.c.
|
static |
|
static |
Definition at line 1812 of file builtin-stat.c.
|
static |
|
static |
|
static |
Definition at line 974 of file builtin-stat.c.
|
static |
Definition at line 468 of file builtin-stat.c.
|
static |
|
static |
Definition at line 173 of file builtin-stat.c.
|
static |
Definition at line 1654 of file builtin-stat.c.
|
static |
Definition at line 1646 of file builtin-stat.c.
|
static |
Definition at line 172 of file builtin-stat.c.
|
static |
Definition at line 174 of file builtin-stat.c.
|
static |
Definition at line 156 of file builtin-stat.c.
|
static |
Definition at line 157 of file builtin-stat.c.
|
static |
Definition at line 149 of file builtin-stat.c.
|
static |
Definition at line 2104 of file builtin-stat.c.
|
static |
Definition at line 159 of file builtin-stat.c.
|
static |
Definition at line 158 of file builtin-stat.c.
|
static |
Definition at line 151 of file builtin-stat.c.
|
static |
Definition at line 199 of file builtin-stat.c.
|
static |
Definition at line 137 of file builtin-stat.c.
|
static |
Definition at line 168 of file builtin-stat.c.
|
static |
Definition at line 166 of file builtin-stat.c.
|
static |
Definition at line 160 of file builtin-stat.c.
|
static |
Definition at line 164 of file builtin-stat.c.
|
static |
Definition at line 175 of file builtin-stat.c.
|
static |
Definition at line 139 of file builtin-stat.c.
|
static |
Definition at line 167 of file builtin-stat.c.
|
static |
Definition at line 148 of file builtin-stat.c.
|
static |
Definition at line 169 of file builtin-stat.c.
|
static |
Definition at line 150 of file builtin-stat.c.
|
static |
Definition at line 177 of file builtin-stat.c.
|
static |
Definition at line 176 of file builtin-stat.c.
Definition at line 196 of file builtin-stat.c.
|
static |
Definition at line 162 of file builtin-stat.c.
|
static |
Definition at line 161 of file builtin-stat.c.
|
static |
Definition at line 178 of file builtin-stat.c.
|
static |
Definition at line 179 of file builtin-stat.c.
|
static |
Definition at line 171 of file builtin-stat.c.
|
static |
Definition at line 182 of file builtin-stat.c.
|
static |
Definition at line 181 of file builtin-stat.c.
|
static |
Definition at line 147 of file builtin-stat.c.
|
static |
Definition at line 1939 of file builtin-stat.c.
|
static |
Definition at line 154 of file builtin-stat.c.
|
static |
Definition at line 129 of file builtin-stat.c.
|
static |
Definition at line 155 of file builtin-stat.c.
|
static |
Definition at line 201 of file builtin-stat.c.
|
static |
Definition at line 2004 of file builtin-stat.c.
|
static |
Definition at line 2578 of file builtin-stat.c.
|
static |
Definition at line 2764 of file builtin-stat.c.
|
static |
Definition at line 163 of file builtin-stat.c.
Definition at line 141 of file builtin-stat.c.
|
static |
Definition at line 120 of file builtin-stat.c.
|
static |
Definition at line 153 of file builtin-stat.c.
|
static |
Definition at line 97 of file builtin-stat.c.
|
static |
Definition at line 110 of file builtin-stat.c.
|
static |
Definition at line 152 of file builtin-stat.c.
|
static |
Definition at line 165 of file builtin-stat.c.
|
static |
Definition at line 180 of file builtin-stat.c.
|
static |
Definition at line 170 of file builtin-stat.c.
|
static |
Definition at line 461 of file builtin-stat.c.