2017-11-01 15:07:57 +01:00
|
|
|
/* SPDX-License-Identifier: GPL-2.0 */
|
2011-01-03 16:39:04 -02:00
|
|
|
#ifndef __PERF_EVSEL_H
|
|
|
|
|
#define __PERF_EVSEL_H 1
|
|
|
|
|
|
|
|
|
|
#include <linux/list.h>
|
2011-01-03 17:45:52 -02:00
|
|
|
#include <stdbool.h>
|
2012-11-13 17:27:28 -03:00
|
|
|
#include <stddef.h>
|
2012-11-19 22:21:03 +00:00
|
|
|
#include <linux/perf_event.h>
|
2014-04-25 21:31:02 +02:00
|
|
|
#include <linux/types.h>
|
2011-01-03 16:39:04 -02:00
|
|
|
#include "xyarray.h"
|
2013-03-05 14:53:26 +09:00
|
|
|
#include "symbol.h"
|
2015-06-23 00:36:08 +02:00
|
|
|
#include "cpumap.h"
|
2015-08-07 12:51:03 +02:00
|
|
|
#include "counts.h"
|
2011-01-03 16:39:04 -02:00
|
|
|
|
2011-01-12 22:39:13 -02:00
|
|
|
struct perf_evsel;
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Per fd, to map back from PERF_SAMPLE_ID to evsel, only used when there are
|
|
|
|
|
* more than one entry in the evlist.
|
|
|
|
|
*/
|
|
|
|
|
struct perf_sample_id {
|
|
|
|
|
struct hlist_node node;
|
|
|
|
|
u64 id;
|
|
|
|
|
struct perf_evsel *evsel;
|
2014-10-27 15:49:22 +02:00
|
|
|
int idx;
|
|
|
|
|
int cpu;
|
|
|
|
|
pid_t tid;
|
2012-10-10 18:52:24 +02:00
|
|
|
|
|
|
|
|
/* Holds total ID period value for PERF_SAMPLE_READ processing. */
|
|
|
|
|
u64 period;
|
2011-01-12 22:39:13 -02:00
|
|
|
};
|
|
|
|
|
|
2018-03-06 09:51:48 -03:00
|
|
|
struct cgroup;
|
2014-10-17 12:17:40 -03:00
|
|
|
|
2015-07-29 05:42:10 -04:00
|
|
|
/*
|
|
|
|
|
* The 'struct perf_evsel_config_term' is used to pass event
|
|
|
|
|
* specific configuration data to perf_evsel__config routine.
|
|
|
|
|
* It is allocated within event parsing and attached to
|
|
|
|
|
* perf_evsel::config_terms list head.
|
|
|
|
|
*/
|
2017-10-20 13:27:54 -07:00
|
|
|
enum term_type {
|
2015-07-29 05:42:11 -04:00
|
|
|
PERF_EVSEL__CONFIG_TERM_PERIOD,
|
2015-08-09 15:45:23 +09:00
|
|
|
PERF_EVSEL__CONFIG_TERM_FREQ,
|
2015-08-04 04:30:19 -04:00
|
|
|
PERF_EVSEL__CONFIG_TERM_TIME,
|
2015-08-11 06:30:47 -04:00
|
|
|
PERF_EVSEL__CONFIG_TERM_CALLGRAPH,
|
|
|
|
|
PERF_EVSEL__CONFIG_TERM_STACK_USER,
|
2015-10-28 10:55:02 +00:00
|
|
|
PERF_EVSEL__CONFIG_TERM_INHERIT,
|
2016-04-28 19:03:42 -03:00
|
|
|
PERF_EVSEL__CONFIG_TERM_MAX_STACK,
|
2018-10-19 15:47:34 -03:00
|
|
|
PERF_EVSEL__CONFIG_TERM_MAX_EVENTS,
|
2016-07-14 08:34:45 +00:00
|
|
|
PERF_EVSEL__CONFIG_TERM_OVERWRITE,
|
2016-09-06 10:37:15 -06:00
|
|
|
PERF_EVSEL__CONFIG_TERM_DRV_CFG,
|
2016-10-12 14:02:06 -07:00
|
|
|
PERF_EVSEL__CONFIG_TERM_BRANCH,
|
2015-07-29 05:42:10 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
struct perf_evsel_config_term {
|
|
|
|
|
struct list_head list;
|
2017-10-20 13:27:54 -07:00
|
|
|
enum term_type type;
|
2015-07-29 05:42:10 -04:00
|
|
|
union {
|
|
|
|
|
u64 period;
|
2015-08-09 15:45:23 +09:00
|
|
|
u64 freq;
|
2015-08-04 04:30:19 -04:00
|
|
|
bool time;
|
2015-08-11 06:30:47 -04:00
|
|
|
char *callgraph;
|
2016-09-06 10:37:15 -06:00
|
|
|
char *drv_cfg;
|
2015-08-11 06:30:47 -04:00
|
|
|
u64 stack_user;
|
2016-04-28 19:03:42 -03:00
|
|
|
int max_stack;
|
2015-10-28 10:55:02 +00:00
|
|
|
bool inherit;
|
2016-07-14 08:34:45 +00:00
|
|
|
bool overwrite;
|
2016-10-12 14:02:06 -07:00
|
|
|
char *branch;
|
2018-10-19 15:47:34 -03:00
|
|
|
unsigned long max_events;
|
2015-07-29 05:42:10 -04:00
|
|
|
} val;
|
2017-10-20 13:27:55 -07:00
|
|
|
bool weak;
|
2015-07-29 05:42:10 -04:00
|
|
|
};
|
|
|
|
|
|
2017-10-26 14:22:34 -03:00
|
|
|
struct perf_stat_evsel;
|
|
|
|
|
|
2011-02-16 15:10:01 +02:00
|
|
|
/** struct perf_evsel - event selector
|
|
|
|
|
*
|
2015-08-27 08:07:40 -04:00
|
|
|
* @evlist - evlist this evsel is in, if it is in one.
|
|
|
|
|
* @node - To insert it into evlist->entries or in other list_heads, say in
|
|
|
|
|
* the event parsing routines.
|
2011-02-16 15:10:01 +02:00
|
|
|
* @name - Can be set to retain the original event name passed by the user,
|
|
|
|
|
* so that when showing results in tools such as 'perf stat', we
|
|
|
|
|
* show the name used, not some alias.
|
2013-08-27 11:23:09 +03:00
|
|
|
* @id_pos: 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
|
|
|
|
|
* @is_pos: 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
|
2014-10-23 13:45:13 +03:00
|
|
|
* @priv: And what is in its containing unnamed union are tool specific
|
2011-02-16 15:10:01 +02:00
|
|
|
*/
|
2011-01-03 16:39:04 -02:00
|
|
|
struct perf_evsel {
|
|
|
|
|
struct list_head node;
|
2015-08-27 08:07:40 -04:00
|
|
|
struct perf_evlist *evlist;
|
2011-01-03 16:39:04 -02:00
|
|
|
struct perf_event_attr attr;
|
|
|
|
|
char *filter;
|
|
|
|
|
struct xyarray *fd;
|
2011-03-10 11:15:54 -03:00
|
|
|
struct xyarray *sample_id;
|
|
|
|
|
u64 *id;
|
2011-01-03 17:45:52 -02:00
|
|
|
struct perf_counts *counts;
|
2013-01-29 12:47:43 +01:00
|
|
|
struct perf_counts *prev_raw_counts;
|
2011-01-03 16:39:04 -02:00
|
|
|
int idx;
|
2012-08-16 21:10:17 +02:00
|
|
|
u32 ids;
|
2018-10-19 15:47:34 -03:00
|
|
|
unsigned long max_events;
|
2018-10-22 14:14:16 -03:00
|
|
|
unsigned long nr_events_printed;
|
2011-02-16 15:10:01 +02:00
|
|
|
char *name;
|
2013-11-12 17:58:49 +01:00
|
|
|
double scale;
|
|
|
|
|
const char *unit;
|
2018-09-19 14:56:44 -04:00
|
|
|
struct tep_event_format *tp_format;
|
2015-10-25 15:51:44 +01:00
|
|
|
off_t id_offset;
|
2017-10-26 14:22:34 -03:00
|
|
|
struct perf_stat_evsel *stats;
|
2016-03-08 21:11:54 -08:00
|
|
|
void *priv;
|
|
|
|
|
u64 db_id;
|
2018-03-06 09:51:48 -03:00
|
|
|
struct cgroup *cgrp;
|
2013-11-06 10:17:38 -03:00
|
|
|
void *handler;
|
2012-09-10 15:53:50 +08:00
|
|
|
struct cpu_map *cpus;
|
2015-09-08 10:58:55 +03:00
|
|
|
struct cpu_map *own_cpus;
|
2015-06-23 00:36:07 +02:00
|
|
|
struct thread_map *threads;
|
2012-08-01 18:53:11 -03:00
|
|
|
unsigned int sample_size;
|
2013-08-27 11:23:09 +03:00
|
|
|
int id_pos;
|
|
|
|
|
int is_pos;
|
2018-04-24 11:20:14 -07:00
|
|
|
bool uniquified_name;
|
2015-05-15 17:29:56 -03:00
|
|
|
bool snapshot;
|
2011-05-30 08:55:59 -06:00
|
|
|
bool supported;
|
2012-09-26 12:48:18 -03:00
|
|
|
bool needs_swap;
|
2018-10-20 09:04:41 -03:00
|
|
|
bool disabled;
|
2014-07-14 13:02:56 +03:00
|
|
|
bool no_aux_samples;
|
2014-07-14 13:02:57 +03:00
|
|
|
bool immediate;
|
2014-07-31 09:00:51 +03:00
|
|
|
bool system_wide;
|
2014-07-31 09:00:52 +03:00
|
|
|
bool tracking;
|
2014-11-21 10:31:12 +01:00
|
|
|
bool per_pkg;
|
2015-10-05 20:06:05 +02:00
|
|
|
bool precise_max;
|
2016-12-13 08:46:22 +01:00
|
|
|
bool ignore_missing_thread;
|
2018-03-07 16:50:02 +01:00
|
|
|
bool forced_leader;
|
2018-05-07 14:13:43 -07:00
|
|
|
bool use_uncore_alias;
|
2012-08-08 12:21:54 +02:00
|
|
|
/* parse modifier helper */
|
|
|
|
|
int exclude_GH;
|
2013-01-22 18:09:29 +09:00
|
|
|
int nr_members;
|
2012-10-10 17:39:03 +02:00
|
|
|
int sample_read;
|
2015-05-15 17:29:56 -03:00
|
|
|
unsigned long *per_pkg_mask;
|
2012-08-08 12:22:36 +02:00
|
|
|
struct perf_evsel *leader;
|
|
|
|
|
char *group_name;
|
2015-07-10 07:36:09 +00:00
|
|
|
bool cmdline_group_boundary;
|
2015-07-29 05:42:10 -04:00
|
|
|
struct list_head config_terms;
|
2015-10-14 12:41:18 +00:00
|
|
|
int bpf_fd;
|
2017-08-31 15:32:18 -03:00
|
|
|
bool auto_merge_stats;
|
2017-03-20 13:17:00 -07:00
|
|
|
bool merged_stat;
|
2017-03-20 13:17:08 -07:00
|
|
|
const char * metric_expr;
|
2017-03-20 13:17:10 -07:00
|
|
|
const char * metric_name;
|
2017-03-20 13:17:08 -07:00
|
|
|
struct perf_evsel **metric_events;
|
|
|
|
|
bool collect_stat;
|
2017-08-31 12:40:26 -07:00
|
|
|
bool weak_group;
|
2018-03-06 09:04:43 -05:00
|
|
|
const char *pmu_name;
|
2011-01-03 16:39:04 -02:00
|
|
|
};
|
|
|
|
|
|
2014-04-14 17:38:39 +02:00
|
|
|
union u64_swap {
|
|
|
|
|
u64 val64;
|
|
|
|
|
u32 val32[2];
|
|
|
|
|
};
|
|
|
|
|
|
2018-02-02 11:27:25 -03:00
|
|
|
struct perf_missing_features {
|
|
|
|
|
bool sample_id_all;
|
|
|
|
|
bool exclude_guest;
|
|
|
|
|
bool mmap2;
|
|
|
|
|
bool cloexec;
|
|
|
|
|
bool clockid;
|
|
|
|
|
bool clockid_wrong;
|
|
|
|
|
bool lbr_flags;
|
|
|
|
|
bool write_backward;
|
|
|
|
|
bool group_read;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
extern struct perf_missing_features perf_missing_features;
|
|
|
|
|
|
2011-01-03 23:09:46 -02:00
|
|
|
struct cpu_map;
|
2014-10-13 10:29:50 -03:00
|
|
|
struct target;
|
2011-01-03 23:09:46 -02:00
|
|
|
struct thread_map;
|
2013-12-19 14:43:45 -03:00
|
|
|
struct record_opts;
|
2011-01-03 23:09:46 -02:00
|
|
|
|
2015-06-23 00:36:08 +02:00
|
|
|
static inline struct cpu_map *perf_evsel__cpus(struct perf_evsel *evsel)
|
|
|
|
|
{
|
|
|
|
|
return evsel->cpus;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static inline int perf_evsel__nr_cpus(struct perf_evsel *evsel)
|
|
|
|
|
{
|
|
|
|
|
return perf_evsel__cpus(evsel)->nr;
|
|
|
|
|
}
|
|
|
|
|
|
2014-11-21 10:31:06 +01:00
|
|
|
void perf_counts_values__scale(struct perf_counts_values *count,
|
|
|
|
|
bool scale, s8 *pscaled);
|
|
|
|
|
|
2015-06-26 11:29:11 +02:00
|
|
|
void perf_evsel__compute_deltas(struct perf_evsel *evsel, int cpu, int thread,
|
2014-11-21 10:31:05 +01:00
|
|
|
struct perf_counts_values *count);
|
|
|
|
|
|
2014-10-09 15:29:51 -03:00
|
|
|
int perf_evsel__object_config(size_t object_size,
|
|
|
|
|
int (*init)(struct perf_evsel *evsel),
|
|
|
|
|
void (*fini)(struct perf_evsel *evsel));
|
|
|
|
|
|
2013-11-07 16:41:19 -03:00
|
|
|
struct perf_evsel *perf_evsel__new_idx(struct perf_event_attr *attr, int idx);
|
|
|
|
|
|
|
|
|
|
static inline struct perf_evsel *perf_evsel__new(struct perf_event_attr *attr)
|
|
|
|
|
{
|
|
|
|
|
return perf_evsel__new_idx(attr, 0);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
struct perf_evsel *perf_evsel__newtp_idx(const char *sys, const char *name, int idx);
|
|
|
|
|
|
2015-09-07 10:38:06 +02:00
|
|
|
/*
|
|
|
|
|
* Returns pointer with encoded error via <linux/err.h> interface.
|
|
|
|
|
*/
|
2013-11-07 16:41:19 -03:00
|
|
|
static inline struct perf_evsel *perf_evsel__newtp(const char *sys, const char *name)
|
|
|
|
|
{
|
|
|
|
|
return perf_evsel__newtp_idx(sys, name, 0);
|
|
|
|
|
}
|
2012-09-26 20:24:19 -03:00
|
|
|
|
2017-07-03 13:05:43 -03:00
|
|
|
struct perf_evsel *perf_evsel__new_cycles(bool precise);
|
2016-07-28 18:33:20 -03:00
|
|
|
|
2018-09-19 14:56:44 -04:00
|
|
|
struct tep_event_format *event_format__new(const char *sys, const char *name);
|
2012-09-26 20:24:19 -03:00
|
|
|
|
2011-01-18 21:41:45 -02:00
|
|
|
void perf_evsel__init(struct perf_evsel *evsel,
|
|
|
|
|
struct perf_event_attr *attr, int idx);
|
|
|
|
|
void perf_evsel__exit(struct perf_evsel *evsel);
|
2011-01-03 16:39:04 -02:00
|
|
|
void perf_evsel__delete(struct perf_evsel *evsel);
|
|
|
|
|
|
2016-04-11 18:15:29 -03:00
|
|
|
struct callchain_param;
|
|
|
|
|
|
2011-11-08 14:41:57 -02:00
|
|
|
void perf_evsel__config(struct perf_evsel *evsel,
|
2016-04-11 18:15:29 -03:00
|
|
|
struct record_opts *opts,
|
|
|
|
|
struct callchain_param *callchain);
|
2016-04-11 18:39:37 -03:00
|
|
|
void perf_evsel__config_callchain(struct perf_evsel *evsel,
|
|
|
|
|
struct record_opts *opts,
|
|
|
|
|
struct callchain_param *callchain);
|
2011-11-08 14:41:57 -02:00
|
|
|
|
2013-08-27 11:23:09 +03:00
|
|
|
int __perf_evsel__sample_size(u64 sample_type);
|
|
|
|
|
void perf_evsel__calc_id_pos(struct perf_evsel *evsel);
|
|
|
|
|
|
2012-06-11 14:08:07 -03:00
|
|
|
bool perf_evsel__is_cache_op_valid(u8 type, u8 op);
|
|
|
|
|
|
|
|
|
|
#define PERF_EVSEL__MAX_ALIASES 8
|
|
|
|
|
|
|
|
|
|
extern const char *perf_evsel__hw_cache[PERF_COUNT_HW_CACHE_MAX]
|
|
|
|
|
[PERF_EVSEL__MAX_ALIASES];
|
|
|
|
|
extern const char *perf_evsel__hw_cache_op[PERF_COUNT_HW_CACHE_OP_MAX]
|
|
|
|
|
[PERF_EVSEL__MAX_ALIASES];
|
2012-09-06 13:11:18 -03:00
|
|
|
extern const char *perf_evsel__hw_cache_result[PERF_COUNT_HW_CACHE_RESULT_MAX]
|
|
|
|
|
[PERF_EVSEL__MAX_ALIASES];
|
|
|
|
|
extern const char *perf_evsel__hw_names[PERF_COUNT_HW_MAX];
|
|
|
|
|
extern const char *perf_evsel__sw_names[PERF_COUNT_SW_MAX];
|
2012-06-11 14:08:07 -03:00
|
|
|
int __perf_evsel__hw_cache_type_op_res_name(u8 type, u8 op, u8 result,
|
|
|
|
|
char *bf, size_t size);
|
2012-06-12 12:34:58 -03:00
|
|
|
const char *perf_evsel__name(struct perf_evsel *evsel);
|
2013-11-12 17:58:49 +01:00
|
|
|
|
2013-01-22 18:09:44 +09:00
|
|
|
const char *perf_evsel__group_name(struct perf_evsel *evsel);
|
|
|
|
|
int perf_evsel__group_desc(struct perf_evsel *evsel, char *buf, size_t size);
|
2012-05-25 16:38:11 -03:00
|
|
|
|
2011-01-12 22:39:13 -02:00
|
|
|
int perf_evsel__alloc_id(struct perf_evsel *evsel, int ncpus, int nthreads);
|
2017-08-11 16:26:17 -07:00
|
|
|
void perf_evsel__close_fd(struct perf_evsel *evsel);
|
2011-01-03 16:39:04 -02:00
|
|
|
|
2012-12-10 14:53:43 -03:00
|
|
|
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);
|
|
|
|
|
|
|
|
|
|
#define perf_evsel__set_sample_bit(evsel, bit) \
|
|
|
|
|
__perf_evsel__set_sample_bit(evsel, PERF_SAMPLE_##bit)
|
|
|
|
|
|
|
|
|
|
#define perf_evsel__reset_sample_bit(evsel, bit) \
|
|
|
|
|
__perf_evsel__reset_sample_bit(evsel, PERF_SAMPLE_##bit)
|
|
|
|
|
|
2013-08-27 11:23:09 +03:00
|
|
|
void perf_evsel__set_sample_id(struct perf_evsel *evsel,
|
|
|
|
|
bool use_sample_identifier);
|
2012-12-10 15:21:30 -03:00
|
|
|
|
2015-07-03 17:05:50 -03:00
|
|
|
int perf_evsel__set_filter(struct perf_evsel *evsel, const char *filter);
|
2016-09-16 08:44:04 -06:00
|
|
|
int perf_evsel__append_tp_filter(struct perf_evsel *evsel, const char *filter);
|
2016-09-16 08:44:05 -06:00
|
|
|
int perf_evsel__append_addr_filter(struct perf_evsel *evsel,
|
|
|
|
|
const char *filter);
|
2017-08-11 16:26:17 -07:00
|
|
|
int perf_evsel__apply_filter(struct perf_evsel *evsel, const char *filter);
|
2015-12-03 10:06:40 +01:00
|
|
|
int perf_evsel__enable(struct perf_evsel *evsel);
|
2015-12-03 10:06:41 +01:00
|
|
|
int perf_evsel__disable(struct perf_evsel *evsel);
|
2012-09-26 15:07:39 -03:00
|
|
|
|
2011-01-11 23:42:19 -02:00
|
|
|
int perf_evsel__open_per_cpu(struct perf_evsel *evsel,
|
2012-08-08 12:22:36 +02:00
|
|
|
struct cpu_map *cpus);
|
2011-01-11 23:42:19 -02:00
|
|
|
int perf_evsel__open_per_thread(struct perf_evsel *evsel,
|
2012-08-08 12:22:36 +02:00
|
|
|
struct thread_map *threads);
|
2011-01-11 23:42:19 -02:00
|
|
|
int perf_evsel__open(struct perf_evsel *evsel, struct cpu_map *cpus,
|
2012-08-08 12:22:36 +02:00
|
|
|
struct thread_map *threads);
|
2017-08-11 16:26:17 -07:00
|
|
|
void perf_evsel__close(struct perf_evsel *evsel);
|
2011-01-03 17:48:12 -02:00
|
|
|
|
2012-09-11 19:24:23 -03:00
|
|
|
struct perf_sample;
|
|
|
|
|
|
2012-09-26 20:22:00 -03:00
|
|
|
void *perf_evsel__rawptr(struct perf_evsel *evsel, struct perf_sample *sample,
|
2012-09-11 19:24:23 -03:00
|
|
|
const char *name);
|
|
|
|
|
u64 perf_evsel__intval(struct perf_evsel *evsel, struct perf_sample *sample,
|
|
|
|
|
const char *name);
|
|
|
|
|
|
2012-09-26 20:22:00 -03:00
|
|
|
static inline char *perf_evsel__strval(struct perf_evsel *evsel,
|
|
|
|
|
struct perf_sample *sample,
|
|
|
|
|
const char *name)
|
|
|
|
|
{
|
|
|
|
|
return perf_evsel__rawptr(evsel, sample, name);
|
|
|
|
|
}
|
|
|
|
|
|
2018-09-19 14:56:45 -04:00
|
|
|
struct tep_format_field;
|
2012-09-18 11:21:50 -03:00
|
|
|
|
2018-09-19 14:56:45 -04:00
|
|
|
u64 format_field__intval(struct tep_format_field *field, struct perf_sample *sample, bool needs_swap);
|
2016-05-31 12:47:46 -03:00
|
|
|
|
2018-09-19 14:56:45 -04:00
|
|
|
struct tep_format_field *perf_evsel__field(struct perf_evsel *evsel, const char *name);
|
2012-09-18 11:21:50 -03:00
|
|
|
|
2011-01-03 16:49:44 -02:00
|
|
|
#define perf_evsel__match(evsel, t, c) \
|
|
|
|
|
(evsel->attr.type == PERF_TYPE_##t && \
|
|
|
|
|
evsel->attr.config == PERF_COUNT_##c)
|
|
|
|
|
|
2012-09-06 17:46:55 +02:00
|
|
|
static inline bool perf_evsel__match2(struct perf_evsel *e1,
|
|
|
|
|
struct perf_evsel *e2)
|
|
|
|
|
{
|
|
|
|
|
return (e1->attr.type == e2->attr.type) &&
|
|
|
|
|
(e1->attr.config == e2->attr.config);
|
|
|
|
|
}
|
|
|
|
|
|
2013-08-21 16:47:26 -07:00
|
|
|
#define perf_evsel__cmp(a, b) \
|
|
|
|
|
((a) && \
|
|
|
|
|
(b) && \
|
|
|
|
|
(a)->attr.type == (b)->attr.type && \
|
|
|
|
|
(a)->attr.config == (b)->attr.config)
|
|
|
|
|
|
2015-06-26 11:29:18 +02:00
|
|
|
int perf_evsel__read(struct perf_evsel *evsel, int cpu, int thread,
|
|
|
|
|
struct perf_counts_values *count);
|
|
|
|
|
|
2017-07-26 14:02:05 +02:00
|
|
|
int perf_evsel__read_counter(struct perf_evsel *evsel, int cpu, int thread);
|
|
|
|
|
|
2011-01-03 17:45:52 -02:00
|
|
|
int __perf_evsel__read_on_cpu(struct perf_evsel *evsel,
|
|
|
|
|
int cpu, int thread, bool scale);
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* perf_evsel__read_on_cpu - Read out the results on a CPU and thread
|
|
|
|
|
*
|
|
|
|
|
* @evsel - event selector to read value
|
|
|
|
|
* @cpu - CPU of interest
|
|
|
|
|
* @thread - thread of interest
|
|
|
|
|
*/
|
|
|
|
|
static inline int perf_evsel__read_on_cpu(struct perf_evsel *evsel,
|
|
|
|
|
int cpu, int thread)
|
|
|
|
|
{
|
|
|
|
|
return __perf_evsel__read_on_cpu(evsel, cpu, thread, false);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* perf_evsel__read_on_cpu_scaled - Read out the results on a CPU and thread, scaled
|
|
|
|
|
*
|
|
|
|
|
* @evsel - event selector to read value
|
|
|
|
|
* @cpu - CPU of interest
|
|
|
|
|
* @thread - thread of interest
|
|
|
|
|
*/
|
|
|
|
|
static inline int perf_evsel__read_on_cpu_scaled(struct perf_evsel *evsel,
|
|
|
|
|
int cpu, int thread)
|
|
|
|
|
{
|
|
|
|
|
return __perf_evsel__read_on_cpu(evsel, cpu, thread, true);
|
|
|
|
|
}
|
|
|
|
|
|
2012-08-02 12:23:46 -03:00
|
|
|
int perf_evsel__parse_sample(struct perf_evsel *evsel, union perf_event *event,
|
2012-09-26 12:48:18 -03:00
|
|
|
struct perf_sample *sample);
|
2012-08-14 16:42:15 -03:00
|
|
|
|
2017-08-03 13:10:28 +02:00
|
|
|
int perf_evsel__parse_sample_timestamp(struct perf_evsel *evsel,
|
|
|
|
|
union perf_event *event,
|
|
|
|
|
u64 *timestamp);
|
|
|
|
|
|
2012-08-14 16:42:15 -03:00
|
|
|
static inline struct perf_evsel *perf_evsel__next(struct perf_evsel *evsel)
|
|
|
|
|
{
|
|
|
|
|
return list_entry(evsel->node.next, struct perf_evsel, node);
|
|
|
|
|
}
|
2012-11-13 17:27:28 -03:00
|
|
|
|
2013-11-13 15:56:40 -03:00
|
|
|
static inline struct perf_evsel *perf_evsel__prev(struct perf_evsel *evsel)
|
|
|
|
|
{
|
|
|
|
|
return list_entry(evsel->node.prev, struct perf_evsel, node);
|
|
|
|
|
}
|
|
|
|
|
|
2013-03-05 14:53:26 +09:00
|
|
|
/**
|
|
|
|
|
* perf_evsel__is_group_leader - Return whether given evsel is a leader event
|
|
|
|
|
*
|
|
|
|
|
* @evsel - evsel selector to be tested
|
|
|
|
|
*
|
|
|
|
|
* Return %true if @evsel is a group leader or a stand-alone event
|
|
|
|
|
*/
|
2012-11-29 15:38:30 +09:00
|
|
|
static inline bool perf_evsel__is_group_leader(const struct perf_evsel *evsel)
|
2012-11-13 17:27:28 -03:00
|
|
|
{
|
2012-11-29 15:38:30 +09:00
|
|
|
return evsel->leader == evsel;
|
2012-11-13 17:27:28 -03:00
|
|
|
}
|
2012-12-10 18:17:08 -03:00
|
|
|
|
2013-03-05 14:53:26 +09:00
|
|
|
/**
|
|
|
|
|
* perf_evsel__is_group_event - Return whether given evsel is a group event
|
|
|
|
|
*
|
|
|
|
|
* @evsel - evsel selector to be tested
|
|
|
|
|
*
|
|
|
|
|
* Return %true iff event group view is enabled and @evsel is a actual group
|
|
|
|
|
* leader which has other members in the group
|
|
|
|
|
*/
|
|
|
|
|
static inline bool perf_evsel__is_group_event(struct perf_evsel *evsel)
|
|
|
|
|
{
|
|
|
|
|
if (!symbol_conf.event_group)
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
return perf_evsel__is_group_leader(evsel) && evsel->nr_members > 1;
|
|
|
|
|
}
|
|
|
|
|
|
2016-07-07 11:51:47 -03:00
|
|
|
bool perf_evsel__is_function_event(struct perf_evsel *evsel);
|
2014-03-02 16:56:40 +01:00
|
|
|
|
2016-02-22 09:10:37 +00:00
|
|
|
static inline bool perf_evsel__is_bpf_output(struct perf_evsel *evsel)
|
|
|
|
|
{
|
2018-07-20 13:00:33 +02:00
|
|
|
return perf_evsel__match(evsel, SOFTWARE, SW_BPF_OUTPUT);
|
2016-02-22 09:10:37 +00:00
|
|
|
}
|
|
|
|
|
|
2018-07-20 13:00:34 +02:00
|
|
|
static inline bool perf_evsel__is_clock(struct perf_evsel *evsel)
|
|
|
|
|
{
|
|
|
|
|
return perf_evsel__match(evsel, SOFTWARE, SW_CPU_CLOCK) ||
|
|
|
|
|
perf_evsel__match(evsel, SOFTWARE, SW_TASK_CLOCK);
|
|
|
|
|
}
|
|
|
|
|
|
2012-12-10 18:17:08 -03:00
|
|
|
struct perf_attr_details {
|
|
|
|
|
bool freq;
|
|
|
|
|
bool verbose;
|
2013-02-06 17:20:02 -03:00
|
|
|
bool event_group;
|
2015-04-02 21:47:10 +08:00
|
|
|
bool force;
|
2016-01-07 09:12:29 +09:00
|
|
|
bool trace_fields;
|
2012-12-10 18:17:08 -03:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
int perf_evsel__fprintf(struct perf_evsel *evsel,
|
|
|
|
|
struct perf_attr_details *details, FILE *fp);
|
2012-12-13 14:16:30 -03:00
|
|
|
|
2016-04-12 15:16:15 -03:00
|
|
|
#define EVSEL__PRINT_IP (1<<0)
|
|
|
|
|
#define EVSEL__PRINT_SYM (1<<1)
|
|
|
|
|
#define EVSEL__PRINT_DSO (1<<2)
|
|
|
|
|
#define EVSEL__PRINT_SYMOFFSET (1<<3)
|
|
|
|
|
#define EVSEL__PRINT_ONELINE (1<<4)
|
|
|
|
|
#define EVSEL__PRINT_SRCLINE (1<<5)
|
|
|
|
|
#define EVSEL__PRINT_UNKNOWN_AS_ADDR (1<<6)
|
2016-11-16 15:06:28 +09:00
|
|
|
#define EVSEL__PRINT_CALLCHAIN_ARROW (1<<7)
|
2016-11-24 10:11:13 +09:00
|
|
|
#define EVSEL__PRINT_SKIP_IGNORED (1<<8)
|
2016-04-12 15:16:15 -03:00
|
|
|
|
2016-04-14 17:45:51 -03:00
|
|
|
struct callchain_cursor;
|
2016-04-11 12:15:48 -03:00
|
|
|
|
2016-04-14 17:53:49 -03:00
|
|
|
int sample__fprintf_callchain(struct perf_sample *sample, int left_alignment,
|
|
|
|
|
unsigned int print_opts,
|
2016-04-14 17:45:51 -03:00
|
|
|
struct callchain_cursor *cursor, FILE *fp);
|
|
|
|
|
|
|
|
|
|
int sample__fprintf_sym(struct perf_sample *sample, struct addr_location *al,
|
|
|
|
|
int left_alignment, unsigned int print_opts,
|
|
|
|
|
struct callchain_cursor *cursor, FILE *fp);
|
2016-04-12 15:16:15 -03:00
|
|
|
|
2012-12-13 14:16:30 -03:00
|
|
|
bool perf_evsel__fallback(struct perf_evsel *evsel, int err,
|
|
|
|
|
char *msg, size_t msgsize);
|
2013-11-12 16:46:16 -03:00
|
|
|
int perf_evsel__open_strerror(struct perf_evsel *evsel, struct target *target,
|
2012-12-13 15:10:58 -03:00
|
|
|
int err, char *msg, size_t size);
|
2013-01-22 18:09:29 +09:00
|
|
|
|
|
|
|
|
static inline int perf_evsel__group_idx(struct perf_evsel *evsel)
|
|
|
|
|
{
|
|
|
|
|
return evsel->idx - evsel->leader->idx;
|
|
|
|
|
}
|
2013-01-22 18:09:44 +09:00
|
|
|
|
2018-08-04 15:05:08 +02:00
|
|
|
/* Iterates group WITHOUT the leader. */
|
2013-01-22 18:09:44 +09:00
|
|
|
#define for_each_group_member(_evsel, _leader) \
|
|
|
|
|
for ((_evsel) = list_entry((_leader)->node.next, struct perf_evsel, node); \
|
|
|
|
|
(_evsel) && (_evsel)->leader == (_leader); \
|
|
|
|
|
(_evsel) = list_entry((_evsel)->node.next, struct perf_evsel, node))
|
|
|
|
|
|
2018-08-04 15:05:08 +02:00
|
|
|
/* Iterates group WITH the leader. */
|
|
|
|
|
#define for_each_group_evsel(_evsel, _leader) \
|
|
|
|
|
for ((_evsel) = _leader; \
|
|
|
|
|
(_evsel) && (_evsel)->leader == (_leader); \
|
|
|
|
|
(_evsel) = list_entry((_evsel)->node.next, struct perf_evsel, node))
|
|
|
|
|
|
2016-04-18 10:35:03 -03:00
|
|
|
static inline bool perf_evsel__has_branch_callstack(const struct perf_evsel *evsel)
|
2015-01-05 13:23:05 -05:00
|
|
|
{
|
|
|
|
|
return evsel->attr.branch_sample_type & PERF_SAMPLE_BRANCH_CALL_STACK;
|
|
|
|
|
}
|
2015-04-07 11:09:54 +02:00
|
|
|
|
2018-05-28 16:00:29 -03:00
|
|
|
static inline bool evsel__has_callchain(const struct perf_evsel *evsel)
|
|
|
|
|
{
|
|
|
|
|
return (evsel->attr.sample_type & PERF_SAMPLE_CALLCHAIN) != 0;
|
|
|
|
|
}
|
|
|
|
|
|
2015-04-07 11:09:54 +02:00
|
|
|
typedef int (*attr__fprintf_f)(FILE *, const char *, const char *, void *);
|
|
|
|
|
|
|
|
|
|
int perf_event_attr__fprintf(FILE *fp, struct perf_event_attr *attr,
|
|
|
|
|
attr__fprintf_f attr__fprintf, void *priv);
|
|
|
|
|
|
2017-12-11 12:46:11 -03:00
|
|
|
struct perf_env *perf_evsel__env(struct perf_evsel *evsel);
|
2016-06-30 11:44:19 +05:30
|
|
|
|
2018-08-30 08:32:16 +02:00
|
|
|
int perf_evsel__store_ids(struct perf_evsel *evsel, struct perf_evlist *evlist);
|
2011-01-03 16:39:04 -02:00
|
|
|
#endif /* __PERF_EVSEL_H */
|