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 <linux/compiler.h>
10 #include <sys/types.h> /* pid_t */
12 #define event_contains(obj, mem) ((obj).header.size > offsetof(typeof(obj), mem))
14 struct perf_record_mmap {
15 struct perf_event_header header;
20 char filename[PATH_MAX];
23 struct perf_record_mmap2 {
24 struct perf_event_header header;
45 char filename[PATH_MAX];
48 struct perf_record_comm {
49 struct perf_event_header header;
54 struct perf_record_namespaces {
55 struct perf_event_header header;
58 struct perf_ns_link_info link_info[];
61 struct perf_record_fork {
62 struct perf_event_header header;
68 struct perf_record_lost {
69 struct perf_event_header header;
74 struct perf_record_lost_samples {
75 struct perf_event_header header;
80 * PERF_FORMAT_ENABLED | PERF_FORMAT_RUNNING | PERF_FORMAT_ID | PERF_FORMAT_LOST
82 struct perf_record_read {
83 struct perf_event_header header;
92 struct perf_record_throttle {
93 struct perf_event_header header;
100 #define KSYM_NAME_LEN 256
103 struct perf_record_ksymbol {
104 struct perf_event_header header;
109 char name[KSYM_NAME_LEN];
112 struct perf_record_bpf_event {
113 struct perf_event_header header;
118 /* for bpf_prog types */
119 __u8 tag[BPF_TAG_SIZE]; // prog tag
122 struct perf_record_cgroup {
123 struct perf_event_header header;
128 struct perf_record_text_poke_event {
129 struct perf_event_header header;
136 struct perf_record_sample {
137 struct perf_event_header header;
141 struct perf_record_switch {
142 struct perf_event_header header;
147 struct perf_record_header_attr {
148 struct perf_event_header header;
149 struct perf_event_attr attr;
154 PERF_CPU_MAP__CPUS = 0,
155 PERF_CPU_MAP__MASK = 1,
159 * Array encoding of a perf_cpu_map where nr is the number of entries in cpu[]
160 * and each entry is a value for a CPU in the map.
162 struct cpu_map_entries {
167 /* Bitmap encoding of a perf_cpu_map where bitmap entries are 32-bit. */
168 struct perf_record_mask_cpu_map32 {
169 /* Number of mask values. */
177 /* Bitmap encoding of a perf_cpu_map where bitmap entries are 64-bit. */
178 struct perf_record_mask_cpu_map64 {
179 /* Number of mask values. */
183 /* Legacy padding. */
190 * 'struct perf_record_cpu_map_data' is packed as unfortunately an earlier
191 * version had unaligned data and we wish to retain file format compatibility.
194 #pragma GCC diagnostic push
195 #pragma GCC diagnostic ignored "-Wpacked"
196 #pragma GCC diagnostic ignored "-Wattributes"
198 struct __packed perf_record_cpu_map_data {
201 /* Used when type == PERF_CPU_MAP__CPUS. */
202 struct cpu_map_entries cpus_data;
203 /* Used when type == PERF_CPU_MAP__MASK and long_size == 4. */
204 struct perf_record_mask_cpu_map32 mask32_data;
205 /* Used when type == PERF_CPU_MAP__MASK and long_size == 8. */
206 struct perf_record_mask_cpu_map64 mask64_data;
210 #pragma GCC diagnostic pop
212 struct perf_record_cpu_map {
213 struct perf_event_header header;
214 struct perf_record_cpu_map_data data;
218 PERF_EVENT_UPDATE__UNIT = 0,
219 PERF_EVENT_UPDATE__SCALE = 1,
220 PERF_EVENT_UPDATE__NAME = 2,
221 PERF_EVENT_UPDATE__CPUS = 3,
224 struct perf_record_event_update_cpus {
225 struct perf_record_cpu_map_data cpus;
228 struct perf_record_event_update_scale {
232 struct perf_record_event_update {
233 struct perf_event_header header;
239 #define MAX_EVENT_NAME 64
241 struct perf_trace_event_type {
243 char name[MAX_EVENT_NAME];
246 struct perf_record_header_event_type {
247 struct perf_event_header header;
248 struct perf_trace_event_type event_type;
251 struct perf_record_header_tracing_data {
252 struct perf_event_header header;
256 #define PERF_RECORD_MISC_BUILD_ID_SIZE (1 << 15)
258 struct perf_record_header_build_id {
259 struct perf_event_header header;
273 struct id_index_entry {
280 struct id_index_entry_2 {
285 struct perf_record_id_index {
286 struct perf_event_header header;
288 struct id_index_entry entries[];
291 struct perf_record_auxtrace_info {
292 struct perf_event_header header;
294 __u32 reserved__; /* For alignment */
298 struct perf_record_auxtrace {
299 struct perf_event_header header;
306 __u32 reserved__; /* For alignment */
309 #define MAX_AUXTRACE_ERROR_MSG 64
311 struct perf_record_auxtrace_error {
312 struct perf_event_header header;
321 char msg[MAX_AUXTRACE_ERROR_MSG];
326 struct perf_record_aux {
327 struct perf_event_header header;
333 struct perf_record_itrace_start {
334 struct perf_event_header header;
339 struct perf_record_aux_output_hw_id {
340 struct perf_event_header header;
344 struct perf_record_thread_map_entry {
349 struct perf_record_thread_map {
350 struct perf_event_header header;
352 struct perf_record_thread_map_entry entries[];
356 PERF_STAT_CONFIG_TERM__AGGR_MODE = 0,
357 PERF_STAT_CONFIG_TERM__INTERVAL = 1,
358 PERF_STAT_CONFIG_TERM__SCALE = 2,
359 PERF_STAT_CONFIG_TERM__MAX = 3,
362 struct perf_record_stat_config_entry {
367 struct perf_record_stat_config {
368 struct perf_event_header header;
370 struct perf_record_stat_config_entry data[];
373 struct perf_record_stat {
374 struct perf_event_header header;
390 struct perf_record_stat_round {
391 struct perf_event_header header;
396 struct perf_record_time_conv {
397 struct perf_event_header header;
403 __u8 cap_user_time_zero;
404 __u8 cap_user_time_short;
405 __u8 reserved[6]; /* For alignment */
408 struct perf_record_header_feature {
409 struct perf_event_header header;
414 struct perf_record_compressed {
415 struct perf_event_header header;
419 enum perf_user_event_type { /* above any possible kernel type */
420 PERF_RECORD_USER_TYPE_START = 64,
421 PERF_RECORD_HEADER_ATTR = 64,
422 PERF_RECORD_HEADER_EVENT_TYPE = 65, /* deprecated */
423 PERF_RECORD_HEADER_TRACING_DATA = 66,
424 PERF_RECORD_HEADER_BUILD_ID = 67,
425 PERF_RECORD_FINISHED_ROUND = 68,
426 PERF_RECORD_ID_INDEX = 69,
427 PERF_RECORD_AUXTRACE_INFO = 70,
428 PERF_RECORD_AUXTRACE = 71,
429 PERF_RECORD_AUXTRACE_ERROR = 72,
430 PERF_RECORD_THREAD_MAP = 73,
431 PERF_RECORD_CPU_MAP = 74,
432 PERF_RECORD_STAT_CONFIG = 75,
433 PERF_RECORD_STAT = 76,
434 PERF_RECORD_STAT_ROUND = 77,
435 PERF_RECORD_EVENT_UPDATE = 78,
436 PERF_RECORD_TIME_CONV = 79,
437 PERF_RECORD_HEADER_FEATURE = 80,
438 PERF_RECORD_COMPRESSED = 81,
439 PERF_RECORD_FINISHED_INIT = 82,
440 PERF_RECORD_HEADER_MAX
444 struct perf_event_header header;
445 struct perf_record_mmap mmap;
446 struct perf_record_mmap2 mmap2;
447 struct perf_record_comm comm;
448 struct perf_record_namespaces namespaces;
449 struct perf_record_cgroup cgroup;
450 struct perf_record_fork fork;
451 struct perf_record_lost lost;
452 struct perf_record_lost_samples lost_samples;
453 struct perf_record_read read;
454 struct perf_record_throttle throttle;
455 struct perf_record_sample sample;
456 struct perf_record_bpf_event bpf;
457 struct perf_record_ksymbol ksymbol;
458 struct perf_record_text_poke_event text_poke;
459 struct perf_record_header_attr attr;
460 struct perf_record_event_update event_update;
461 struct perf_record_header_event_type event_type;
462 struct perf_record_header_tracing_data tracing_data;
463 struct perf_record_header_build_id build_id;
464 struct perf_record_id_index id_index;
465 struct perf_record_auxtrace_info auxtrace_info;
466 struct perf_record_auxtrace auxtrace;
467 struct perf_record_auxtrace_error auxtrace_error;
468 struct perf_record_aux aux;
469 struct perf_record_itrace_start itrace_start;
470 struct perf_record_aux_output_hw_id aux_output_hw_id;
471 struct perf_record_switch context_switch;
472 struct perf_record_thread_map thread_map;
473 struct perf_record_cpu_map cpu_map;
474 struct perf_record_stat_config stat_config;
475 struct perf_record_stat stat;
476 struct perf_record_stat_round stat_round;
477 struct perf_record_time_conv time_conv;
478 struct perf_record_header_feature feat;
479 struct perf_record_compressed pack;
482 #endif /* __LIBPERF_EVENT_H */