1 /* SPDX-License-Identifier: GPL-2.0 */
2 #ifndef __LIBPERF_INTERNAL_EVSEL_H
3 #define __LIBPERF_INTERNAL_EVSEL_H
5 #include <linux/types.h>
6 #include <linux/perf_event.h>
9 #include <internal/cpumap.h>
11 struct perf_thread_map;
15 * Per fd, to map back from PERF_SAMPLE_ID to evsel, only used when there are
16 * more than one entry in the evlist.
18 struct perf_sample_id {
19 struct hlist_node node;
21 struct perf_evsel *evsel;
23 * 'idx' will be used for AUX area sampling. A sample will have AUX area
24 * data that will be queued for decoding, where there are separate
25 * queues for each CPU (per-cpu tracing) or task (per-thread tracing).
26 * The sample ID can be used to lookup 'idx' which is effectively the
33 /* Guest machine pid and VCPU, valid only if machine_pid is non-zero */
37 /* Holds total ID period value for PERF_SAMPLE_READ processing. */
42 struct list_head node;
43 struct perf_event_attr attr;
44 /** The commonly used cpu map of CPUs the event should be opened upon, etc. */
45 struct perf_cpu_map *cpus;
47 * The cpu map read from the PMU. For core PMUs this is the list of all
48 * CPUs the event can be opened upon. For other PMUs this is the default
49 * cpu map for opening the event on, for example, the first CPU on a
50 * socket for an uncore event.
52 struct perf_cpu_map *own_cpus;
53 struct perf_thread_map *threads;
56 struct xyarray *sample_id;
59 struct perf_evsel *leader;
61 /* parse modifier helper */
64 * system_wide is for events that need to be on every CPU, irrespective
65 * of user requested CPUs or threads. Tha main example of this is the
66 * dummy event. Map propagation will set cpus for this event to all CPUs
67 * as software PMU events like dummy, have a CPU map that is empty.
71 * Some events, for example uncore events, require a CPU.
72 * i.e. it cannot be the 'any CPU' value of -1.
75 /** Is the PMU for the event a core one? Effects the handling of own_cpus. */
80 void perf_evsel__init(struct perf_evsel *evsel, struct perf_event_attr *attr,
82 int perf_evsel__alloc_fd(struct perf_evsel *evsel, int ncpus, int nthreads);
83 void perf_evsel__close_fd(struct perf_evsel *evsel);
84 void perf_evsel__free_fd(struct perf_evsel *evsel);
85 int perf_evsel__read_size(struct perf_evsel *evsel);
86 int perf_evsel__apply_filter(struct perf_evsel *evsel, const char *filter);
88 int perf_evsel__alloc_id(struct perf_evsel *evsel, int ncpus, int nthreads);
89 void perf_evsel__free_id(struct perf_evsel *evsel);
91 #endif /* __LIBPERF_INTERNAL_EVSEL_H */