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;
8 option java_outer_classname = "PerfDataProtos";
9 option java_package = "org.chromium.components.metrics";
13 // Stores information from a perf session generated via running:
16 // See $kernel/tools/perf/design.txt for more details.
18 // Please do not modify this protobuf directly, except to mirror the upstream
19 // version found here:
20 // https://chromium.googlesource.com/chromiumos/platform/chromiumos-wide-profiling/+/master/perf_data.proto
21 // with some fields omitted for privacy reasons. Because it is a read-only copy
22 // of the upstream protobuf, "Next tag:" comments are also absent.
24 message PerfDataProto {
26 // Perf event attribute. Stores the event description.
27 // This data structure is defined in the linux kernel:
28 // $kernel/tools/perf/util/event.h.
29 message PerfEventAttr {
30 // Type of the event. Type is an enumeration and can be:
31 // IP: an instruction-pointer was stored in the event.
32 // MMAP: a DLL was loaded.
33 // FORK: a process was forked.
35 optional uint32 type = 1;
37 // Size of the event data in bytes.
38 optional uint32 size = 2;
40 // The config stores the CPU-specific counter information.
41 optional uint64 config = 3;
43 // Sample period of the event. Indicates how often the event is
44 // triggered in terms of # of events. After |sample_period| events, an event
45 // will be recorded and stored.
46 optional uint64 sample_period = 4;
48 // Sample frequency of the event. Indicates how often the event is
49 // triggered in terms of # per second. The kernel will try to record
50 // |sample_freq| events per second.
51 optional uint64 sample_freq = 5;
53 // Sample type is a bitfield that records attributes of the sample. Example,
54 // whether an entire callchain was recorded, etc.
55 optional uint64 sample_type = 6;
57 // Bitfield that indicates whether reads on the counter will return the
58 // total time enabled and total time running.
59 optional uint64 read_format = 7;
61 // Indicates whether the counter starts off disabled.
62 optional bool disabled = 8;
64 // Indicates whether child processes inherit the counter.
65 optional bool inherit = 9;
67 // Indicates whether the counter is pinned to a particular CPU.
68 optional bool pinned = 10;
70 // Indicates whether this counter's group has exclusive access to the CPU's
72 optional bool exclusive = 11;
74 // The following bits restrict events to be counted when the CPU is in user,
75 // kernel, hypervisor or idle modes.
76 optional bool exclude_user = 12;
77 optional bool exclude_kernel = 13;
78 optional bool exclude_hv = 14;
79 optional bool exclude_idle = 15;
81 // Indicates whether mmap events should be recorded.
82 optional bool mmap = 16;
84 // Indicates whether process comm information should be recorded upon
86 optional bool comm = 17;
88 // Indicates that we are in frequency mode, not period mode.
89 optional bool freq = 18;
91 // Indicates whether we have per-task counts.
92 optional bool inherit_stat = 19;
94 // Indicates whether we enable perf events after an exec() function call.
95 optional bool enable_on_exec = 20;
97 // Indicates whether we trace fork/exit.
98 optional bool task = 21;
100 // Indicates whether we are using a watermark to wake up.
101 optional bool watermark = 22;
103 // CPUs often "skid" when recording events. That means the instruction
104 // pointer may not be the same as the one that caused the counter overflow.
105 // Indicates the capabilities of the CPU in terms of recording precise
106 // instruction pointer.
107 optional uint32 precise_ip = 23;
109 // Indicates whether we have non-exec mmap data.
110 optional bool mmap_data = 24;
112 // If set, all the event types will have the same sample_type.
113 optional bool sample_id_all = 25;
115 // Indicates whether we are counting events from the host (when running a
117 optional bool exclude_host = 26;
119 // Exclude events that happen on a guest OS.
120 optional bool exclude_guest = 27;
122 // Contains the number of events after which we wake up.
123 optional uint32 wakeup_events = 28;
125 // Contains the number of bytes after which we wake up.
126 optional uint32 wakeup_watermark = 29;
128 // Information about the type of the breakpoint.
129 optional uint32 bp_type = 30;
131 // Contains the breakpoint address.
132 optional uint64 bp_addr = 31;
134 // This is an extension of config (see above).
135 optional uint64 config1 = 32;
137 // The length of the breakpoint data in bytes.
138 optional uint64 bp_len = 33;
140 // This is an extension of config (see above).
141 optional uint64 config2 = 34;
143 // Contains the type of branch, example: user, kernel, call, return, etc.
144 optional uint64 branch_sample_type = 35;
147 // Describes a perf.data file attribute.
148 message PerfFileAttr {
149 optional PerfEventAttr attr = 1;
151 // List of perf file attribute ids. Each id describes an event.
152 repeated uint64 ids = 2;
155 // This message contains information about a perf sample itself, as opposed to
156 // a perf event captured by a sample.
158 // Process ID / thread ID from which this sample was taken.
159 optional uint32 pid = 1;
160 optional uint32 tid = 2;
162 // Time this sample was taken (NOT the same as an event time).
163 // It is the number of nanoseconds since bootup.
164 optional uint64 sample_time_ns = 3;
166 // The ID of the sample's event type (cycles, instructions, etc).
167 // The event type IDs are defined in PerfFileAttr.
168 optional uint64 id = 4;
170 // The CPU on which this sample was taken.
171 optional uint32 cpu = 5;
176 optional uint32 pid = 1;
179 optional uint32 tid = 2;
181 // Comm string's md5 prefix.
182 // The comm string was field 3 and has been intentionally left out.
183 optional uint64 comm_md5_prefix = 4;
185 // Time the sample was taken.
186 // Deprecated, use |sample_info| instead.
187 optional uint64 sample_time = 5 [deprecated=true];
189 // Info about the perf sample containing this event.
190 optional SampleInfo sample_info = 6;
195 optional uint32 pid = 1;
198 optional uint32 tid = 2;
201 optional uint64 start = 3;
204 optional uint64 len = 4;
207 optional uint64 pgoff = 5;
209 // Filename's md5 prefix.
210 // The filename was field 6 and has been intentionally left out.
211 optional uint64 filename_md5_prefix = 7;
213 // Info about the perf sample containing this event.
214 optional SampleInfo sample_info = 8;
217 message BranchStackEntry {
218 // Branch source address.
219 optional uint64 from_ip = 1;
221 // Branch destination address.
222 optional uint64 to_ip = 2;
224 // Indicates a mispredicted branch.
225 optional bool mispredicted = 3;
228 message SampleEvent {
229 // Instruction pointer.
230 optional uint64 ip = 1;
233 optional uint32 pid = 2;
236 optional uint32 tid = 3;
238 // The time after boot when the sample was recorded, in nanoseconds.
239 optional uint64 sample_time_ns = 4;
241 // The address of the sample.
242 optional uint64 addr = 5;
244 // The id of the sample.
245 optional uint64 id = 6;
247 // The stream id of the sample.
248 optional uint64 stream_id = 7;
250 // The period of the sample.
251 optional uint64 period = 8;
253 // The CPU where the event was recorded.
254 optional uint32 cpu = 9;
256 // The raw size of the event in bytes.
257 optional uint32 raw_size = 10;
259 // Sample callchain info.
260 repeated uint64 callchain = 11;
262 // Branch stack info.
263 repeated BranchStackEntry branch_stack = 12;
266 // ForkEvent is used for both FORK and EXIT events, which have the same data
267 // format. We don't want to call this "ForkOrExitEvent", in case a separate
268 // exit event is introduced in the future.
270 // Forked process ID.
271 optional uint32 pid = 1;
273 // Parent process ID.
274 optional uint32 ppid = 2;
276 // Forked process thread ID.
277 optional uint32 tid = 3;
279 // Parent process thread ID.
280 optional uint32 ptid = 4;
282 // Time of fork event in nanoseconds since bootup.
283 optional uint64 fork_time_ns = 5;
285 // Info about the perf sample containing this event.
286 optional SampleInfo sample_info = 11;
289 message EventHeader {
291 optional uint32 type = 1;
292 optional uint32 misc = 2;
294 optional uint32 size = 3;
298 optional EventHeader header = 1;
300 optional MMapEvent mmap_event = 2;
301 optional SampleEvent sample_event = 3;
302 optional CommEvent comm_event = 4;
303 optional ForkEvent fork_event = 5;
306 message PerfEventStats {
307 // Total number of events read from perf data.
308 optional uint32 num_events_read = 1;
310 // Total number of various types of events.
311 optional uint32 num_sample_events = 2;
312 optional uint32 num_mmap_events = 3;
313 optional uint32 num_fork_events = 4;
314 optional uint32 num_exit_events = 5;
316 // Number of sample events that were successfully mapped by the address
317 // mapper, a quipper module that is used to obscure addresses and convert
318 // them to DSO name + offset. Sometimes it fails to process sample events.
319 // This field allows us to track the success rate of the address mapper.
320 optional uint32 num_sample_events_mapped = 6;
322 // Whether address remapping was enabled.
323 optional bool did_remap = 7;
326 message PerfBuildID {
327 // Misc field in perf_event_header.
328 // Indicates whether the file is mapped in kernel mode or user mode.
329 optional uint32 misc = 1;
332 optional uint32 pid = 2;
334 // Build id. Should always contain kBuildIDArraySize bytes of data.
335 // perf_reader.h in Chrome OS defines kBuildIDArraySize = 20.
336 optional bytes build_hash = 3;
338 // Filename Md5sum prefix.
339 // The filename was field 4 and has been intentionally left out.
340 optional uint64 filename_md5_prefix = 5;
343 repeated PerfFileAttr file_attrs = 1;
344 repeated PerfEvent events = 2;
346 // Time when quipper generated this perf data / protobuf, given as seconds
348 optional uint64 timestamp_sec = 3;
350 // Records some stats about the serialized perf events.
351 optional PerfEventStats stats = 4;
353 // Not added from original: repeated uint64 metadata_mask = 5;
355 // Build ID metadata.
356 repeated PerfBuildID build_ids = 7;
358 // Not added from original: repeated PerfUint32Metadata uint32_metadata = 8;
359 // Not added from original: repeated PerfUint64Metadata uint64_metadata = 9;
360 // Not added from original:
361 // optional PerfCPUTopologyMetadata cpu_topology = 11;
362 // Not added from original:
363 // repeated PerfNodeTopologyMetadata numa_topology = 12;
365 message StringMetadata {
366 message StringAndMd5sumPrefix {
367 // The string value was field 1 and has been intentionally left out.
369 // The string value's md5sum prefix.
370 optional uint64 value_md5_prefix = 2;
373 // Not added from original: optional StringAndMd5sumPrefix hostname = 1;
374 // Not added from original:
375 // optional StringAndMd5sumPrefix kernel_version =2;
376 // Not added from original: optional StringAndMd5sumPrefix perf_version = 3;
377 // Not added from original: optional StringAndMd5sumPrefix architecture = 4;
378 // Not added from original:
379 // optional StringAndMd5sumPrefix cpu_description = 5;
380 // Not added from original: optional StringAndMd5sumPrefix cpu_id = 6;
381 // Not added from original:
382 // repeated StringAndMd5sumPrefix perf_command_line_token = 7;
384 // The command line stored as a single string.
385 optional StringAndMd5sumPrefix perf_command_line_whole = 8;
388 // All the string metadata from the perf data file.
389 optional StringMetadata string_metadata = 13;