Linux Perf
builtin-stat.c File Reference
#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"
Include dependency graph for builtin-stat.c:

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_evselperf_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_valuesort_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_evlistevsel_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_mapaggr_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_mapcpus_aggr_map
 
static const char *const stat_record_usage []
 
static const char *const stat_report_usage []
 

Macro Definition Documentation

◆ CNTR_NOT_COUNTED

#define CNTR_NOT_COUNTED   "<not counted>"

Definition at line 91 of file builtin-stat.c.

◆ CNTR_NOT_SUPPORTED

#define CNTR_NOT_SUPPORTED   "<not supported>"

Definition at line 90 of file builtin-stat.c.

◆ DEFAULT_SEPARATOR

#define DEFAULT_SEPARATOR   " "

Definition at line 89 of file builtin-stat.c.

◆ FD

#define FD (   e,
  x,
 
)    (*(int *)xyarray__entry(e->fd, x, y))

Definition at line 517 of file builtin-stat.c.

◆ FREEZE_ON_SMI_PATH

#define FREEZE_ON_SMI_PATH   "devices/cpu/freeze_on_smi"

Definition at line 92 of file builtin-stat.c.

◆ METRIC_LEN

#define METRIC_LEN   35

Definition at line 890 of file builtin-stat.c.

◆ METRIC_ONLY_LEN

#define METRIC_ONLY_LEN   20

Definition at line 970 of file builtin-stat.c.

◆ SID

#define SID (   e,
  x,
 
)    xyarray__entry(e->sample_id, x, y)

Definition at line 330 of file builtin-stat.c.

◆ STAT_RECORD

#define STAT_RECORD   perf_stat.record

Definition at line 197 of file builtin-stat.c.

◆ WRITE_STAT_ROUND_EVENT

#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 Documentation

◆ aggr_get_id_t

typedef int(* aggr_get_id_t) (struct cpu_map *m, int cpu)

Definition at line 145 of file builtin-stat.c.

Function Documentation

◆ __cmd_record()

static int __cmd_record ( int  argc,
const char **  argv 
)
static

Definition at line 2596 of file builtin-stat.c.

Here is the call graph for this function:

◆ __cmd_report()

static int __cmd_report ( int  argc,
const char **  argv 
)
static

Definition at line 2782 of file builtin-stat.c.

Here is the call graph for this function:

◆ __run_perf_stat()

static int __run_perf_stat ( int  argc,
const char **  argv,
int  run_idx 
)
static

Definition at line 579 of file builtin-stat.c.

Here is the call graph for this function:

◆ __store_counter_ids()

static int __store_counter_ids ( struct perf_evsel counter)
static

Definition at line 519 of file builtin-stat.c.

Here is the call graph for this function:

◆ abs_printout()

static void abs_printout ( int  id,
int  nr,
struct perf_evsel evsel,
double  avg 
)
static

Definition at line 1110 of file builtin-stat.c.

Here is the call graph for this function:

◆ add_default_attributes()

static int add_default_attributes ( void  )
static

Definition at line 2324 of file builtin-stat.c.

Here is the call graph for this function:

◆ aggr_cb()

static void aggr_cb ( struct perf_evsel counter,
void *  data,
bool  first 
)
static

Definition at line 1362 of file builtin-stat.c.

Here is the call graph for this function:

◆ aggr_printout()

static void aggr_printout ( struct perf_evsel evsel,
int  id,
int  nr 
)
static

Definition at line 839 of file builtin-stat.c.

Here is the call graph for this function:

◆ aggr_update_shadow()

static void aggr_update_shadow ( void  )
static

Definition at line 1269 of file builtin-stat.c.

Here is the call graph for this function:

◆ arch_topdown_check_group()

__weak bool arch_topdown_check_group ( bool *  warn)

Definition at line 2310 of file builtin-stat.c.

◆ arch_topdown_group_warn()

__weak void arch_topdown_group_warn ( void  )

Definition at line 2316 of file builtin-stat.c.

◆ cmd_stat()

int cmd_stat ( int  argc,
const char **  argv 
)

Definition at line 2855 of file builtin-stat.c.

Here is the call graph for this function:

◆ cmp_val()

static int cmp_val ( const void *  a,
const void *  b 
)
static

