1 // SPDX-License-Identifier: GPL-2.0
3 #include "util/evsel.h"
5 #include "util/topdown.h"
9 /* Check whether there is a PMU which supports the perf metrics. */
10 bool topdown_sys_has_perf_metrics(void)
12 static bool has_perf_metrics;
17 return has_perf_metrics;
20 * The perf metrics feature is a core PMU feature.
21 * The PERF_TYPE_RAW type is the type of a core PMU.
22 * The slots event is only available when the core PMU
23 * supports the perf metrics feature.
25 pmu = perf_pmu__find_by_type(PERF_TYPE_RAW);
26 if (pmu && pmu_have_event(pmu->name, "slots"))
27 has_perf_metrics = true;
30 return has_perf_metrics;
33 #define TOPDOWN_SLOTS 0x0400
36 * Check whether a topdown group supports sample-read.
38 * Only Topdown metric supports sample-read. The slots
39 * event must be the leader of the topdown group.
41 bool arch_topdown_sample_read(struct evsel *leader)
43 if (!evsel__sys_has_perf_metrics(leader))
46 if (leader->core.attr.config == TOPDOWN_SLOTS)