1 /* SPDX-License-Identifier: GPL-2.0 */
2 #ifndef __LIBPERF_EVENT_H
3 #define __LIBPERF_EVENT_H
5 #include <linux/perf_event.h>
6 #include <linux/types.h>
7 #include <linux/limits.h>
9 #include <sys/types.h> /* pid_t */
11 #define event_contains(obj, mem) ((obj).header.size > offsetof(typeof(obj), mem))
13 struct perf_record_mmap {
14 struct perf_event_header header;
19 char filename[PATH_MAX];
22 struct perf_record_mmap2 {
23 struct perf_event_header header;
44 char filename[PATH_MAX];
47 struct perf_record_comm {
48 struct perf_event_header header;
53 struct perf_record_namespaces {
54 struct perf_event_header header;
57 struct perf_ns_link_info link_info[];
60 struct perf_record_fork {
61 struct perf_event_header header;
67 struct perf_record_lost {
68 struct perf_event_header header;
73 struct perf_record_lost_samples {
74 struct perf_event_header header;
79 * PERF_FORMAT_ENABLED | PERF_FORMAT_RUNNING | PERF_FORMAT_ID
81 struct perf_record_read {
82 struct perf_event_header header;
90 struct perf_record_throttle {
91 struct perf_event_header header;
98 #define KSYM_NAME_LEN 256
101 struct perf_record_ksymbol {
102 struct perf_event_header header;
107 char name[KSYM_NAME_LEN];
110 struct perf_record_bpf_event {
111 struct perf_event_header header;
116 /* for bpf_prog types */
117 __u8 tag[BPF_TAG_SIZE]; // prog tag
120 struct perf_record_cgroup {
121 struct perf_event_header header;
126 struct perf_record_text_poke_event {
127 struct perf_event_header header;
134 struct perf_record_sample {
135 struct perf_event_header header;
139 struct perf_record_switch {
140 struct perf_event_header header;
145 struct perf_record_header_attr {
146 struct perf_event_header header;
147 struct perf_event_attr attr;
152 PERF_CPU_MAP__CPUS = 0,
153 PERF_CPU_MAP__MASK = 1,
156 struct cpu_map_entries {
161 struct perf_record_record_cpu_map {
164 unsigned long mask[];
167 struct perf_record_cpu_map_data {
172 struct perf_record_cpu_map {
173 struct perf_event_header header;
174 struct perf_record_cpu_map_data data;
178 PERF_EVENT_UPDATE__UNIT = 0,
179 PERF_EVENT_UPDATE__SCALE = 1,
180 PERF_EVENT_UPDATE__NAME = 2,
181 PERF_EVENT_UPDATE__CPUS = 3,
184 struct perf_record_event_update_cpus {
185 struct perf_record_cpu_map_data cpus;
188 struct perf_record_event_update_scale {
192 struct perf_record_event_update {
193 struct perf_event_header header;
199 #define MAX_EVENT_NAME 64
201 struct perf_trace_event_type {
203 char name[MAX_EVENT_NAME];
206 struct perf_record_header_event_type {
207 struct perf_event_header header;
208 struct perf_trace_event_type event_type;
211 struct perf_record_header_tracing_data {
212 struct perf_event_header header;
216 #define PERF_RECORD_MISC_BUILD_ID_SIZE (1 << 15)
218 struct perf_record_header_build_id {
219 struct perf_event_header header;
233 struct id_index_entry {
240 struct perf_record_id_index {
241 struct perf_event_header header;
243 struct id_index_entry entries[];
246 struct perf_record_auxtrace_info {
247 struct perf_event_header header;
249 __u32 reserved__; /* For alignment */
253 struct perf_record_auxtrace {
254 struct perf_event_header header;
261 __u32 reserved__; /* For alignment */
264 #define MAX_AUXTRACE_ERROR_MSG 64
266 struct perf_record_auxtrace_error {
267 struct perf_event_header header;
276 char msg[MAX_AUXTRACE_ERROR_MSG];
279 struct perf_record_aux {
280 struct perf_event_header header;
286 struct perf_record_itrace_start {
287 struct perf_event_header header;
292 struct perf_record_aux_output_hw_id {
293 struct perf_event_header header;
297 struct perf_record_thread_map_entry {
302 struct perf_record_thread_map {
303 struct perf_event_header header;
305 struct perf_record_thread_map_entry entries[];
309 PERF_STAT_CONFIG_TERM__AGGR_MODE = 0,
310 PERF_STAT_CONFIG_TERM__INTERVAL = 1,
311 PERF_STAT_CONFIG_TERM__SCALE = 2,
312 PERF_STAT_CONFIG_TERM__MAX = 3,
315 struct perf_record_stat_config_entry {
320 struct perf_record_stat_config {
321 struct perf_event_header header;
323 struct perf_record_stat_config_entry data[];
326 struct perf_record_stat {
327 struct perf_event_header header;
343 struct perf_record_stat_round {
344 struct perf_event_header header;
349 struct perf_record_time_conv {
350 struct perf_event_header header;
356 __u8 cap_user_time_zero;
357 __u8 cap_user_time_short;
358 __u8 reserved[6]; /* For alignment */
361 struct perf_record_header_feature {
362 struct perf_event_header header;
367 struct perf_record_compressed {
368 struct perf_event_header header;
372 enum perf_user_event_type { /* above any possible kernel type */
373 PERF_RECORD_USER_TYPE_START = 64,
374 PERF_RECORD_HEADER_ATTR = 64,
375 PERF_RECORD_HEADER_EVENT_TYPE = 65, /* deprecated */
376 PERF_RECORD_HEADER_TRACING_DATA = 66,
377 PERF_RECORD_HEADER_BUILD_ID = 67,
378 PERF_RECORD_FINISHED_ROUND = 68,
379 PERF_RECORD_ID_INDEX = 69,
380 PERF_RECORD_AUXTRACE_INFO = 70,
381 PERF_RECORD_AUXTRACE = 71,
382 PERF_RECORD_AUXTRACE_ERROR = 72,
383 PERF_RECORD_THREAD_MAP = 73,
384 PERF_RECORD_CPU_MAP = 74,
385 PERF_RECORD_STAT_CONFIG = 75,
386 PERF_RECORD_STAT = 76,
387 PERF_RECORD_STAT_ROUND = 77,
388 PERF_RECORD_EVENT_UPDATE = 78,
389 PERF_RECORD_TIME_CONV = 79,
390 PERF_RECORD_HEADER_FEATURE = 80,
391 PERF_RECORD_COMPRESSED = 81,
392 PERF_RECORD_HEADER_MAX
396 struct perf_event_header header;
397 struct perf_record_mmap mmap;
398 struct perf_record_mmap2 mmap2;
399 struct perf_record_comm comm;
400 struct perf_record_namespaces namespaces;
401 struct perf_record_cgroup cgroup;
402 struct perf_record_fork fork;
403 struct perf_record_lost lost;
404 struct perf_record_lost_samples lost_samples;
405 struct perf_record_read read;
406 struct perf_record_throttle throttle;
407 struct perf_record_sample sample;
408 struct perf_record_bpf_event bpf;
409 struct perf_record_ksymbol ksymbol;
410 struct perf_record_text_poke_event text_poke;
411 struct perf_record_header_attr attr;
412 struct perf_record_event_update event_update;
413 struct perf_record_header_event_type event_type;
414 struct perf_record_header_tracing_data tracing_data;
415 struct perf_record_header_build_id build_id;
416 struct perf_record_id_index id_index;
417 struct perf_record_auxtrace_info auxtrace_info;
418 struct perf_record_auxtrace auxtrace;
419 struct perf_record_auxtrace_error auxtrace_error;
420 struct perf_record_aux aux;
421 struct perf_record_itrace_start itrace_start;
422 struct perf_record_aux_output_hw_id aux_output_hw_id;
423 struct perf_record_switch context_switch;
424 struct perf_record_thread_map thread_map;
425 struct perf_record_cpu_map cpu_map;
426 struct perf_record_stat_config stat_config;
427 struct perf_record_stat stat;
428 struct perf_record_stat_round stat_round;
429 struct perf_record_time_conv time_conv;
430 struct perf_record_header_feature feat;
431 struct perf_record_compressed pack;
434 #endif /* __LIBPERF_EVENT_H */