Definition at line 1447 of file builtin-stat.c.

◆ collect_all_aliases()

static void collect_all_aliases ( struct perf_evsel counter,
void(*)(struct perf_evsel *counter, void *data, bool first)  cb,
void *  data 
)
static

Definition at line 1320 of file builtin-stat.c.

Here is the call graph for this function:

◆ collect_data()

static bool collect_data ( struct perf_evsel counter,
void(*)(struct perf_evsel *counter, void *data, bool first)  cb,
void *  data 
)
static

Definition at line 1340 of file builtin-stat.c.

Here is the call graph for this function:

◆ counter_aggr_cb()

static void counter_aggr_cb ( struct perf_evsel counter,
void *  data,
bool first  __maybe_unused 
)
static

Definition at line 1538 of file builtin-stat.c.

Here is the call graph for this function:

◆ counter_cb()

static void counter_cb ( struct perf_evsel counter,
void *  data,
bool first  __maybe_unused 
)
static

Definition at line 1572 of file builtin-stat.c.

Here is the call graph for this function:

◆ cpu_map__get_max()

static int cpu_map__get_max ( struct cpu_map map)
static

Definition at line 2092 of file builtin-stat.c.

◆ create_perf_stat_counter()

static int create_perf_stat_counter ( struct perf_evsel evsel)
static

Definition at line 234 of file builtin-stat.c.

Here is the call graph for this function:

◆ diff_timespec()

static void diff_timespec ( struct timespec *  r,
struct timespec *  a,
struct timespec *  b 
)
inlinestatic

Definition at line 211 of file builtin-stat.c.

◆ disable_counters()

static void disable_counters ( void  )
static

Definition at line 450 of file builtin-stat.c.

Here is the call graph for this function:

◆ do_new_line_std()

static void do_new_line_std ( struct outstate os)
static

Definition at line 899 of file builtin-stat.c.

Here is the call graph for this function:

◆ enable_counters()

static void enable_counters ( void  )
static

Definition at line 436 of file builtin-stat.c.

Here is the call graph for this function:

◆ enable_metric_only()

static int enable_metric_only ( const struct option *opt  __maybe_unused,
const char *s  __maybe_unused,
int  unset 
)
static

Definition at line 1989 of file builtin-stat.c.

◆ first_shadow_cpu()

static int first_shadow_cpu ( struct perf_evsel evsel,
int  id 
)
static

Definition at line 1088 of file builtin-stat.c.

Here is the call graph for this function:

◆ fixunit()

static const char* fixunit ( char *  buf,
struct perf_evsel evsel,
const char *  unit 
)
static

Definition at line 986 of file builtin-stat.c.

Here is the call graph for this function:

◆ get_precision()

static int get_precision ( double  num)
static

Definition at line 1777 of file builtin-stat.c.

◆ init_features()

static void init_features ( struct perf_session session)
static

Definition at line 2583 of file builtin-stat.c.

Here is the call graph for this function:

◆ is_duration_time()

static bool is_duration_time ( struct perf_evsel evsel)
static

Definition at line 206 of file builtin-stat.c.

◆ is_mixed_hw_group()

static bool is_mixed_hw_group ( struct perf_evsel counter)
static

Definition at line 1140 of file builtin-stat.c.

Here is the call graph for this function:

◆ new_line_csv()

static void new_line_csv ( void *  ctx)
static

Definition at line 935 of file builtin-stat.c.

Here is the call graph for this function:

◆ new_line_metric()

static void new_line_metric ( void *ctx  __maybe_unused)
static

Definition at line 1040 of file builtin-stat.c.

◆ new_line_std()

static void new_line_std ( void *  ctx)
static

Definition at line 892 of file builtin-stat.c.

◆ nsec_counter()

static int nsec_counter ( struct perf_evsel evsel)
inlinestatic

Definition at line 297 of file builtin-stat.c.

◆ nsec_printout()

static void nsec_printout ( int  id,
int  nr,
struct perf_evsel evsel,
double  avg 
)
static

Definition at line 1060 of file builtin-stat.c.

Here is the call graph for this function:

◆ parse_metric_groups()

static int parse_metric_groups ( const struct option *  opt,
const char *  str,
int unset  __maybe_unused 
)
static

