Upstream version 7.36.149.0
[platform/framework/web/crosswalk.git] / src / components / metrics / proto / perf_data.proto
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.
4
5 syntax = "proto2";
6
7 option optimize_for = LITE_RUNTIME;
8
9 package metrics;
10
11 // Stores information from a perf session generated via running:
12 // "perf record"
13 //
14 // See $kernel/tools/perf/design.txt for more details.
15
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.
21
22 message PerfDataProto {
23
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.
32     // etc.
33     optional uint32 type = 1;
34
35     // Size of the event data in bytes.
36     optional uint32 size = 2;
37
38     // The config stores the CPU-specific counter information.
39     optional uint64 config = 3;
40
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;
45
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;
50
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;
54
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;
58
59     // Indicates whether the counter starts off disabled.
60     optional bool disabled = 8;
61
62     // Indicates whether child processes inherit the counter.
63     optional bool inherit = 9;
64
65     // Indicates whether the counter is pinned to a particular CPU.
66     optional bool pinned = 10;
67
68     // Indicates whether this counter's group has exclusive access to the CPU's
69     // counters.
70     optional bool exclusive = 11;
71
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;
78
79     // Indicates whether mmap events should be recorded.
80     optional bool mmap = 16;
81
82     // Indicates whether process comm information should be recorded upon
83     // process creation.
84     optional bool comm = 17;
85
86     // Indicates that we are in frequency mode, not period mode.
87     optional bool freq = 18;
88
89     // Indicates whether we have per-task counts.
90     optional bool inherit_stat = 19;
91
92     // Indicates whether we enable perf events after an exec() function call.
93     optional bool enable_on_exec = 20;
94
95     // Indicates whether we trace fork/exit.
96     optional bool task = 21;
97
98     // Indicates whether we are using a watermark to wake up.
99     optional bool watermark = 22;
100
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;
106
107     // Indicates whether we have non-exec mmap data.
108     optional bool mmap_data = 24;
109
110     // If set, all the event types will have the same sample_type.
111     optional bool sample_id_all = 25;
112
113     // Indicates whether we are counting events from the host (when running a
114     // VM).
115     optional bool exclude_host = 26;
116
117     // Exclude events that happen on a guest OS.
118     optional bool exclude_guest = 27;
119
120     // Contains the number of events after which we wake up.
121     optional uint32 wakeup_events = 28;
122
123     // Contains the number of bytes after which we wake up.
124     optional uint32 wakeup_watermark = 29;
125
126     // Information about the type of the breakpoint.
127     optional uint32 bp_type = 30;
128
129     // Contains the breakpoint address.
130     optional uint64 bp_addr = 31;
131
132     // This is an extension of config (see above).
133     optional uint64 config1 = 32;
134
135     // The length of the breakpoint data in bytes.
136     optional uint64 bp_len = 33;
137
138     // This is an extension of config (see above).
139     optional uint64 config2 = 34;
140
141     // Contains the type of branch, example: user, kernel, call, return, etc.
142     optional uint64 branch_sample_type = 35;
143   }
144
145   // Describes a perf.data file attribute.
146   message PerfFileAttr {
147     optional PerfEventAttr attr = 1;
148
149     // List of perf file attribute ids. Each id describes an event.
150     repeated uint64 ids = 2;
151   }
152
153   // This message contains information about a perf sample itself, as opposed to
154   // a perf event captured by a sample.
155   message SampleInfo {
156     // Process ID / thread ID from which this sample was taken.
157     optional uint32 pid = 1;
158     optional uint32 tid = 2;
159
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;
163
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;
167
168     // The CPU on which this sample was taken.
169     optional uint32 cpu = 5;
170   }
171
172   message CommEvent {
173     // Process id.
174     optional uint32 pid = 1;
175
176     // Thread id.
177     optional uint32 tid = 2;
178
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;
182
183     // Time the sample was taken.
184     // Deprecated, use |sample_info| instead.
185     optional uint64 sample_time = 5 [deprecated=true];
186
187     // Info about the perf sample containing this event.
188     optional SampleInfo sample_info = 6;
189   }
190
191   message MMapEvent {
192     // Process id.
193     optional uint32 pid = 1;
194
195     // Thread id.
196     optional uint32 tid = 2;
197
198     // Start address.
199     optional uint64 start = 3;
200
201     // Length.
202     optional uint64 len = 4;
203
204     // PG Offset.
205     optional uint64 pgoff = 5;
206
207     // Filename's md5 prefix.
208     // The filename was field 6 and has been intentionally left out.
209     optional uint64 filename_md5_prefix = 7;
210
211     // Info about the perf sample containing this event.
212     optional SampleInfo sample_info = 8;
213   }
214
215   message BranchStackEntry {
216     // Branch source address.
217     optional uint64 from_ip = 1;
218
219     // Branch destination address.
220     optional uint64 to_ip = 2;
221
222     // Indicates a mispredicted branch.
223     optional bool mispredicted = 3;
224   }
225
226   message SampleEvent {
227     // Instruction pointer.
228     optional uint64 ip = 1;
229
230     // Process id.
231     optional uint32 pid = 2;
232
233     // Thread id.
234     optional uint32 tid = 3;
235
236     // The time after boot when the sample was recorded, in nanoseconds.
237     optional uint64 sample_time_ns = 4;
238
239     // The address of the sample.
240     optional uint64 addr = 5;
241
242     // The id of the sample.
243     optional uint64 id = 6;
244
245     // The stream id of the sample.
246     optional uint64 stream_id = 7;
247
248     // The period of the sample.
249     optional uint64 period = 8;
250
251     // The CPU where the event was recorded.
252     optional uint32 cpu = 9;
253
254     // The raw size of the event in bytes.
255     optional uint32 raw_size = 10;
256
257     // Sample callchain info.
258     repeated uint64 callchain = 11;
259
260     // Branch stack info.
261     repeated BranchStackEntry branch_stack = 12;
262   }
263
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.
267   message ForkEvent {
268     // Forked process ID.
269     optional uint32 pid = 1;
270
271     // Parent process ID.
272     optional uint32 ppid = 2;
273
274     // Forked process thread ID.
275     optional uint32 tid = 3;
276
277     // Parent process thread ID.
278     optional uint32 ptid = 4;
279
280     // Time of fork event in nanoseconds since bootup.
281     optional uint64 fork_time_ns = 5;
282
283     // Info about the perf sample containing this event.
284     optional SampleInfo sample_info = 11;
285   }
286
287   message EventHeader {
288     // Type of event.
289     optional uint32 type = 1;
290     optional uint32 misc = 2;
291     // Size of event.
292     optional uint32 size = 3;
293   }
294
295   message PerfEvent {
296     optional EventHeader header = 1;
297
298     optional MMapEvent mmap_event = 2;
299     optional SampleEvent sample_event = 3;
300     optional CommEvent comm_event = 4;
301     optional ForkEvent fork_event = 5;
302   }
303
304   message PerfEventStats {
305     // Total number of events read from perf data.
306     optional uint32 num_events_read = 1;
307
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;
313
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;
319
320     // Whether address remapping was enabled.
321     optional bool did_remap = 7;
322   }
323
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;
328
329     // Process ID.
330     optional uint32 pid = 2;
331
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;
335
336     // Filename Md5sum prefix.
337     // The filename was field 4 and has been intentionally left out.
338     optional uint64 filename_md5_prefix = 5;
339   }
340
341   repeated PerfFileAttr file_attrs = 1;
342   repeated PerfEvent events = 2;
343
344   // Time when quipper generated this perf data / protobuf, given as seconds
345   // since the epoch.
346   optional uint64 timestamp_sec = 3;
347
348   // Records some stats about the serialized perf events.
349   optional PerfEventStats stats = 4;
350
351   // Not added from original: repeated uint64 metadata_mask = 5;
352
353   // Build ID metadata.
354   repeated PerfBuildID build_ids = 7;
355
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;
362
363   message StringMetadata {
364     message StringAndMd5sumPrefix {
365       // The string value was field 1 and has been intentionally left out.
366
367       // The string value's md5sum prefix.
368       optional uint64 value_md5_prefix = 2;
369     }
370
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;
381
382     // The command line stored as a single string.
383     optional StringAndMd5sumPrefix perf_command_line_whole = 8;
384   }
385
386   // All the string metadata from the perf data file.
387   optional StringMetadata string_metadata = 13;
388 }