Skip to content

Commit 3872dd5

Browse files
committed
Fix volatile errors
1 parent c2cdd83 commit 3872dd5

File tree

5 files changed

+410
-2
lines changed

5 files changed

+410
-2
lines changed

runtime/include/bpftime_epoll.h

Lines changed: 380 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
#pragma once
2+
3+
#include <cstdint>
24
/*
35
Keeping declaration for structs that are specific to linux
46
structures added from
@@ -213,3 +215,381 @@ struct perf_event_mmap_page {
213215
};
214216

215217

218+
enum perf_event_type {
219+
220+
/*
221+
* If perf_event_attr.sample_id_all is set then all event types will
222+
* have the sample_type selected fields related to where/when
223+
* (identity) an event took place (TID, TIME, ID, STREAM_ID, CPU,
224+
* IDENTIFIER) described in PERF_RECORD_SAMPLE below, it will be stashed
225+
* just after the perf_event_header and the fields already present for
226+
* the existing fields, i.e. at the end of the payload. That way a newer
227+
* perf.data file will be supported by older perf tools, with these new
228+
* optional fields being ignored.
229+
*
230+
* struct sample_id {
231+
* { u32 pid, tid; } && PERF_SAMPLE_TID
232+
* { u64 time; } && PERF_SAMPLE_TIME
233+
* { u64 id; } && PERF_SAMPLE_ID
234+
* { u64 stream_id;} && PERF_SAMPLE_STREAM_ID
235+
* { u32 cpu, res; } && PERF_SAMPLE_CPU
236+
* { u64 id; } && PERF_SAMPLE_IDENTIFIER
237+
* } && perf_event_attr::sample_id_all
238+
*
239+
* Note that PERF_SAMPLE_IDENTIFIER duplicates PERF_SAMPLE_ID. The
240+
* advantage of PERF_SAMPLE_IDENTIFIER is that its position is fixed
241+
* relative to header.size.
242+
*/
243+
244+
/*
245+
* The MMAP events record the PROT_EXEC mappings so that we can
246+
* correlate userspace IPs to code. They have the following structure:
247+
*
248+
* struct {
249+
* struct perf_event_header header;
250+
*
251+
* u32 pid, tid;
252+
* u64 addr;
253+
* u64 len;
254+
* u64 pgoff;
255+
* char filename[];
256+
* struct sample_id sample_id;
257+
* };
258+
*/
259+
PERF_RECORD_MMAP = 1,
260+
261+
/*
262+
* struct {
263+
* struct perf_event_header header;
264+
* u64 id;
265+
* u64 lost;
266+
* struct sample_id sample_id;
267+
* };
268+
*/
269+
PERF_RECORD_LOST = 2,
270+
271+
/*
272+
* struct {
273+
* struct perf_event_header header;
274+
*
275+
* u32 pid, tid;
276+
* char comm[];
277+
* struct sample_id sample_id;
278+
* };
279+
*/
280+
PERF_RECORD_COMM = 3,
281+
282+
/*
283+
* struct {
284+
* struct perf_event_header header;
285+
* u32 pid, ppid;
286+
* u32 tid, ptid;
287+
* u64 time;
288+
* struct sample_id sample_id;
289+
* };
290+
*/
291+
PERF_RECORD_EXIT = 4,
292+
293+
/*
294+
* struct {
295+
* struct perf_event_header header;
296+
* u64 time;
297+
* u64 id;
298+
* u64 stream_id;
299+
* struct sample_id sample_id;
300+
* };
301+
*/
302+
PERF_RECORD_THROTTLE = 5,
303+
PERF_RECORD_UNTHROTTLE = 6,
304+
305+
/*
306+
* struct {
307+
* struct perf_event_header header;
308+
* u32 pid, ppid;
309+
* u32 tid, ptid;
310+
* u64 time;
311+
* struct sample_id sample_id;
312+
* };
313+
*/
314+
PERF_RECORD_FORK = 7,
315+
316+
/*
317+
* struct {
318+
* struct perf_event_header header;
319+
* u32 pid, tid;
320+
*
321+
* struct read_format values;
322+
* struct sample_id sample_id;
323+
* };
324+
*/
325+
PERF_RECORD_READ = 8,
326+
327+
/*
328+
* struct {
329+
* struct perf_event_header header;
330+
*
331+
* #
332+
* # Note that PERF_SAMPLE_IDENTIFIER duplicates PERF_SAMPLE_ID.
333+
* # The advantage of PERF_SAMPLE_IDENTIFIER is that its position
334+
* # is fixed relative to header.
335+
* #
336+
*
337+
* { u64 id; } && PERF_SAMPLE_IDENTIFIER
338+
* { u64 ip; } && PERF_SAMPLE_IP
339+
* { u32 pid, tid; } && PERF_SAMPLE_TID
340+
* { u64 time; } && PERF_SAMPLE_TIME
341+
* { u64 addr; } && PERF_SAMPLE_ADDR
342+
* { u64 id; } && PERF_SAMPLE_ID
343+
* { u64 stream_id;} && PERF_SAMPLE_STREAM_ID
344+
* { u32 cpu, res; } && PERF_SAMPLE_CPU
345+
* { u64 period; } && PERF_SAMPLE_PERIOD
346+
*
347+
* { struct read_format values; } && PERF_SAMPLE_READ
348+
*
349+
* { u64 nr,
350+
* u64 ips[nr]; } && PERF_SAMPLE_CALLCHAIN
351+
*
352+
* #
353+
* # The RAW record below is opaque data wrt the ABI
354+
* #
355+
* # That is, the ABI doesn't make any promises wrt to
356+
* # the stability of its content, it may vary depending
357+
* # on event, hardware, kernel version and phase of
358+
* # the moon.
359+
* #
360+
* # In other words, PERF_SAMPLE_RAW contents are not an ABI.
361+
* #
362+
*
363+
* { u32 size;
364+
* char data[size];}&& PERF_SAMPLE_RAW
365+
*
366+
* { u64 nr;
367+
* { u64 hw_idx; } && PERF_SAMPLE_BRANCH_HW_INDEX
368+
* { u64 from, to, flags } lbr[nr];
369+
* } && PERF_SAMPLE_BRANCH_STACK
370+
*
371+
* { u64 abi; # enum perf_sample_regs_abi
372+
* u64 regs[weight(mask)]; } && PERF_SAMPLE_REGS_USER
373+
*
374+
* { u64 size;
375+
* char data[size];
376+
* u64 dyn_size; } && PERF_SAMPLE_STACK_USER
377+
*
378+
* { union perf_sample_weight
379+
* {
380+
* u64 full; && PERF_SAMPLE_WEIGHT
381+
* #if defined(__LITTLE_ENDIAN_BITFIELD)
382+
* struct {
383+
* u32 var1_dw;
384+
* u16 var2_w;
385+
* u16 var3_w;
386+
* } && PERF_SAMPLE_WEIGHT_STRUCT
387+
* #elif defined(__BIG_ENDIAN_BITFIELD)
388+
* struct {
389+
* u16 var3_w;
390+
* u16 var2_w;
391+
* u32 var1_dw;
392+
* } && PERF_SAMPLE_WEIGHT_STRUCT
393+
* #endif
394+
* }
395+
* }
396+
* { u64 data_src; } && PERF_SAMPLE_DATA_SRC
397+
* { u64 transaction; } && PERF_SAMPLE_TRANSACTION
398+
* { u64 abi; # enum perf_sample_regs_abi
399+
* u64 regs[weight(mask)]; } && PERF_SAMPLE_REGS_INTR
400+
* { u64 phys_addr;} && PERF_SAMPLE_PHYS_ADDR
401+
* { u64 size;
402+
* char data[size]; } && PERF_SAMPLE_AUX
403+
* { u64 data_page_size;} && PERF_SAMPLE_DATA_PAGE_SIZE
404+
* { u64 code_page_size;} && PERF_SAMPLE_CODE_PAGE_SIZE
405+
* };
406+
*/
407+
PERF_RECORD_SAMPLE = 9,
408+
409+
/*
410+
* The MMAP2 records are an augmented version of MMAP, they add
411+
* maj, min, ino numbers to be used to uniquely identify each mapping
412+
*
413+
* struct {
414+
* struct perf_event_header header;
415+
*
416+
* u32 pid, tid;
417+
* u64 addr;
418+
* u64 len;
419+
* u64 pgoff;
420+
* union {
421+
* struct {
422+
* u32 maj;
423+
* u32 min;
424+
* u64 ino;
425+
* u64 ino_generation;
426+
* };
427+
* struct {
428+
* u8 build_id_size;
429+
* u8 __reserved_1;
430+
* u16 __reserved_2;
431+
* u8 build_id[20];
432+
* };
433+
* };
434+
* u32 prot, flags;
435+
* char filename[];
436+
* struct sample_id sample_id;
437+
* };
438+
*/
439+
PERF_RECORD_MMAP2 = 10,
440+
441+
/*
442+
* Records that new data landed in the AUX buffer part.
443+
*
444+
* struct {
445+
* struct perf_event_header header;
446+
*
447+
* u64 aux_offset;
448+
* u64 aux_size;
449+
* u64 flags;
450+
* struct sample_id sample_id;
451+
* };
452+
*/
453+
PERF_RECORD_AUX = 11,
454+
455+
/*
456+
* Indicates that instruction trace has started
457+
*
458+
* struct {
459+
* struct perf_event_header header;
460+
* u32 pid;
461+
* u32 tid;
462+
* struct sample_id sample_id;
463+
* };
464+
*/
465+
PERF_RECORD_ITRACE_START = 12,
466+
467+
/*
468+
* Records the dropped/lost sample number.
469+
*
470+
* struct {
471+
* struct perf_event_header header;
472+
*
473+
* u64 lost;
474+
* struct sample_id sample_id;
475+
* };
476+
*/
477+
PERF_RECORD_LOST_SAMPLES = 13,
478+
479+
/*
480+
* Records a context switch in or out (flagged by
481+
* PERF_RECORD_MISC_SWITCH_OUT). See also
482+
* PERF_RECORD_SWITCH_CPU_WIDE.
483+
*
484+
* struct {
485+
* struct perf_event_header header;
486+
* struct sample_id sample_id;
487+
* };
488+
*/
489+
PERF_RECORD_SWITCH = 14,
490+
491+
/*
492+
* CPU-wide version of PERF_RECORD_SWITCH with next_prev_pid and
493+
* next_prev_tid that are the next (switching out) or previous
494+
* (switching in) pid/tid.
495+
*
496+
* struct {
497+
* struct perf_event_header header;
498+
* u32 next_prev_pid;
499+
* u32 next_prev_tid;
500+
* struct sample_id sample_id;
501+
* };
502+
*/
503+
PERF_RECORD_SWITCH_CPU_WIDE = 15,
504+
505+
/*
506+
* struct {
507+
* struct perf_event_header header;
508+
* u32 pid;
509+
* u32 tid;
510+
* u64 nr_namespaces;
511+
* { u64 dev, inode; } [nr_namespaces];
512+
* struct sample_id sample_id;
513+
* };
514+
*/
515+
PERF_RECORD_NAMESPACES = 16,
516+
517+
/*
518+
* Record ksymbol register/unregister events:
519+
*
520+
* struct {
521+
* struct perf_event_header header;
522+
* u64 addr;
523+
* u32 len;
524+
* u16 ksym_type;
525+
* u16 flags;
526+
* char name[];
527+
* struct sample_id sample_id;
528+
* };
529+
*/
530+
PERF_RECORD_KSYMBOL = 17,
531+
532+
/*
533+
* Record bpf events:
534+
* enum perf_bpf_event_type {
535+
* PERF_BPF_EVENT_UNKNOWN = 0,
536+
* PERF_BPF_EVENT_PROG_LOAD = 1,
537+
* PERF_BPF_EVENT_PROG_UNLOAD = 2,
538+
* };
539+
*
540+
* struct {
541+
* struct perf_event_header header;
542+
* u16 type;
543+
* u16 flags;
544+
* u32 id;
545+
* u8 tag[BPF_TAG_SIZE];
546+
* struct sample_id sample_id;
547+
* };
548+
*/
549+
PERF_RECORD_BPF_EVENT = 18,
550+
551+
/*
552+
* struct {
553+
* struct perf_event_header header;
554+
* u64 id;
555+
* char path[];
556+
* struct sample_id sample_id;
557+
* };
558+
*/
559+
PERF_RECORD_CGROUP = 19,
560+
561+
/*
562+
* Records changes to kernel text i.e. self-modified code. 'old_len' is
563+
* the number of old bytes, 'new_len' is the number of new bytes. Either
564+
* 'old_len' or 'new_len' may be zero to indicate, for example, the
565+
* addition or removal of a trampoline. 'bytes' contains the old bytes
566+
* followed immediately by the new bytes.
567+
*
568+
* struct {
569+
* struct perf_event_header header;
570+
* u64 addr;
571+
* u16 old_len;
572+
* u16 new_len;
573+
* u8 bytes[];
574+
* struct sample_id sample_id;
575+
* };
576+
*/
577+
PERF_RECORD_TEXT_POKE = 20,
578+
579+
/*
580+
* Data written to the AUX area by hardware due to aux_output, may need
581+
* to be matched to the event by an architecture-specific hardware ID.
582+
* This records the hardware ID, but requires sample_id to provide the
583+
* event ID. e.g. Intel PT uses this record to disambiguate PEBS-via-PT
584+
* records from multiple events.
585+
*
586+
* struct {
587+
* struct perf_event_header header;
588+
* u64 hw_id;
589+
* struct sample_id sample_id;
590+
* };
591+
*/
592+
PERF_RECORD_AUX_OUTPUT_HW_ID = 21,
593+
594+
PERF_RECORD_MAX, /* non-ABI */
595+
};

0 commit comments

Comments
 (0)