Definition at line 1997 of file builtin-stat.c.

Here is the call graph for this function:

◆ perf_env__build_core_map()

static int perf_env__build_core_map ( struct perf_env env,
struct cpu_map cpus,
struct cpu_map **  corep 
)
static

Definition at line 2225 of file builtin-stat.c.

Here is the call graph for this function:

◆ perf_env__build_socket_map()

static int perf_env__build_socket_map ( struct perf_env env,
struct cpu_map cpus,
struct cpu_map **  sockp 
)
static

Definition at line 2219 of file builtin-stat.c.

Here is the call graph for this function:

◆ perf_env__get_core()

static int perf_env__get_core ( struct cpu_map map,
int  idx,
void *  data 
)
static

Definition at line 2199 of file builtin-stat.c.

Here is the call graph for this function:

◆ perf_env__get_cpu()

static int perf_env__get_cpu ( struct perf_env env,
struct cpu_map map,
int  idx 
)
inlinestatic

Definition at line 2176 of file builtin-stat.c.

◆ perf_env__get_socket()

static int perf_env__get_socket ( struct cpu_map map,
int  idx,
void *  data 
)
static

Definition at line 2191 of file builtin-stat.c.

Here is the call graph for this function:

◆ perf_evsel__reset_weak_group()

static struct perf_evsel* perf_evsel__reset_weak_group ( struct perf_evsel evsel)
static

Definition at line 553 of file builtin-stat.c.

Here is the call graph for this function:

◆ perf_evsel__should_store_id()

static bool perf_evsel__should_store_id ( struct perf_evsel counter)
static

Definition at line 548 of file builtin-stat.c.

◆ perf_evsel__write_stat_event()

static int perf_evsel__write_stat_event ( struct perf_evsel counter,
u32  cpu,
u32  thread,
struct perf_counts_values count 
)
static

Definition at line 333 of file builtin-stat.c.

Here is the call graph for this function:

◆ perf_stat__exit_aggr_mode()

static void perf_stat__exit_aggr_mode ( void  )
static

Definition at line 2168 of file builtin-stat.c.

Here is the call graph for this function:

◆ perf_stat__get_aggr()

static int perf_stat__get_aggr ( aggr_get_id_t  get_id,
struct cpu_map map,
int  idx 
)
static

Definition at line 2106 of file builtin-stat.c.

◆ perf_stat__get_core()

static int perf_stat__get_core ( struct cpu_map map,
int  cpu 
)
static

Definition at line 2087 of file builtin-stat.c.

Here is the call graph for this function:

◆ perf_stat__get_core_cached()

static int perf_stat__get_core_cached ( struct cpu_map map,
int  idx 
)
static

Definition at line 2126 of file builtin-stat.c.

Here is the call graph for this function:

◆ perf_stat__get_core_file()

static int perf_stat__get_core_file ( struct cpu_map map,
int  idx 
)
static

Definition at line 2236 of file builtin-stat.c.

Here is the call graph for this function:

◆ perf_stat__get_socket()

static int perf_stat__get_socket ( struct cpu_map map,
int  cpu 
)
static

Definition at line 2082 of file builtin-stat.c.

Here is the call graph for this function:

◆ perf_stat__get_socket_cached()

static int perf_stat__get_socket_cached ( struct cpu_map map,
int  idx 
)
static

Definition at line 2121 of file builtin-stat.c.

Here is the call graph for this function:

◆ perf_stat__get_socket_file()

static int perf_stat__get_socket_file ( struct cpu_map map,
int  idx 
)
static

Definition at line 2231 of file builtin-stat.c.

Here is the call graph for this function:

◆ perf_stat__reset_stats()

static void perf_stat__reset_stats ( void  )
static

Definition at line 223 of file builtin-stat.c.

Here is the call graph for this function:

◆ perf_stat_init_aggr_mode()

static int perf_stat_init_aggr_mode ( void  )
static

Definition at line 2131 of file builtin-stat.c.

Here is the call graph for this function:

◆ perf_stat_init_aggr_mode_file()

static int perf_stat_init_aggr_mode_file ( struct perf_stat st)
static

Definition at line 2241 of file builtin-stat.c.

Here is the call graph for this function:

◆ perf_stat_synthesize_config()

