/** struct evsel - event selector * * @evlist - evlist this evsel is in, if it is in one. * @core - libperf evsel object * @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. * @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 perf_record_sample * @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 * @priv: And what is in its containing unnamed union are tool specific
*/ struct evsel { struct perf_evsel core; struct evlist *evlist;
off_t id_offset; int id_pos; int is_pos; unsignedint sample_size;
/* * These fields can be set in the parse-events code or similar. * Please check evsel__clone() to copy them properly so that * they can be released properly.
*/ struct { char *name; char *group_name; constchar *group_pmu_name; #ifdef HAVE_LIBTRACEEVENT char *tp_sys; char *tp_name; struct tep_event *tp_format; #endif char *filter; unsignedlong max_events; double scale; constchar *unit; struct cgroup *cgrp; constchar *metric_id; /* * This point to the first evsel with the same name, intended to store the * aggregated counts in aggregation mode.
*/ struct evsel *first_wildcard_match; /* parse modifier helper */ int exclude_GH; int sample_read; bool snapshot; bool per_pkg; bool percore; bool precise_max; bool is_libpfm_event; bool collect_stat; bool weak_group; bool bpf_counter; bool use_config_name; bool skippable; bool retire_lat; int bpf_fd; struct bpf_object *bpf_obj; struct list_head config_terms;
u64 alternate_hw_config;
};
/* * metric fields are similar, but needs more care as they can have * references to other metric (evsel).
*/ struct evsel **metric_events; struct evsel *metric_leader;
void *handler; struct perf_counts *counts; struct perf_counts *prev_raw_counts; unsignedlong nr_events_printed; struct perf_stat_evsel *stats; void *priv;
u64 db_id; bool uniquified_name; bool supported; bool needs_swap; bool disabled; bool no_aux_samples; bool immediate; bool tracking; bool ignore_missing_thread; bool forced_leader; bool cmdline_group_boundary; bool reset_group; bool errored; bool needs_auxtrace_mmap; bool default_metricgroup; /* A member of the Default metricgroup */ bool needs_uniquify; struct hashmap *per_pkg_mask; int err; int script_output_type; struct {
evsel__sb_cb_t *cb; void *data;
} side_band; /* * For reporting purposes, an evsel sample can have a callchain * synthesized from AUX area data. Keep track of synthesized sample * types here. Note, the recorded sample_type cannot be changed because * it is needed to continue to parse events. * See also evsel__has_callchain().
*/
__u64 synth_sample_type;
/* * Store the branch counter related information. * br_cntr_idx: The idx of the branch counter event in the evlist * br_cntr_nr: The number of the branch counter event in the group * (Only available for the leader event) * abbr_name: The abbreviation name assigned to an event which is * logged by the branch counter. * The abbr name is from A to Z9. NA is applied if out * of the range.
*/ int br_cntr_idx; int br_cntr_nr; char abbr_name[3];
/* * bpf_counter_ops serves two use cases: * 1. perf-stat -b counting events used byBPF programs * 2. perf-stat --use-bpf use BPF programs to aggregate counts
*/ struct bpf_counter_ops *bpf_counter_ops;
struct list_head bpf_counter_list; /* for perf-stat -b */ struct list_head bpf_filters; /* for perf-record --filter */
/* for perf-stat --use-bpf */ int bperf_leader_prog_fd; int bperf_leader_link_fd; union { struct bperf_leader_bpf *leader_skel; struct bperf_follower_bpf *follower_skel; void *bpf_skel;
}; unsignedlong open_flags; int precise_ip_original;
/* The PMU the event is from. Used for missing_features, PMU name, etc. */ struct perf_pmu *pmu;
/* For tool events */ /* Beginning time subtracted when the counter is read. */ union { /* Defaults for retirement latency events. */ struct _retirement_latency { double mean; double min; double max;
} retirement_latency; /* duration_time is a single global time. */
__u64 start_time; /* * user_time and system_time read an initial value potentially * per-CPU or per-pid.
*/ struct xyarray *start_times;
}; /* Is the tool's fd for /proc/pid/stat or /proc/stat. */ bool pid_stat;
};
int evsel__set_filter(struct evsel *evsel, constchar *filter); int evsel__append_tp_filter(struct evsel *evsel, constchar *filter); int evsel__append_addr_filter(struct evsel *evsel, constchar *filter); int evsel__enable_cpu(struct evsel *evsel, int cpu_map_idx); int evsel__enable(struct evsel *evsel); int evsel__disable(struct evsel *evsel); int evsel__disable_cpu(struct evsel *evsel, int cpu_map_idx);
int evsel__open_per_cpu_and_thread(struct evsel *evsel, struct perf_cpu_map *cpus, int cpu_map_idx, struct perf_thread_map *threads); int evsel__open_per_cpu(struct evsel *evsel, struct perf_cpu_map *cpus, int cpu_map_idx); int evsel__open_per_thread(struct evsel *evsel, struct perf_thread_map *threads); int evsel__open(struct evsel *evsel, struct perf_cpu_map *cpus, struct perf_thread_map *threads); void evsel__close(struct evsel *evsel); int evsel__prepare_open(struct evsel *evsel, struct perf_cpu_map *cpus, struct perf_thread_map *threads);
#define evsel__match(evsel, t, c) __evsel__match(evsel, PERF_TYPE_##t, PERF_COUNT_##c)
int evsel__read_counter(struct evsel *evsel, int cpu_map_idx, int thread);
int __evsel__read_on_cpu(struct evsel *evsel, int cpu_map_idx, int thread, bool scale);
/** * evsel__read_on_cpu - Read out the results on a CPU and thread * * @evsel - event selector to read value * @cpu_map_idx - CPU of interest * @thread - thread of interest
*/ staticinlineint evsel__read_on_cpu(struct evsel *evsel, int cpu_map_idx, int thread)
{ return __evsel__read_on_cpu(evsel, cpu_map_idx, thread, false);
}
/** * evsel__read_on_cpu_scaled - Read out the results on a CPU and thread, scaled * * @evsel - event selector to read value * @cpu_map_idx - CPU of interest * @thread - thread of interest
*/ staticinlineint evsel__read_on_cpu_scaled(struct evsel *evsel, int cpu_map_idx, int thread)
{ return __evsel__read_on_cpu(evsel, cpu_map_idx, thread, true);
}
int evsel__parse_sample(struct evsel *evsel, union perf_event *event, struct perf_sample *sample);
int evsel__parse_sample_timestamp(struct evsel *evsel, union perf_event *event,
u64 *timestamp);
/** * 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
*/ staticinlinebool evsel__is_group_leader(conststruct evsel *evsel)
{ return evsel->core.leader == &evsel->core;
}
/** * 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
*/ staticinlinebool evsel__is_group_event(struct evsel *evsel)
{ if (!symbol_conf.event_group) returnfalse;
staticinlinebool evsel__has_callchain(conststruct evsel *evsel)
{ /* * For reporting purposes, an evsel sample can have a recorded callchain * or a callchain synthesized from AUX area data.
*/ return evsel->core.attr.sample_type & PERF_SAMPLE_CALLCHAIN ||
evsel->synth_sample_type & PERF_SAMPLE_CALLCHAIN;
}
staticinlinebool evsel__has_br_stack(conststruct evsel *evsel)
{ /* * For reporting purposes, an evsel sample can have a recorded branch * stack or a branch stack synthesized from AUX area data.
*/ return evsel->core.attr.sample_type & PERF_SAMPLE_BRANCH_STACK ||
evsel->synth_sample_type & PERF_SAMPLE_BRANCH_STACK;
}
/* * Macro to swap the bit-field postition and size. * Used when, * - dont need to swap the entire u64 && * - when u64 has variable bit-field sizes && * - when presented in a host endian which is different * than the source endian of the perf.data file
*/ #define bitfield_swap(src, pos, size) \
((((src) >> (pos)) & ((1ull << (size)) - 1)) << (63 - ((pos) + (size) - 1)))
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.