2 * @file pe_profiling/operf_event.h
3 * Definitions of structures and methods for handling perf_event data
6 * @remark Copyright 2011 OProfile authors
7 * @remark Read the file COPYING
9 * Created on: Dec 7, 2011
10 * @author Maynard Johnson
11 * (C) Copyright IBM Corp. 2011
14 #ifndef OPERF_EVENT_H_
15 #define OPERF_EVENT_H_
18 #include <linux/perf_event.h>
23 #define OP_MAX_EVT_NAME_LEN 64
24 #define OP_MAX_UM_NAME_LEN 64
25 #define OP_MAX_UM_NAME_STR_LEN 17
26 #define OP_MAX_NUM_EVENTS 512
29 struct perf_event_header header;
32 unsigned char __more_data[];
36 struct perf_event_header header;
41 char filename[PATH_MAX];
45 struct perf_event_header header;
51 struct perf_event_header header;
58 struct perf_event_header header;
64 struct perf_event_header header;
73 struct perf_event_header header;
77 struct throttle_event {
78 struct perf_event_header header;
84 typedef union event_union {
85 struct perf_event_header header;
87 struct mmap_event mmap;
88 struct comm_event comm;
89 struct fork_event fork;
90 struct lost_event lost;
91 struct read_event read;
92 struct sample_event sample;
93 struct throttle_event throttle;
102 struct ip_callchain {
116 struct ip_callchain * callchain;
120 typedef struct operf_event {
121 char name[OP_MAX_EVT_NAME_LEN];
122 // code for perf_events
124 /* Base event code for oprofile sample file management; may be the same as evt_code,
125 * but different for certain architectures (e.g., ppc64). Also, when unit masks
126 * are used, the evt_code to be passed to perf_events includes both the
127 * base code from op_evt_code and the left-shifted unit mask bits.
130 // Make the evt_um and count fields unsigned long to match op_default_event_descr
131 unsigned long evt_um;
132 char um_name[OP_MAX_UM_NAME_LEN];
137 bool mode_specified; /* user specified user or kernel modes */
138 bool umask_specified; /* user specified a unit mask */
139 char um_numeric_val_as_str[OP_MAX_UM_NAME_STR_LEN];
140 bool throttled; /* set to true if the event is ever throttled */
144 u64 offset, file_data_size, file_data_offset, head;
150 struct op_file_section {
155 struct op_file_attr {
156 struct perf_event_attr attr;
157 struct op_file_section ids;
160 struct op_header_evt_info {
161 struct perf_event_attr attr;
162 std::vector<u64> ids;
166 struct OP_file_header {
170 struct op_file_section attrs;
171 struct op_file_section data;
175 struct op_header_evt_info h_attrs[OP_MAX_NUM_EVENTS];
180 /* Some of the above definitions were borrowed from the perf tool's util/event.h file. */
182 #endif /* OPERF_EVENT_H_ */