static int perf_stat_synthesize_config ( bool  is_pipe)
static

Definition at line 474 of file builtin-stat.c.

Here is the call graph for this function:

◆ print_aggr()

static void print_aggr ( char *  prefix)
static

Definition at line 1392 of file builtin-stat.c.

Here is the call graph for this function:

◆ print_aggr_thread()

static void print_aggr_thread ( struct perf_evsel counter,
char *  prefix 
)
static

Definition at line 1501 of file builtin-stat.c.

Here is the call graph for this function:

◆ print_counter()

static void print_counter ( struct perf_evsel counter,
char *  prefix 
)
static

Definition at line 1586 of file builtin-stat.c.

Here is the call graph for this function:

◆ print_counter_aggr()

static void print_counter_aggr ( struct perf_evsel counter,
char *  prefix 
)
static

Definition at line 1553 of file builtin-stat.c.

Here is the call graph for this function:

◆ print_counters()

static void print_counters ( struct timespec *  ts,
int  argc,
const char **  argv 
)
static

Definition at line 1870 of file builtin-stat.c.

Here is the call graph for this function:

◆ print_footer()

static void print_footer ( void  )
static

Definition at line 1817 of file builtin-stat.c.

Here is the call graph for this function:

◆ print_header()

static void print_header ( int  argc,
const char **  argv 
)
static

Definition at line 1747 of file builtin-stat.c.

Here is the call graph for this function:

◆ print_interval()

static void print_interval ( char *  prefix,
struct timespec *  ts 
)
static

Definition at line 1702 of file builtin-stat.c.

Here is the call graph for this function:

◆ print_metric_csv()

static void print_metric_csv ( void *  ctx,
const char *color  __maybe_unused,
const char *  fmt,
const char *  unit,
double  val 
)
static

Definition at line 948 of file builtin-stat.c.

Here is the call graph for this function:

◆ print_metric_header()

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

Definition at line 1044 of file builtin-stat.c.

Here is the call graph for this function:

◆ print_metric_headers()

static void print_metric_headers ( const char *  prefix,
bool  no_indent 
)
static

Definition at line 1662 of file builtin-stat.c.

Here is the call graph for this function:

◆ print_metric_only()

static void print_metric_only ( void *  ctx,
const char *  color,
const char *  fmt,
const char *  unit,
double  val 
)
static

Definition at line 997 of file builtin-stat.c.

Here is the call graph for this function:

◆ print_metric_only_csv()

static void print_metric_only_csv ( void *  ctx,
const char *color  __maybe_unused,
const char *  fmt,
const char *  unit,
double  val 
)
static

Definition at line 1020 of file builtin-stat.c.

Here is the call graph for this function:

◆ print_metric_std()

static void print_metric_std ( void *  ctx,
const char *  color,
const char *  fmt,
const char *  unit,
double  val 
)
static

Definition at line 909 of file builtin-stat.c.

Here is the call graph for this function:

◆ print_no_aggr_metric()

static void print_no_aggr_metric ( char *  prefix)
static

Definition at line 1613 of file builtin-stat.c.

Here is the call graph for this function:

◆ print_noise()

static void print_noise ( struct perf_evsel evsel,
double  avg 
)
static

Definition at line 828 of file builtin-stat.c.

Here is the call graph for this function:

◆ print_noise_pct()

static void print_noise_pct ( double  total,
double  avg 
)
static

Definition at line 818 of file builtin-stat.c.

Here is the call graph for this function:

◆ print_running()

static void print_running ( u64  run,
u64  ena 
)
static

Definition at line 805 of file builtin-stat.c.

◆ print_table()

static void print_table ( FILE *  output,
int  precision,
double  avg 
)
static

Definition at line 1785 of file builtin-stat.c.

◆ printout()

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

Definition at line 1164 of file builtin-stat.c.

Here is the call graph for this function:

◆ process_cpu_map_event()

static int process_cpu_map_event ( struct perf_tool tool,
union perf_event event,
struct perf_session *session  __maybe_unused 
)
static

Definition at line 2715 of file builtin-stat.c.

Here is the call graph for this function:

◆ process_interval()

static void process_interval ( void  )
static

Definition at line 417 of file builtin-stat.c.

