xref: /linux/tools/perf/util/tool_pmu.h (revision 9e906a9dead17d81d6c2687f65e159231d0e3286)
1 /* SPDX-License-Identifier: GPL-2.0 */
2 #ifndef __TOOL_PMU_H
3 #define __TOOL_PMU_H
4 
5 #include "pmu.h"
6 
7 struct evsel;
8 struct perf_thread_map;
9 struct print_callbacks;
10 
11 enum tool_pmu_event {
12 	TOOL_PMU__EVENT_NONE = 0,
13 	TOOL_PMU__EVENT_DURATION_TIME,
14 	TOOL_PMU__EVENT_USER_TIME,
15 	TOOL_PMU__EVENT_SYSTEM_TIME,
16 	TOOL_PMU__EVENT_HAS_PMEM,
17 	TOOL_PMU__EVENT_NUM_CORES,
18 	TOOL_PMU__EVENT_NUM_CPUS,
19 	TOOL_PMU__EVENT_NUM_CPUS_ONLINE,
20 	TOOL_PMU__EVENT_NUM_DIES,
21 	TOOL_PMU__EVENT_NUM_PACKAGES,
22 	TOOL_PMU__EVENT_SLOTS,
23 	TOOL_PMU__EVENT_SMT_ON,
24 	TOOL_PMU__EVENT_SYSTEM_TSC_FREQ,
25 	TOOL_PMU__EVENT_CORE_WIDE,
26 	TOOL_PMU__EVENT_TARGET_CPU,
27 
28 	TOOL_PMU__EVENT_MAX,
29 };
30 
31 #define tool_pmu__for_each_event(ev)					\
32 	for ((ev) = TOOL_PMU__EVENT_DURATION_TIME; (ev) < TOOL_PMU__EVENT_MAX; ev++)
33 
34 const char *tool_pmu__event_to_str(enum tool_pmu_event ev);
35 enum tool_pmu_event tool_pmu__str_to_event(const char *str);
36 bool tool_pmu__skip_event(const char *name);
37 int tool_pmu__num_skip_events(void);
38 
39 bool tool_pmu__read_event(enum tool_pmu_event ev,
40 			  struct evsel *evsel,
41 			  bool system_wide,
42 			  const char *user_requested_cpu_list,
43 			  u64 *result);
44 
45 
46 u64 tool_pmu__cpu_slots_per_cycle(void);
47 
48 bool perf_pmu__is_tool(const struct perf_pmu *pmu);
49 struct perf_cpu_map *tool_pmu__cpus(struct perf_event_attr *attr);
50 
51 bool evsel__is_tool(const struct evsel *evsel);
52 enum tool_pmu_event evsel__tool_event(const struct evsel *evsel);
53 const char *evsel__tool_pmu_event_name(const struct evsel *evsel);
54 int evsel__tool_pmu_prepare_open(struct evsel *evsel,
55 				 struct perf_cpu_map *cpus,
56 				 int nthreads);
57 int evsel__tool_pmu_open(struct evsel *evsel,
58 			 struct perf_thread_map *threads,
59 			 int start_cpu_map_idx, int end_cpu_map_idx);
60 int evsel__tool_pmu_read(struct evsel *evsel, int cpu_map_idx, int thread);
61 
62 struct perf_pmu *tool_pmu__new(void);
63 
64 #endif /* __TOOL_PMU_H */
65