Lines Matching refs:evsel

15 #include "evsel.h"
80 static void evsel__reset_aggr_stats(struct evsel *evsel)
82 struct perf_stat_evsel *ps = evsel->stats;
89 static void evsel__reset_stat_priv(struct evsel *evsel)
91 struct perf_stat_evsel *ps = evsel->stats;
94 evsel__reset_aggr_stats(evsel);
97 static int evsel__alloc_aggr_stats(struct evsel *evsel, int nr_aggr)
99 struct perf_stat_evsel *ps = evsel->stats;
114 struct evsel *evsel;
116 evlist__for_each_entry(evlist, evsel) {
117 if (evsel__alloc_aggr_stats(evsel, nr_aggr) < 0)
123 static int evsel__alloc_stat_priv(struct evsel *evsel, int nr_aggr)
131 evsel->stats = ps;
133 if (nr_aggr && evsel__alloc_aggr_stats(evsel, nr_aggr) < 0) {
134 evsel->stats = NULL;
139 evsel__reset_stat_priv(evsel);
143 static void evsel__free_stat_priv(struct evsel *evsel)
145 struct perf_stat_evsel *ps = evsel->stats;
151 zfree(&evsel->stats);
154 static int evsel__alloc_prev_raw_counts(struct evsel *evsel)
156 int cpu_map_nr = evsel__nr_cpus(evsel);
157 int nthreads = perf_thread_map__nr(evsel->core.threads);
162 evsel->prev_raw_counts = counts;
167 static void evsel__free_prev_raw_counts(struct evsel *evsel)
169 perf_counts__delete(evsel->prev_raw_counts);
170 evsel->prev_raw_counts = NULL;
173 static void evsel__reset_prev_raw_counts(struct evsel *evsel)
175 if (evsel->prev_raw_counts)
176 perf_counts__reset(evsel->prev_raw_counts);
179 static int evsel__alloc_stats(struct evsel *evsel, int nr_aggr, bool alloc_raw)
181 if (evsel__alloc_stat_priv(evsel, nr_aggr) < 0 ||
182 evsel__alloc_counts(evsel) < 0 ||
183 (alloc_raw && evsel__alloc_prev_raw_counts(evsel) < 0))
192 struct evsel *evsel;
198 evlist__for_each_entry(evlist, evsel) {
199 if (evsel__alloc_stats(evsel, nr_aggr, alloc_raw))
212 struct evsel *evsel;
214 evlist__for_each_entry(evlist, evsel) {
215 evsel__free_stat_priv(evsel);
216 evsel__free_counts(evsel);
217 evsel__free_prev_raw_counts(evsel);
223 struct evsel *evsel;
225 evlist__for_each_entry(evlist, evsel) {
226 evsel__reset_stat_priv(evsel);
227 evsel__reset_counts(evsel);
233 struct evsel *evsel;
235 evlist__for_each_entry(evlist, evsel)
236 evsel__reset_aggr_stats(evsel);
241 struct evsel *evsel;
243 evlist__for_each_entry(evlist, evsel)
244 evsel__reset_prev_raw_counts(evsel);
247 static void evsel__copy_prev_raw_counts(struct evsel *evsel)
249 int idx, nthreads = perf_thread_map__nr(evsel->core.threads);
252 perf_cpu_map__for_each_idx(idx, evsel__cpus(evsel)) {
253 *perf_counts(evsel->counts, idx, thread) =
254 *perf_counts(evsel->prev_raw_counts, idx, thread);
261 struct evsel *evsel;
263 evlist__for_each_entry(evlist, evsel)
264 evsel__copy_prev_raw_counts(evsel);
267 static void evsel__copy_res_stats(struct evsel *evsel)
269 struct perf_stat_evsel *ps = evsel->stats;
273 * in the evsel->stats.res_stats. See perf_stat_process_counter().
280 struct evsel *evsel;
285 evlist__for_each_entry(evlist, evsel)
286 evsel__copy_res_stats(evsel);
304 static int check_per_pkg(struct evsel *counter, struct perf_counts_values *vals,
366 static bool evsel__count_has_error(struct evsel *evsel,
370 /* the evsel was failed already */
371 if (evsel->err || evsel->counts->scaled == -1)
386 process_counter_values(struct perf_stat_config *config, struct evsel *evsel,
390 struct perf_stat_evsel *ps = evsel->stats;
394 if (check_per_pkg(evsel, count, cpu_map_idx, &skip)) {
402 if (!evsel->snapshot)
403 evsel__compute_deltas(evsel, cpu_map_idx, thread, count);
425 struct perf_cpu cpu = perf_cpu_map__cpu(evsel->core.cpus, cpu_map_idx);
442 if (evsel__count_has_error(evsel, count, config) && !ps_aggr->failed) {
462 struct evsel *counter)
480 struct evsel *counter)
511 static int evsel__merge_aggr_counters(struct evsel *evsel, struct evsel *alias)
513 struct perf_stat_evsel *ps_a = evsel->stats;
539 static bool evsel__is_alias(struct evsel *evsel_a, struct evsel *evsel_b)
559 static void evsel__merge_aliases(struct evsel *evsel)
561 struct evlist *evlist = evsel->evlist;
562 struct evsel *alias;
564 alias = list_prepare_entry(evsel, &(evlist->core.entries), core.node);
567 if (evsel__is_alias(evsel, alias)) {
568 evsel__merge_aggr_counters(evsel, alias);
574 static bool evsel__should_merge_hybrid(const struct evsel *evsel,
577 return config->hybrid_merge && evsel__is_hybrid(evsel);
580 static void evsel__merge_stats(struct evsel *evsel, struct perf_stat_config *config)
582 /* this evsel is already merged */
583 if (evsel->merged_stat)
586 if (evsel->auto_merge_stats || evsel__should_merge_hybrid(evsel, config))
587 evsel__merge_aliases(evsel);
593 struct evsel *evsel;
598 evlist__for_each_entry(evlist, evsel)
599 evsel__merge_stats(evsel, config);
602 static void evsel__update_percore_stats(struct evsel *evsel, struct aggr_cpu_id *core_id)
604 struct perf_stat_evsel *ps = evsel->stats;
611 perf_cpu_map__for_each_cpu(cpu, idx, evsel->core.cpus) {
624 perf_cpu_map__for_each_cpu(cpu, idx, evsel->core.cpus) {
640 static void evsel__process_percore(struct evsel *evsel)
642 struct perf_stat_evsel *ps = evsel->stats;
647 if (!evsel->percore)
650 perf_cpu_map__for_each_cpu(cpu, idx, evsel->core.cpus) {
657 evsel__update_percore_stats(evsel, &core_id);
664 struct evsel *evsel;
669 evlist__for_each_entry(evlist, evsel)
670 evsel__process_percore(evsel);
678 struct evsel *counter;
745 int create_perf_stat_counter(struct evsel *evsel,
750 struct perf_event_attr *attr = &evsel->core.attr;
751 struct evsel *leader = evsel__leader(evsel);
764 attr->inherit = !config->no_inherit && list_empty(&evsel->bpf_counter_list);
790 if (evsel__is_group_leader(evsel)) {
798 return evsel__open_per_cpu(evsel, evsel__cpus(evsel), cpu_map_idx);
800 return evsel__open_per_thread(evsel, evsel->core.threads);