Here is the call graph for this function:

◆ process_stat_config_event()

static int process_stat_config_event ( struct perf_tool tool,
union perf_event event,
struct perf_session *session  __maybe_unused 
)
static

Definition at line 2653 of file builtin-stat.c.

Here is the call graph for this function:

◆ process_stat_round_event()

static int process_stat_round_event ( struct perf_tool *tool  __maybe_unused,
union perf_event event,
struct perf_session session 
)
static

Definition at line 2626 of file builtin-stat.c.

Here is the call graph for this function:

◆ process_synthesized_event()

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

Definition at line 306 of file builtin-stat.c.

Here is the call graph for this function:

◆ process_thread_map_event()

static int process_thread_map_event ( struct perf_tool tool,
union perf_event event,
struct perf_session *session  __maybe_unused 
)
static

Definition at line 2696 of file builtin-stat.c.

Here is the call graph for this function:

◆ read_counter()

static int read_counter ( struct perf_evsel counter)
static

Definition at line 346 of file builtin-stat.c.

Here is the call graph for this function:

◆ read_counters()

static void read_counters ( void  )
static

Definition at line 402 of file builtin-stat.c.

Here is the call graph for this function:

◆ run_perf_stat()

static int run_perf_stat ( int  argc,
const char **  argv,
int  run_idx 
)
static

Definition at line 779 of file builtin-stat.c.

Here is the call graph for this function:

◆ runtime_stat_delete()

static void runtime_stat_delete ( struct perf_stat_config config)
static

Definition at line 2751 of file builtin-stat.c.

Here is the call graph for this function:

◆ runtime_stat_new()

static int runtime_stat_new ( struct perf_stat_config config,
int  nthreads 
)
static

Definition at line 2735 of file builtin-stat.c.

Here is the call graph for this function:

◆ set_maps()

static int set_maps ( struct perf_stat st)
static

Definition at line 2678 of file builtin-stat.c.

Here is the call graph for this function:

◆ setup_system_wide()

static void setup_system_wide ( int  forks)
static

Definition at line 2826 of file builtin-stat.c.

Here is the call graph for this function:

◆ sig_atexit()

static void sig_atexit ( void  )
static

Definition at line 1956 of file builtin-stat.c.

◆ skip_signal()

static void skip_signal ( int  signo)
static

Definition at line 1941 of file builtin-stat.c.

◆ sort_aggr_thread()

static struct perf_aggr_thread_value* sort_aggr_thread ( struct perf_evsel counter,
int  nthreads,
int  ncpus,
int *  ret 
)
static

Definition at line 1453 of file builtin-stat.c.

Here is the call graph for this function:

◆ stat__set_big_num()

static int stat__set_big_num ( const struct option *opt  __maybe_unused,
const char *s  __maybe_unused,
int  unset 
)
static

Definition at line 1982 of file builtin-stat.c.

◆ store_counter_ids()

static int store_counter_ids ( struct perf_evsel counter)
static

Definition at line 537 of file builtin-stat.c.

Here is the call graph for this function:

◆ timeval2double()

static double timeval2double ( struct timeval *  t)
static

Definition at line 1812 of file builtin-stat.c.

◆ topdown_filter_events()

static int topdown_filter_events ( const char **  attr,
char **  str,
bool  use_group 
)
static

Definition at line 2271 of file builtin-stat.c.

Here is the call graph for this function:

◆ uniquify_event_name()

static void uniquify_event_name ( struct perf_evsel counter)
static

Definition at line 1292 of file builtin-stat.c.

Here is the call graph for this function:

◆ valid_only_metric()

static bool valid_only_metric ( const char *  unit)
static

Definition at line 974 of file builtin-stat.c.

◆ workload_exec_failed_signal()

static void workload_exec_failed_signal ( int signo  __maybe_unused,
siginfo_t *  info,
void *ucontext  __maybe_unused 
)
static

Definition at line 468 of file builtin-stat.c.

◆ write_stat_round_event()

static int write_stat_round_event ( u64  tm,
u64  type 
)
static

Definition at line 320 of file builtin-stat.c.

Here is the call graph for this function:

Variable Documentation

◆ aggr_get_id

aggr_get_id_t aggr_get_id
static

