1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
7 option optimize_for = LITE_RUNTIME;
11 // Stores information from a perf session generated via running:
14 // See $kernel/tools/perf/design.txt for more details.
16 // Please do not modify this protobuf directly, except to mirror the upstream
17 // version found here:
18 // https://chromium.googlesource.com/chromiumos/platform/chromiumos-wide-profiling/+/master/perf_data.proto
19 // with some fields omitted for privacy reasons. Because it is a read-only copy
20 // of the upstream protobuf, "Next tag:" comments are also absent.
22 message PerfDataProto {
24 // Perf event attribute. Stores the event description.
25 // This data structure is defined in the linux kernel:
26 // $kernel/tools/perf/util/event.h.
27 message PerfEventAttr {
28 // Type of the event. Type is an enumeration and can be:
29 // IP: an instruction-pointer was stored in the event.
30 // MMAP: a DLL was loaded.
31 // FORK: a process was forked.
33 optional uint32 type = 1;
35 // Size of the event data in bytes.
36 optional uint32 size = 2;
38 // The config stores the CPU-specific counter information.
39 optional uint64 config = 3;
41 // Sample period of the event. Indicates how often the event is
42 // triggered in terms of # of events. After |sample_period| events, an event
43 // will be recorded and stored.
44 optional uint64 sample_period = 4;
46 // Sample frequency of the event. Indicates how often the event is
47 // triggered in terms of # per second. The kernel will try to record
48 // |sample_freq| events per second.
49 optional uint64 sample_freq = 5;
51 // Sample type is a bitfield that records attributes of the sample. Example,
52 // whether an entire callchain was recorded, etc.
53 optional uint64 sample_type = 6;
55 // Bitfield that indicates whether reads on the counter will return the
56 // total time enabled and total time running.
57 optional uint64 read_format = 7;
59 // Indicates whether the counter starts off disabled.
60 optional bool disabled = 8;
62 // Indicates whether child processes inherit the counter.
63 optional bool inherit = 9;
65 // Indicates whether the counter is pinned to a particular CPU.
66 optional bool pinned = 10;
68 // Indicates whether this counter's group has exclusive access to the CPU's
70 optional bool exclusive = 11;
72 // The following bits restrict events to be counted when the CPU is in user,
73 // kernel, hypervisor or idle modes.
74 optional bool exclude_user = 12;
75 optional bool exclude_kernel = 13;
76 optional bool exclude_hv = 14;
77 optional bool exclude_idle = 15;
79 // Indicates whether mmap events should be recorded.
80 optional bool mmap = 16;
82 // Indicates whether process comm information should be recorded upon
84 optional bool comm = 17;
86 // Indicates that we are in frequency mode, not period mode.
87 optional bool freq = 18;
89 // Indicates whether we have per-task counts.
90 optional bool inherit_stat = 19;
92 // Indicates whether we enable perf events after an exec() function call.
93 optional bool enable_on_exec = 20;
95 // Indicates whether we trace fork/exit.
96 optional bool task = 21;
98 // Indicates whether we are using a watermark to wake up.
99 optional bool watermark = 22;
101 // CPUs often "skid" when recording events. That means the instruction
102 // pointer may not be the same as the one that caused the counter overflow.
103 // Indicates the capabilities of the CPU in terms of recording precise
104 // instruction pointer.
105 optional uint32 precise_ip = 23;
107 // Indicates whether we have non-exec mmap data.
108 optional bool mmap_data = 24;
110 // If set, all the event types will have the same sample_type.
111 optional bool sample_id_all = 25;
113 // Indicates whether we are counting events from the host (when running a
115 optional bool exclude_host = 26;
117 // Exclude events that happen on a guest OS.
118 optional bool exclude_guest = 27;
120 // Contains the number of events after which we wake up.
121 optional uint32 wakeup_events = 28;
123 // Contains the number of bytes after which we wake up.
124 optional uint32 wakeup_watermark = 29;
126 // Information about the type of the breakpoint.
127 optional uint32 bp_type = 30;
129 // Contains the breakpoint address.
130 optional uint64 bp_addr = 31;
132 // This is an extension of config (see above).
133 optional uint64 config1 = 32;
135 // The length of the breakpoint data in bytes.
136 optional uint64 bp_len = 33;
138 // This is an extension of config (see above).
139 optional uint64 config2 = 34;
141 // Contains the type of branch, example: user, kernel, call, return, etc.
142 optional uint64 branch_sample_type = 35;
145 // Describes a perf.data file attribute.
146 message PerfFileAttr {
147 optional PerfEventAttr attr = 1;
149 // List of perf file attribute ids. Each id describes an event.
150 repeated uint64 ids = 2;
153 // This message contains information about a perf sample itself, as opposed to
154 // a perf event captured by a sample.
156 // Process ID / thread ID from which this sample was taken.
157 optional uint32 pid = 1;
158 optional uint32 tid = 2;
160 // Time this sample was taken (NOT the same as an event time).
161 // It is the number of nanoseconds since bootup.
162 optional uint64 sample_time_ns = 3;
164 // The ID of the sample's event type (cycles, instructions, etc).
165 // The event type IDs are defined in PerfFileAttr.
166 optional uint64 id = 4;
168 // The CPU on which this sample was taken.
169 optional uint32 cpu = 5;
174 optional uint32 pid = 1;
177 optional uint32 tid = 2;
179 // Comm string's md5 prefix.
180 // The comm string was field 3 and has been intentionally left out.
181 optional uint64 comm_md5_prefix = 4;
183 // Time the sample was taken.
184 // Deprecated, use |sample_info| instead.
185 optional uint64 sample_time = 5 [deprecated=true];
187 // Info about the perf sample containing this event.
188 optional SampleInfo sample_info = 6;
193 optional uint32 pid = 1;
196 optional uint32 tid = 2;
199 optional uint64 start = 3;
202 optional uint64 len = 4;
205 optional uint64 pgoff = 5;
207 // Filename's md5 prefix.
208 // The filename was field 6 and has been intentionally left out.
209 optional uint64 filename_md5_prefix = 7;
211 // Info about the perf sample containing this event.
212 optional SampleInfo sample_info = 8;
215 message BranchStackEntry {
216 // Branch source address.
217 optional uint64 from_ip = 1;
219 // Branch destination address.
220 optional uint64 to_ip = 2;
222 // Indicates a mispredicted branch.
223 optional bool mispredicted = 3;
226 message SampleEvent {
227 // Instruction pointer.
228 optional uint64 ip = 1;
231 optional uint32 pid = 2;
234 optional uint32 tid = 3;
236 // The time after boot when the sample was recorded, in nanoseconds.
237 optional uint64 sample_time_ns = 4;
239 // The address of the sample.
240 optional uint64 addr = 5;
242 // The id of the sample.
243 optional uint64 id = 6;
245 // The stream id of the sample.
246 optional uint64 stream_id = 7;
248 // The period of the sample.
249 optional uint64 period = 8;
251 // The CPU where the event was recorded.
252 optional uint32 cpu = 9;
254 // The raw size of the event in bytes.
255 optional uint32 raw_size = 10;
257 // Sample callchain info.
258 repeated uint64 callchain = 11;
260 // Branch stack info.
261 repeated BranchStackEntry branch_stack = 12;
264 // ForkEvent is used for both FORK and EXIT events, which have the same data
265 // format. We don't want to call this "ForkOrExitEvent", in case a separate
266 // exit event is introduced in the future.
268 // Forked process ID.
269 optional uint32 pid = 1;
271 // Parent process ID.
272 optional uint32 ppid = 2;
274 // Forked process thread ID.
275 optional uint32 tid = 3;
277 // Parent process thread ID.
278 optional uint32 ptid = 4;
280 // Time of fork event in nanoseconds since bootup.
281 optional uint64 fork_time_ns = 5;
283 // Info about the perf sample containing this event.
284 optional SampleInfo sample_info = 11;
287 message EventHeader {
289 optional uint32 type = 1;
290 optional uint32 misc = 2;
292 optional uint32 size = 3;
296 optional EventHeader header = 1;
298 optional MMapEvent mmap_event = 2;
299 optional SampleEvent sample_event = 3;
300 optional CommEvent comm_event = 4;
301 optional ForkEvent fork_event = 5;
304 message PerfEventStats {
305 // Total number of events read from perf data.
306 optional uint32 num_events_read = 1;
308 // Total number of various types of events.
309 optional uint32 num_sample_events = 2;
310 optional uint32 num_mmap_events = 3;
311 optional uint32 num_fork_events = 4;
312 optional uint32 num_exit_events = 5;
314 // Number of sample events that were successfully mapped by the address
315 // mapper, a quipper module that is used to obscure addresses and convert
316 // them to DSO name + offset. Sometimes it fails to process sample events.
317 // This field allows us to track the success rate of the address mapper.
318 optional uint32 num_sample_events_mapped = 6;
320 // Whether address remapping was enabled.
321 optional bool did_remap = 7;
324 message PerfBuildID {
325 // Misc field in perf_event_header.
326 // Indicates whether the file is mapped in kernel mode or user mode.
327 optional uint32 misc = 1;
330 optional uint32 pid = 2;
332 // Build id. Should always contain kBuildIDArraySize bytes of data.
333 // perf_reader.h in Chrome OS defines kBuildIDArraySize = 20.
334 optional bytes build_hash = 3;
336 // Filename Md5sum prefix.
337 // The filename was field 4 and has been intentionally left out.
338 optional uint64 filename_md5_prefix = 5;
341 repeated PerfFileAttr file_attrs = 1;
342 repeated PerfEvent events = 2;
344 // Time when quipper generated this perf data / protobuf, given as seconds
346 optional uint64 timestamp_sec = 3;
348 // Records some stats about the serialized perf events.
349 optional PerfEventStats stats = 4;
351 // Not added from original: repeated uint64 metadata_mask = 5;
353 // Build ID metadata.
354 repeated PerfBuildID build_ids = 7;
356 // Not added from original: repeated PerfUint32Metadata uint32_metadata = 8;
357 // Not added from original: repeated PerfUint64Metadata uint64_metadata = 9;
358 // Not added from original:
359 // optional PerfCPUTopologyMetadata cpu_topology = 11;
360 // Not added from original:
361 // repeated PerfNodeTopologyMetadata numa_topology = 12;
363 message StringMetadata {
364 message StringAndMd5sumPrefix {
365 // The string value was field 1 and has been intentionally left out.
367 // The string value's md5sum prefix.
368 optional uint64 value_md5_prefix = 2;
371 // Not added from original: optional StringAndMd5sumPrefix hostname = 1;
372 // Not added from original:
373 // optional StringAndMd5sumPrefix kernel_version =2;
374 // Not added from original: optional StringAndMd5sumPrefix perf_version = 3;
375 // Not added from original: optional StringAndMd5sumPrefix architecture = 4;
376 // Not added from original:
377 // optional StringAndMd5sumPrefix cpu_description = 5;
378 // Not added from original: optional StringAndMd5sumPrefix cpu_id = 6;
379 // Not added from original:
380 // repeated StringAndMd5sumPrefix perf_command_line_token = 7;
382 // The command line stored as a single string.
383 optional StringAndMd5sumPrefix perf_command_line_whole = 8;
386 // All the string metadata from the perf data file.
387 optional StringMetadata string_metadata = 13;