1 /* SPDX-License-Identifier: GPL-2.0 */ 1 /* SPDX-License-Identifier: GPL-2.0 */ 2 #ifndef __LIBPERF_INTERNAL_EVSEL_H 2 #ifndef __LIBPERF_INTERNAL_EVSEL_H 3 #define __LIBPERF_INTERNAL_EVSEL_H 3 #define __LIBPERF_INTERNAL_EVSEL_H 4 4 5 #include <linux/types.h> 5 #include <linux/types.h> 6 #include <linux/perf_event.h> 6 #include <linux/perf_event.h> 7 #include <stdbool.h> 7 #include <stdbool.h> 8 #include <sys/types.h> 8 #include <sys/types.h> 9 #include <internal/cpumap.h> 9 #include <internal/cpumap.h> 10 10 11 struct perf_thread_map; 11 struct perf_thread_map; 12 struct xyarray; 12 struct xyarray; 13 13 14 /* 14 /* 15 * Per fd, to map back from PERF_SAMPLE_ID to 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. 16 * more than one entry in the evlist. 17 */ 17 */ 18 struct perf_sample_id { 18 struct perf_sample_id { 19 struct hlist_node node; 19 struct hlist_node node; 20 u64 id; 20 u64 id; 21 struct perf_evsel *evsel; 21 struct perf_evsel *evsel; 22 /* 22 /* 23 * 'idx' will be used for AUX area samp 23 * 'idx' will be used for AUX area sampling. A sample will have AUX area 24 * data that will be queued for decodin 24 * data that will be queued for decoding, where there are separate 25 * queues for each CPU (per-cpu tracing 25 * queues for each CPU (per-cpu tracing) or task (per-thread tracing). 26 * The sample ID can be used to lookup 26 * The sample ID can be used to lookup 'idx' which is effectively the 27 * queue number. 27 * queue number. 28 */ 28 */ 29 int idx; 29 int idx; 30 struct perf_cpu cpu; 30 struct perf_cpu cpu; 31 pid_t tid; 31 pid_t tid; 32 32 33 /* Guest machine pid and VCPU, valid o 33 /* Guest machine pid and VCPU, valid only if machine_pid is non-zero */ 34 pid_t machine_pid; 34 pid_t machine_pid; 35 struct perf_cpu vcpu; 35 struct perf_cpu vcpu; 36 36 37 /* Holds total ID period value for PER 37 /* Holds total ID period value for PERF_SAMPLE_READ processing. */ 38 u64 period; 38 u64 period; 39 }; 39 }; 40 40 41 struct perf_evsel { 41 struct perf_evsel { 42 struct list_head node; 42 struct list_head node; 43 struct perf_event_attr attr; 43 struct perf_event_attr attr; 44 /** The commonly used cpu map of CPUs 44 /** The commonly used cpu map of CPUs the event should be opened upon, etc. */ 45 struct perf_cpu_map *cpus; 45 struct perf_cpu_map *cpus; 46 /** 46 /** 47 * The cpu map read from the PMU. For 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. 48 * CPUs the event can be opened upon. For other PMUs this is the default 49 * cpu map for opening the event on, f 49 * cpu map for opening the event on, for example, the first CPU on a 50 * socket for an uncore event. 50 * socket for an uncore event. 51 */ 51 */ 52 struct perf_cpu_map *own_cpus; 52 struct perf_cpu_map *own_cpus; 53 struct perf_thread_map *threads; 53 struct perf_thread_map *threads; 54 struct xyarray *fd; 54 struct xyarray *fd; 55 struct xyarray *mmap; 55 struct xyarray *mmap; 56 struct xyarray *sample_id; 56 struct xyarray *sample_id; 57 u64 *id; 57 u64 *id; 58 u32 ids; 58 u32 ids; 59 struct perf_evsel *leader; 59 struct perf_evsel *leader; 60 60 61 /* parse modifier helper */ 61 /* parse modifier helper */ 62 int nr_members; 62 int nr_members; 63 /* 63 /* 64 * system_wide is for events that need 64 * system_wide is for events that need to be on every CPU, irrespective 65 * of user requested CPUs or threads. 65 * of user requested CPUs or threads. Tha main example of this is the 66 * dummy event. Map propagation will s 66 * dummy event. Map propagation will set cpus for this event to all CPUs 67 * as software PMU events like dummy, 67 * as software PMU events like dummy, have a CPU map that is empty. 68 */ 68 */ 69 bool system_wide; 69 bool system_wide; 70 /* 70 /* 71 * Some events, for example uncore eve 71 * Some events, for example uncore events, require a CPU. 72 * i.e. it cannot be the 'any CPU' val 72 * i.e. it cannot be the 'any CPU' value of -1. 73 */ 73 */ 74 bool requires_cpu; 74 bool requires_cpu; 75 /** Is the PMU for the event a core on 75 /** Is the PMU for the event a core one? Effects the handling of own_cpus. */ 76 bool is_pmu_core; 76 bool is_pmu_core; 77 int idx; 77 int idx; 78 }; 78 }; 79 79 80 void perf_evsel__init(struct perf_evsel *evsel 80 void perf_evsel__init(struct perf_evsel *evsel, struct perf_event_attr *attr, 81 int idx); 81 int idx); 82 int perf_evsel__alloc_fd(struct perf_evsel *ev 82 int perf_evsel__alloc_fd(struct perf_evsel *evsel, int ncpus, int nthreads); 83 void perf_evsel__close_fd(struct perf_evsel *e 83 void perf_evsel__close_fd(struct perf_evsel *evsel); 84 void perf_evsel__free_fd(struct perf_evsel *ev 84 void perf_evsel__free_fd(struct perf_evsel *evsel); 85 int perf_evsel__read_size(struct perf_evsel *e 85 int perf_evsel__read_size(struct perf_evsel *evsel); 86 int perf_evsel__apply_filter(struct perf_evsel 86 int perf_evsel__apply_filter(struct perf_evsel *evsel, const char *filter); 87 87 88 int perf_evsel__alloc_id(struct perf_evsel *ev 88 int perf_evsel__alloc_id(struct perf_evsel *evsel, int ncpus, int nthreads); 89 void perf_evsel__free_id(struct perf_evsel *ev 89 void perf_evsel__free_id(struct perf_evsel *evsel); 90 90 91 #endif /* __LIBPERF_INTERNAL_EVSEL_H */ 91 #endif /* __LIBPERF_INTERNAL_EVSEL_H */ 92 92
Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.