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 id_index_entry_2 {
245 struct perf_record_id_index {
246 struct perf_event_header header;
248 struct id_index_entry entries[];
251 struct perf_record_auxtrace_info {
252 struct perf_event_header header;
254 __u32 reserved__; /* For alignment */
258 struct perf_record_auxtrace {
259 struct perf_event_header header;
266 __u32 reserved__; /* For alignment */
269 #define MAX_AUXTRACE_ERROR_MSG 64
271 struct perf_record_auxtrace_error {
272 struct perf_event_header header;
281 char msg[MAX_AUXTRACE_ERROR_MSG];
286 struct perf_record_aux {
287 struct perf_event_header header;
293 struct perf_record_itrace_start {
294 struct perf_event_header header;
299 struct perf_record_aux_output_hw_id {
300 struct perf_event_header header;
304 struct perf_record_thread_map_entry {
309 struct perf_record_thread_map {
310 struct perf_event_header header;
312 struct perf_record_thread_map_entry entries[];
316 PERF_STAT_CONFIG_TERM__AGGR_MODE = 0,
317 PERF_STAT_CONFIG_TERM__INTERVAL = 1,
318 PERF_STAT_CONFIG_TERM__SCALE = 2,
319 PERF_STAT_CONFIG_TERM__MAX = 3,
322 struct perf_record_stat_config_entry {
327 struct perf_record_stat_config {
328 struct perf_event_header header;
330 struct perf_record_stat_config_entry data[];
333 struct perf_record_stat {
334 struct perf_event_header header;
350 struct perf_record_stat_round {
351 struct perf_event_header header;
356 struct perf_record_time_conv {
357 struct perf_event_header header;
363 __u8 cap_user_time_zero;
364 __u8 cap_user_time_short;
365 __u8 reserved[6]; /* For alignment */
368 struct perf_record_header_feature {
369 struct perf_event_header header;
374 struct perf_record_compressed {
375 struct perf_event_header header;
379 enum perf_user_event_type { /* above any possible kernel type */
380 PERF_RECORD_USER_TYPE_START = 64,
381 PERF_RECORD_HEADER_ATTR = 64,
382 PERF_RECORD_HEADER_EVENT_TYPE = 65, /* deprecated */
383 PERF_RECORD_HEADER_TRACING_DATA = 66,
384 PERF_RECORD_HEADER_BUILD_ID = 67,
385 PERF_RECORD_FINISHED_ROUND = 68,
386 PERF_RECORD_ID_INDEX = 69,
387 PERF_RECORD_AUXTRACE_INFO = 70,
388 PERF_RECORD_AUXTRACE = 71,
389 PERF_RECORD_AUXTRACE_ERROR = 72,
390 PERF_RECORD_THREAD_MAP = 73,
391 PERF_RECORD_CPU_MAP = 74,
392 PERF_RECORD_STAT_CONFIG = 75,
393 PERF_RECORD_STAT = 76,
394 PERF_RECORD_STAT_ROUND = 77,
395 PERF_RECORD_EVENT_UPDATE = 78,
396 PERF_RECORD_TIME_CONV = 79,
397 PERF_RECORD_HEADER_FEATURE = 80,
398 PERF_RECORD_COMPRESSED = 81,
399 PERF_RECORD_FINISHED_INIT = 82,
400 PERF_RECORD_HEADER_MAX
404 struct perf_event_header header;
405 struct perf_record_mmap mmap;
406 struct perf_record_mmap2 mmap2;
407 struct perf_record_comm comm;
408 struct perf_record_namespaces namespaces;
409 struct perf_record_cgroup cgroup;
410 struct perf_record_fork fork;
411 struct perf_record_lost lost;
412 struct perf_record_lost_samples lost_samples;
413 struct perf_record_read read;
414 struct perf_record_throttle throttle;
415 struct perf_record_sample sample;
416 struct perf_record_bpf_event bpf;
417 struct perf_record_ksymbol ksymbol;
418 struct perf_record_text_poke_event text_poke;
419 struct perf_record_header_attr attr;
420 struct perf_record_event_update event_update;
421 struct perf_record_header_event_type event_type;
422 struct perf_record_header_tracing_data tracing_data;
423 struct perf_record_header_build_id build_id;
424 struct perf_record_id_index id_index;
425 struct perf_record_auxtrace_info auxtrace_info;
426 struct perf_record_auxtrace auxtrace;
427 struct perf_record_auxtrace_error auxtrace_error;
428 struct perf_record_aux aux;
429 struct perf_record_itrace_start itrace_start;
430 struct perf_record_aux_output_hw_id aux_output_hw_id;
431 struct perf_record_switch context_switch;
432 struct perf_record_thread_map thread_map;
433 struct perf_record_cpu_map cpu_map;
434 struct perf_record_stat_config stat_config;
435 struct perf_record_stat stat;
436 struct perf_record_stat_round stat_round;
437 struct perf_record_time_conv time_conv;
438 struct perf_record_header_feature feat;
439 struct perf_record_compressed pack;
442 #endif /* __LIBPERF_EVENT_H */