Merge tag 'for-v5.18' of git://git.kernel.org/pub/scm/linux/kernel/git/sre/linux...
[sfrench/cifs-2.6.git] / tools / perf / arch / x86 / util / evlist.c
1 // SPDX-License-Identifier: GPL-2.0
2 #include <stdio.h>
3 #include "util/pmu.h"
4 #include "util/evlist.h"
5 #include "util/parse-events.h"
6
7 #define TOPDOWN_L1_EVENTS       "{slots,topdown-retiring,topdown-bad-spec,topdown-fe-bound,topdown-be-bound}"
8 #define TOPDOWN_L2_EVENTS       "{slots,topdown-retiring,topdown-bad-spec,topdown-fe-bound,topdown-be-bound,topdown-heavy-ops,topdown-br-mispredict,topdown-fetch-lat,topdown-mem-bound}"
9
10 int arch_evlist__add_default_attrs(struct evlist *evlist)
11 {
12         if (!pmu_have_event("cpu", "slots"))
13                 return 0;
14
15         if (pmu_have_event("cpu", "topdown-heavy-ops"))
16                 return parse_events(evlist, TOPDOWN_L2_EVENTS, NULL);
17         else
18                 return parse_events(evlist, TOPDOWN_L1_EVENTS, NULL);
19 }
20
21 struct evsel *arch_evlist__leader(struct list_head *list)
22 {
23         struct evsel *evsel, *first;
24
25         first = list_first_entry(list, struct evsel, core.node);
26
27         if (!pmu_have_event("cpu", "slots"))
28                 return first;
29
30         __evlist__for_each_entry(list, evsel) {
31                 if (evsel->pmu_name && !strcmp(evsel->pmu_name, "cpu") &&
32                         evsel->name && strcasestr(evsel->name, "slots"))
33                         return evsel;
34         }
35         return first;
36 }