Definition at line 173 of file builtin-stat.c.

◆ aggr_header_csv

const char* aggr_header_csv[]
static
Initial value:
= {
[AGGR_CORE] = "core,cpus,",
[AGGR_SOCKET] = "socket,cpus",
[AGGR_NONE] = "cpu,",
[AGGR_THREAD] = "comm-pid,",
[AGGR_GLOBAL] = ""
}
Definition: stat.h:41
Definition: stat.h:38

Definition at line 1654 of file builtin-stat.c.

◆ aggr_header_lens

int aggr_header_lens[]
static
Initial value:
= {
[AGGR_CORE] = 18,
[AGGR_SOCKET] = 12,
[AGGR_NONE] = 6,
[AGGR_THREAD] = 24,
[AGGR_GLOBAL] = 0,
}
Definition: stat.h:41
Definition: stat.h:38

Definition at line 1646 of file builtin-stat.c.

◆ aggr_map

struct cpu_map* aggr_map
static

Definition at line 172 of file builtin-stat.c.

◆ append_file

bool append_file
static

Definition at line 174 of file builtin-stat.c.

◆ big_num

bool big_num = true
static

Definition at line 156 of file builtin-stat.c.

◆ big_num_opt

int big_num_opt = -1
static

Definition at line 157 of file builtin-stat.c.

◆ child_pid

volatile pid_t child_pid = -1
static

Definition at line 149 of file builtin-stat.c.

◆ cpus_aggr_map

struct cpu_map* cpus_aggr_map
static

Definition at line 2104 of file builtin-stat.c.

◆ csv_output

bool csv_output = false
static

Definition at line 159 of file builtin-stat.c.

◆ csv_sep

const char* csv_sep = NULL
static

Definition at line 158 of file builtin-stat.c.

◆ detailed_run

int detailed_run = 0
static

Definition at line 151 of file builtin-stat.c.

◆ done

volatile int done = 0
static

Definition at line 199 of file builtin-stat.c.

◆ evsel_list

struct perf_evlist* evsel_list
static

Definition at line 137 of file builtin-stat.c.

◆ force_metric_only

bool force_metric_only = false
static

Definition at line 168 of file builtin-stat.c.

◆ forever

bool forever = false
static

Definition at line 166 of file builtin-stat.c.

◆ group

bool group = false
static

Definition at line 160 of file builtin-stat.c.

◆ initial_delay

unsigned int initial_delay = 0
static

Definition at line 164 of file builtin-stat.c.

◆ interval_count

bool interval_count
static

Definition at line 175 of file builtin-stat.c.

◆ metric_events

struct rblist metric_events
static

Definition at line 139 of file builtin-stat.c.

◆ metric_only

bool metric_only = false
static

Definition at line 167 of file builtin-stat.c.

◆ no_inherit

bool no_inherit = false
static

Definition at line 148 of file builtin-stat.c.

◆ no_merge

bool no_merge = false
static

Definition at line 169 of file builtin-stat.c.

◆ null_run

bool null_run = false
static

Definition at line 150 of file builtin-stat.c.

◆ output_fd

int output_fd
static

Definition at line 177 of file builtin-stat.c.

◆ output_name

const char* output_name
static

Definition at line 176 of file builtin-stat.c.

◆ perf_stat

static struct perf_stat perf_stat
static
Initial value:
= {
.tool = {
.thread_map = process_thread_map_event,
.stat_config = process_stat_config_event,
.stat_round = process_stat_round_event,
},
.aggr_mode = AGGR_UNSET,
}
int perf_event__process_attr(struct perf_tool *tool __maybe_unused, union perf_event *event, struct perf_evlist **pevlist)
Definition: header.c:3721
static int process_stat_config_event(struct perf_tool *tool, union perf_event *event, struct perf_session *session __maybe_unused)
int perf_event__process_event_update(struct perf_tool *tool __maybe_unused, union perf_event *event, struct perf_evlist **pevlist)
Definition: header.c:3759
static int process_stat_round_event(struct perf_tool *tool __maybe_unused, union perf_event *event, struct perf_session *session)
static int process_cpu_map_event(struct perf_tool *tool, union perf_event *event, struct perf_session *session __maybe_unused)
int perf_event__process_stat_event(struct perf_tool *tool __maybe_unused, union perf_event *event, struct perf_session *session)
Definition: stat.c:377
static int process_thread_map_event(struct perf_tool *tool, union perf_event *event, struct perf_session *session __maybe_unused)

