Linux Perf
|
#include <byteswap.h>
#include <errno.h>
#include <inttypes.h>
#include <linux/bitops.h>
#include <api/fs/fs.h>
#include <api/fs/tracing_path.h>
#include <traceevent/event-parse.h>
#include <linux/hw_breakpoint.h>
#include <linux/perf_event.h>
#include <linux/compiler.h>
#include <linux/err.h>
#include <sys/ioctl.h>
#include <sys/resource.h>
#include <sys/types.h>
#include <dirent.h>
#include "asm/bug.h"
#include "callchain.h"
#include "cgroup.h"
#include "event.h"
#include "evsel.h"
#include "evlist.h"
#include "util.h"
#include "cpumap.h"
#include "thread_map.h"
#include "target.h"
#include "perf_regs.h"
#include "debug.h"
#include "trace-event.h"
#include "stat.h"
#include "memswap.h"
#include "util/parse-branch-options.h"
#include "sane_ctype.h"
Go to the source code of this file.
Classes | |
struct | bit_names |
Macros | |
#define | FD(e, x, y) (*(int *)xyarray__entry(e->fd, x, y)) |
#define | FUNCTION_EVENT "ftrace:function" |
#define | MOD_PRINT(context, mod) |
#define | C(x) PERF_COUNT_HW_CACHE_##x |
#define | CACHE_READ (1 << C(OP_READ)) |
#define | CACHE_WRITE (1 << C(OP_WRITE)) |
#define | CACHE_PREFETCH (1 << C(OP_PREFETCH)) |
#define | COP(x) (1 << x) |
#define | bit_name(n) { PERF_SAMPLE_##n, #n } |
#define | bit_name(n) { PERF_SAMPLE_BRANCH_##n, #n } |
#define | bit_name(n) { PERF_FORMAT_##n, #n } |
#define | BUF_SIZE 1024 |
#define | p_hex(val) snprintf(buf, BUF_SIZE, "%#"PRIx64, (uint64_t)(val)) |
#define | p_unsigned(val) snprintf(buf, BUF_SIZE, "%"PRIu64, (uint64_t)(val)) |
#define | p_signed(val) snprintf(buf, BUF_SIZE, "%"PRId64, (int64_t)(val)) |
#define | p_sample_type(val) __p_sample_type(buf, BUF_SIZE, val) |
#define | p_branch_sample_type(val) __p_branch_sample_type(buf, BUF_SIZE, val) |
#define | p_read_format(val) __p_read_format(buf, BUF_SIZE, val) |
#define | PRINT_ATTRn(_n, _f, _p) |
#define | PRINT_ATTRf(_f, _p) PRINT_ATTRn(#_f, _f, _p) |
#define | OVERFLOW_CHECK(offset, size, max_size) |
#define | OVERFLOW_CHECK_u64(offset) OVERFLOW_CHECK(offset, sizeof(u64), sizeof(u64)) |
Functions | |
static int | perf_evsel__no_extra_init (struct perf_evsel *evsel __maybe_unused) |
void __weak | test_attr__ready (void) |
static void | perf_evsel__no_extra_fini (struct perf_evsel *evsel __maybe_unused) |
int | perf_evsel__object_config (size_t object_size, int(*init)(struct perf_evsel *evsel), void(*fini)(struct perf_evsel *evsel)) |
int | __perf_evsel__sample_size (u64 sample_type) |
static int | __perf_evsel__calc_id_pos (u64 sample_type) |
static int | __perf_evsel__calc_is_pos (u64 sample_type) |
void | perf_evsel__calc_id_pos (struct perf_evsel *evsel) |
void | __perf_evsel__set_sample_bit (struct perf_evsel *evsel, enum perf_event_sample_format bit) |
void | __perf_evsel__reset_sample_bit (struct perf_evsel *evsel, enum perf_event_sample_format bit) |
void | perf_evsel__set_sample_id (struct perf_evsel *evsel, bool can_sample_identifier) |
bool | perf_evsel__is_function_event (struct perf_evsel *evsel) |
void | perf_evsel__init (struct perf_evsel *evsel, struct perf_event_attr *attr, int idx) |
struct perf_evsel * | perf_evsel__new_idx (struct perf_event_attr *attr, int idx) |
static bool | perf_event_can_profile_kernel (void) |
struct perf_evsel * | perf_evsel__new_cycles (bool precise) |
struct perf_evsel * | perf_evsel__newtp_idx (const char *sys, const char *name, int idx) |
static const char * | __perf_evsel__hw_name (u64 config) |
static int | perf_evsel__add_modifiers (struct perf_evsel *evsel, char *bf, size_t size) |
static int | perf_evsel__hw_name (struct perf_evsel *evsel, char *bf, size_t size) |
static const char * | __perf_evsel__sw_name (u64 config) |
static int | perf_evsel__sw_name (struct perf_evsel *evsel, char *bf, size_t size) |
static int | __perf_evsel__bp_name (char *bf, size_t size, u64 addr, u64 type) |
static int | perf_evsel__bp_name (struct perf_evsel *evsel, char *bf, size_t size) |
bool | perf_evsel__is_cache_op_valid (u8 type, u8 op) |
int | __perf_evsel__hw_cache_type_op_res_name (u8 type, u8 op, u8 result, char *bf, size_t size) |
static int | __perf_evsel__hw_cache_name (u64 config, char *bf, size_t size) |
static int | perf_evsel__hw_cache_name (struct perf_evsel *evsel, char *bf, size_t size) |
static int | perf_evsel__raw_name (struct perf_evsel *evsel, char *bf, size_t size) |
const char * | perf_evsel__name (struct perf_evsel *evsel) |
const char * | perf_evsel__group_name (struct perf_evsel *evsel) |
int | perf_evsel__group_desc (struct perf_evsel *evsel, char *buf, size_t size) |
static void | __perf_evsel__config_callchain (struct perf_evsel *evsel, struct record_opts *opts, struct callchain_param *param) |
void | perf_evsel__config_callchain (struct perf_evsel *evsel, struct record_opts *opts, struct callchain_param *param) |
static void | perf_evsel__reset_callgraph (struct perf_evsel *evsel, struct callchain_param *param) |
static void | apply_config_terms (struct perf_evsel *evsel, struct record_opts *opts, bool track) |
void | perf_evsel__config (struct perf_evsel *evsel, struct record_opts *opts, struct callchain_param *callchain) |
static int | perf_evsel__alloc_fd (struct perf_evsel *evsel, int ncpus, int nthreads) |
static int | perf_evsel__run_ioctl (struct perf_evsel *evsel, int ioc, void *arg) |
int | perf_evsel__apply_filter (struct perf_evsel *evsel, const char *filter) |
int | perf_evsel__set_filter (struct perf_evsel *evsel, const char *filter) |
static int | perf_evsel__append_filter (struct perf_evsel *evsel, const char *fmt, const char *filter) |
int | perf_evsel__append_tp_filter (struct perf_evsel *evsel, const char *filter) |
int | perf_evsel__append_addr_filter (struct perf_evsel *evsel, const char *filter) |
int | perf_evsel__enable (struct perf_evsel *evsel) |
int | perf_evsel__disable (struct perf_evsel *evsel) |
int | perf_evsel__alloc_id (struct perf_evsel *evsel, int ncpus, int nthreads) |
static void | perf_evsel__free_fd (struct perf_evsel *evsel) |
static void | perf_evsel__free_id (struct perf_evsel *evsel) |
static void | perf_evsel__free_config_terms (struct perf_evsel *evsel) |
void | perf_evsel__close_fd (struct perf_evsel *evsel) |
void | perf_evsel__exit (struct perf_evsel *evsel) |
void | perf_evsel__delete (struct perf_evsel *evsel) |
void | perf_evsel__compute_deltas (struct perf_evsel *evsel, int cpu, int thread, struct perf_counts_values *count) |
void | perf_counts_values__scale (struct perf_counts_values *count, bool scale, s8 *pscaled) |
static int | perf_evsel__read_size (struct perf_evsel *evsel) |
int | perf_evsel__read (struct perf_evsel *evsel, int cpu, int thread, struct perf_counts_values *count) |
static int | perf_evsel__read_one (struct perf_evsel *evsel, int cpu, int thread) |
static void | perf_evsel__set_count (struct perf_evsel *counter, int cpu, int thread, u64 val, u64 ena, u64 run) |
static int | perf_evsel__process_group_data (struct perf_evsel *leader, int cpu, int thread, u64 *data) |
static int | perf_evsel__read_group (struct perf_evsel *leader, int cpu, int thread) |
int | perf_evsel__read_counter (struct perf_evsel *evsel, int cpu, int thread) |
int | __perf_evsel__read_on_cpu (struct perf_evsel *evsel, int cpu, int thread, bool scale) |
static int | get_group_fd (struct perf_evsel *evsel, int cpu, int thread) |
static void | __p_bits (char *buf, size_t size, u64 value, struct bit_names *bits) |
static void | __p_sample_type (char *buf, size_t size, u64 value) |
static void | __p_branch_sample_type (char *buf, size_t size, u64 value) |
static void | __p_read_format (char *buf, size_t size, u64 value) |
int | perf_event_attr__fprintf (FILE *fp, struct perf_event_attr *attr, attr__fprintf_f attr__fprintf, void *priv) |
static int | __open_attr__fprintf (FILE *fp, const char *name, const char *val, void *priv __maybe_unused) |
static void | perf_evsel__remove_fd (struct perf_evsel *pos, int nr_cpus, int nr_threads, int thread_idx) |
static int | update_fds (struct perf_evsel *evsel, int nr_cpus, int cpu_idx, int nr_threads, int thread_idx) |
static bool | ignore_missing_thread (struct perf_evsel *evsel, int nr_cpus, int cpu, struct thread_map *threads, int thread, int err) |
int | perf_evsel__open (struct perf_evsel *evsel, struct cpu_map *cpus, struct thread_map *threads) |
void | perf_evsel__close (struct perf_evsel *evsel) |
int | perf_evsel__open_per_cpu (struct perf_evsel *evsel, struct cpu_map *cpus) |
int | perf_evsel__open_per_thread (struct perf_evsel *evsel, struct thread_map *threads) |
static int | perf_evsel__parse_id_sample (const struct perf_evsel *evsel, const union perf_event *event, struct perf_sample *sample) |
static bool | overflow (const void *endp, u16 max_size, const void *offset, u64 size) |
static int | perf_event__check_size (union perf_event *event, unsigned int sample_size) |
int | perf_evsel__parse_sample (struct perf_evsel *evsel, union perf_event *event, struct perf_sample *data) |
int | perf_evsel__parse_sample_timestamp (struct perf_evsel *evsel, union perf_event *event, u64 *timestamp) |
size_t | perf_event__sample_event_size (const struct perf_sample *sample, u64 type, u64 read_format) |
int | perf_event__synthesize_sample (union perf_event *event, u64 type, u64 read_format, const struct perf_sample *sample) |
struct format_field * | perf_evsel__field (struct perf_evsel *evsel, const char *name) |
void * | perf_evsel__rawptr (struct perf_evsel *evsel, struct perf_sample *sample, const char *name) |
u64 | format_field__intval (struct format_field *field, struct perf_sample *sample, bool needs_swap) |
u64 | perf_evsel__intval (struct perf_evsel *evsel, struct perf_sample *sample, const char *name) |
bool | perf_evsel__fallback (struct perf_evsel *evsel, int err, char *msg, size_t msgsize) |
static bool | find_process (const char *name) |
int | perf_evsel__open_strerror (struct perf_evsel *evsel, struct target *target, int err, char *msg, size_t size) |
struct perf_env * | perf_evsel__env (struct perf_evsel *evsel) |
Variables | |
struct perf_missing_features | perf_missing_features |
static clockid_t | clockid |
struct { | |
size_t size | |
int(* init )(struct perf_evsel *evsel) | |
void(* fini )(struct perf_evsel *evsel) | |
} | perf_evsel__object |
const char * | perf_evsel__hw_names [PERF_COUNT_HW_MAX] |
const char * | perf_evsel__sw_names [PERF_COUNT_SW_MAX] |
const char * | perf_evsel__hw_cache [PERF_COUNT_HW_CACHE_MAX][PERF_EVSEL__MAX_ALIASES] |
const char * | perf_evsel__hw_cache_op [PERF_COUNT_HW_CACHE_OP_MAX][PERF_EVSEL__MAX_ALIASES] |
const char * | perf_evsel__hw_cache_result [PERF_COUNT_HW_CACHE_RESULT_MAX][PERF_EVSEL__MAX_ALIASES] |
static unsigned long | perf_evsel__hw_cache_stat [C(MAX)] |
#define bit_name | ( | n | ) | { PERF_SAMPLE_##n, #n } |
#define bit_name | ( | n | ) | { PERF_SAMPLE_BRANCH_##n, #n } |
#define bit_name | ( | n | ) | { PERF_FORMAT_##n, #n } |
#define FD | ( | e, | |
x, | |||
y | |||
) | (*(int *)xyarray__entry(e->fd, x, y)) |
#define FUNCTION_EVENT "ftrace:function" |
#define MOD_PRINT | ( | context, | |
mod | |||
) |
#define OVERFLOW_CHECK | ( | offset, | |
size, | |||
max_size | |||
) |
#define OVERFLOW_CHECK_u64 | ( | offset | ) | OVERFLOW_CHECK(offset, sizeof(u64), sizeof(u64)) |
#define p_branch_sample_type | ( | val | ) | __p_branch_sample_type(buf, BUF_SIZE, val) |
#define p_hex | ( | val | ) | snprintf(buf, BUF_SIZE, "%#"PRIx64, (uint64_t)(val)) |
#define p_read_format | ( | val | ) | __p_read_format(buf, BUF_SIZE, val) |
#define p_sample_type | ( | val | ) | __p_sample_type(buf, BUF_SIZE, val) |
#define p_signed | ( | val | ) | snprintf(buf, BUF_SIZE, "%"PRId64, (int64_t)(val)) |
#define p_unsigned | ( | val | ) | snprintf(buf, BUF_SIZE, "%"PRIu64, (uint64_t)(val)) |
#define PRINT_ATTRf | ( | _f, | |
_p | |||
) | PRINT_ATTRn(#_f, _f, _p) |
#define PRINT_ATTRn | ( | _n, | |
_f, | |||
_p | |||
) |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
__perf_evsel__calc_id_pos - calculate id_pos. : sample type
This function returns the position of the event id (PERF_SAMPLE_ID or PERF_SAMPLE_IDENTIFIER) in a sample event i.e. in the array of struct sample_event.
|
static |
__perf_evsel__calc_is_pos - calculate is_pos. : sample type
This function returns the position (counting backwards) of the event id (PERF_SAMPLE_ID or PERF_SAMPLE_IDENTIFIER) in a non-sample event i.e. if sample_id_all is used there is an id sample appended to non-sample events.
|
static |
|
static |
int __perf_evsel__hw_cache_type_op_res_name | ( | u8 | type, |
u8 | op, | ||
u8 | result, | ||
char * | bf, | ||
size_t | size | ||
) |
|
static |
int __perf_evsel__read_on_cpu | ( | struct perf_evsel * | evsel, |
int | cpu, | ||
int | thread, | ||
bool | scale | ||
) |
void __perf_evsel__reset_sample_bit | ( | struct perf_evsel * | evsel, |
enum perf_event_sample_format | bit | ||
) |
void __perf_evsel__set_sample_bit | ( | struct perf_evsel * | evsel, |
enum perf_event_sample_format | bit | ||
) |
|
static |
|
static |
|
static |
u64 format_field__intval | ( | struct format_field * | field, |
struct perf_sample * | sample, | ||
bool | needs_swap | ||
) |
|
static |
|
static |
|
inlinestatic |
void perf_counts_values__scale | ( | struct perf_counts_values * | count, |
bool | scale, | ||
s8 * | pscaled | ||
) |
|
static |
size_t perf_event__sample_event_size | ( | const struct perf_sample * | sample, |
u64 | type, | ||
u64 | read_format | ||
) |
int perf_event__synthesize_sample | ( | union perf_event * | event, |
u64 | type, | ||
u64 | read_format, | ||
const struct perf_sample * | sample | ||
) |
int perf_event_attr__fprintf | ( | FILE * | fp, |
struct perf_event_attr * | attr, | ||
attr__fprintf_f | attr__fprintf, | ||
void * | priv | ||
) |
|
static |
|
static |
|
static |
int perf_evsel__alloc_id | ( | struct perf_evsel * | evsel, |
int | ncpus, | ||
int | nthreads | ||
) |
int perf_evsel__append_addr_filter | ( | struct perf_evsel * | evsel, |
const char * | filter | ||
) |
|
static |
int perf_evsel__append_tp_filter | ( | struct perf_evsel * | evsel, |
const char * | filter | ||
) |
int perf_evsel__apply_filter | ( | struct perf_evsel * | evsel, |
const char * | filter | ||
) |
|
static |
void perf_evsel__calc_id_pos | ( | struct perf_evsel * | evsel | ) |
void perf_evsel__close | ( | struct perf_evsel * | evsel | ) |
void perf_evsel__close_fd | ( | struct perf_evsel * | evsel | ) |
void perf_evsel__compute_deltas | ( | struct perf_evsel * | evsel, |
int | cpu, | ||
int | thread, | ||
struct perf_counts_values * | count | ||
) |
void perf_evsel__config | ( | struct perf_evsel * | evsel, |
struct record_opts * | opts, | ||
struct callchain_param * | callchain | ||
) |
void perf_evsel__config_callchain | ( | struct perf_evsel * | evsel, |
struct record_opts * | opts, | ||
struct callchain_param * | param | ||
) |
void perf_evsel__delete | ( | struct perf_evsel * | evsel | ) |
int perf_evsel__disable | ( | struct perf_evsel * | evsel | ) |
int perf_evsel__enable | ( | struct perf_evsel * | evsel | ) |
struct perf_env* perf_evsel__env | ( | struct perf_evsel * | evsel | ) |
void perf_evsel__exit | ( | struct perf_evsel * | evsel | ) |
bool perf_evsel__fallback | ( | struct perf_evsel * | evsel, |
int | err, | ||
char * | msg, | ||
size_t | msgsize | ||
) |
struct format_field* perf_evsel__field | ( | struct perf_evsel * | evsel, |
const char * | name | ||
) |
|
static |
|
static |
|
static |
int perf_evsel__group_desc | ( | struct perf_evsel * | evsel, |
char * | buf, | ||
size_t | size | ||
) |
const char* perf_evsel__group_name | ( | struct perf_evsel * | evsel | ) |
|
static |
|
static |
void perf_evsel__init | ( | struct perf_evsel * | evsel, |
struct perf_event_attr * | attr, | ||
int | idx | ||
) |
u64 perf_evsel__intval | ( | struct perf_evsel * | evsel, |
struct perf_sample * | sample, | ||
const char * | name | ||
) |
bool perf_evsel__is_function_event | ( | struct perf_evsel * | evsel | ) |
const char* perf_evsel__name | ( | struct perf_evsel * | evsel | ) |
struct perf_evsel* perf_evsel__new_cycles | ( | bool | precise | ) |
struct perf_evsel* perf_evsel__new_idx | ( | struct perf_event_attr * | attr, |
int | idx | ||
) |
struct perf_evsel* perf_evsel__newtp_idx | ( | const char * | sys, |
const char * | name, | ||
int | idx | ||
) |
|
static |
|
static |
int perf_evsel__object_config | ( | size_t | object_size, |
int(*)(struct perf_evsel *evsel) | init, | ||
void(*)(struct perf_evsel *evsel) | fini | ||
) |
int perf_evsel__open | ( | struct perf_evsel * | evsel, |
struct cpu_map * | cpus, | ||
struct thread_map * | threads | ||
) |
int perf_evsel__open_per_cpu | ( | struct perf_evsel * | evsel, |
struct cpu_map * | cpus | ||
) |
int perf_evsel__open_per_thread | ( | struct perf_evsel * | evsel, |
struct thread_map * | threads | ||
) |
int perf_evsel__open_strerror | ( | struct perf_evsel * | evsel, |
struct target * | target, | ||
int | err, | ||
char * | msg, | ||
size_t | size | ||
) |
|
static |
int perf_evsel__parse_sample | ( | struct perf_evsel * | evsel, |
union perf_event * | event, | ||
struct perf_sample * | data | ||
) |
int perf_evsel__parse_sample_timestamp | ( | struct perf_evsel * | evsel, |
union perf_event * | event, | ||
u64 * | timestamp | ||
) |
|
static |
|
static |
void* perf_evsel__rawptr | ( | struct perf_evsel * | evsel, |
struct perf_sample * | sample, | ||
const char * | name | ||
) |
int perf_evsel__read | ( | struct perf_evsel * | evsel, |
int | cpu, | ||
int | thread, | ||
struct perf_counts_values * | count | ||
) |
int perf_evsel__read_counter | ( | struct perf_evsel * | evsel, |
int | cpu, | ||
int | thread | ||
) |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
int perf_evsel__set_filter | ( | struct perf_evsel * | evsel, |
const char * | filter | ||
) |
void perf_evsel__set_sample_id | ( | struct perf_evsel * | evsel, |
bool | can_sample_identifier | ||
) |
|
static |
|
static |
void(* fini) (struct perf_evsel *evsel) |
int(* init) (struct perf_evsel *evsel) |
const char* perf_evsel__hw_cache[PERF_COUNT_HW_CACHE_MAX][PERF_EVSEL__MAX_ALIASES] |
const char* perf_evsel__hw_cache_op[PERF_COUNT_HW_CACHE_OP_MAX][PERF_EVSEL__MAX_ALIASES] |
const char* perf_evsel__hw_cache_result[PERF_COUNT_HW_CACHE_RESULT_MAX][PERF_EVSEL__MAX_ALIASES] |
|
static |
const char* perf_evsel__hw_names[PERF_COUNT_HW_MAX] |
struct { ... } perf_evsel__object |
const char* perf_evsel__sw_names[PERF_COUNT_SW_MAX] |