Definition at line 196 of file builtin-stat.c.

◆ post_cmd

const char* post_cmd = NULL
static

Definition at line 162 of file builtin-stat.c.

◆ pre_cmd

const char* pre_cmd = NULL
static

Definition at line 161 of file builtin-stat.c.

◆ print_free_counters_hint

int print_free_counters_hint
static

Definition at line 178 of file builtin-stat.c.

◆ print_mixed_hw_group_error

int print_mixed_hw_group_error
static

Definition at line 179 of file builtin-stat.c.

◆ ref_time

struct timespec ref_time
static

Definition at line 171 of file builtin-stat.c.

◆ ru_data

struct rusage ru_data
static

Definition at line 182 of file builtin-stat.c.

◆ ru_display

bool ru_display = false
static

Definition at line 181 of file builtin-stat.c.

◆ run_count

int run_count = 1
static

Definition at line 147 of file builtin-stat.c.

◆ signr

volatile int signr = -1
static

Definition at line 1939 of file builtin-stat.c.

◆ smi_cost

bool smi_cost = false
static

Definition at line 154 of file builtin-stat.c.

◆ smi_cost_attrs

const char* smi_cost_attrs
static
Initial value:
= {
"{"
"msr/aperf/,"
"msr/smi/,"
"cycles"
"}"
}

Definition at line 129 of file builtin-stat.c.

◆ smi_reset

bool smi_reset = false
static

Definition at line 155 of file builtin-stat.c.

◆ stat_config

struct perf_stat_config stat_config
static
Initial value:
= {
.aggr_mode = AGGR_GLOBAL,
.scale = true,
}

Definition at line 201 of file builtin-stat.c.

◆ stat_options

const struct option stat_options[]
static

Definition at line 2004 of file builtin-stat.c.

◆ stat_record_usage

const char* const stat_record_usage[]
static
Initial value:
= {
"perf stat record [<options>]",
NULL,
}

Definition at line 2578 of file builtin-stat.c.

◆ stat_report_usage

const char* const stat_report_usage[]
static
Initial value:
= {
"perf stat report [<options>]",
NULL,
}

Definition at line 2764 of file builtin-stat.c.

◆ sync_run

bool sync_run = false
static

Definition at line 163 of file builtin-stat.c.

◆ target

struct target target
static
Initial value:
= {
.uid = UINT_MAX,
}

Definition at line 141 of file builtin-stat.c.

◆ topdown_attrs

const char* topdown_attrs[]
static
Initial value:
= {
"topdown-total-slots",
"topdown-slots-retired",
"topdown-recovery-bubbles",
"topdown-fetch-bubbles",
"topdown-slots-issued",
NULL,
}

Definition at line 120 of file builtin-stat.c.

◆ topdown_run

bool topdown_run = false
static

Definition at line 153 of file builtin-stat.c.

◆ transaction_attrs

const char* transaction_attrs
static
Initial value:
= {
"task-clock,"
"{"
"instructions,"
"cycles,"
"cpu/cycles-t/,"
"cpu/tx-start/,"
"cpu/el-start/,"
"cpu/cycles-ct/"
"}"
}

Definition at line 97 of file builtin-stat.c.

◆ transaction_limited_attrs

const char* transaction_limited_attrs
static
Initial value:
= {
"task-clock,"
"{"
"instructions,"
"cycles,"
"cpu/cycles-t/,"
"cpu/tx-start/"
"}"
}

Definition at line 110 of file builtin-stat.c.

◆ transaction_run

bool transaction_run
static

Definition at line 152 of file builtin-stat.c.

◆ unit_width

unsigned int unit_width = 4
static

Definition at line 165 of file builtin-stat.c.

◆ walltime_run

u64* walltime_run
static

Definition at line 180 of file builtin-stat.c.

◆ walltime_run_table

bool walltime_run_table = false
static

Definition at line 170 of file builtin-stat.c.

◆ workload_exec_errno

volatile int workload_exec_errno
static

Definition at line 461 of file builtin-stat.c.