• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1// Copyright (c) 2012 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
5syntax = "proto2";
6option cc_enable_arenas = true;
7
8package quipper;
9
10// Stores information from a perf session generated via running:
11// "perf record"
12//
13// See $kernel/tools/perf/design.txt for more details.
14
15// Next tag: 17
16message PerfDataProto {
17  // Perf event attribute. Stores the event description.
18  // This data structure is defined in the linux kernel:
19  // $kernel/include/uapi/linux/perf_event.h.
20  // Next tag: 42
21  message PerfEventAttr {
22    // Type of the event. Type is an enumeration and can be one of the values
23    // described at: $kernel/include/linux/perf_event.h.
24    // Example types are:
25    // PERF_TYPE_HARDWARE
26    // PERF_TYPE_SOFTWARE, etc.
27    optional uint32 type = 1;
28
29    // Size of the event data in bytes.
30    optional uint32 size = 2;
31
32    // The config stores the CPU-specific counter information.
33    optional uint64 config = 3;
34
35    // Sample period of the event. Indicates how often the event is
36    // triggered in terms of # of events. After |sample_period| events, an event
37    // will be recorded and stored.
38    optional uint64 sample_period = 4;
39
40    // Sample frequency of the event. Indicates how often the event is
41    // triggered in terms of # per second. The kernel will try to record
42    // |sample_freq| events per second.
43    optional uint64 sample_freq = 5;
44
45    // Sample type is a bitfield that records attributes of the sample. Example,
46    // whether an entire callchain was recorded, etc.
47    optional uint64 sample_type = 6;
48
49    // Bitfield that indicates whether reads on the counter will return the
50    // total time enabled and total time running.
51    optional uint64 read_format = 7;
52
53    // Indicates whether the counter starts off disabled.
54    optional bool disabled = 8;
55
56    // Indicates whether child processes inherit the counter.
57    optional bool inherit = 9;
58
59    // Indicates whether the counter is pinned to a particular CPU.
60    optional bool pinned = 10;
61
62    // Indicates whether this counter's group has exclusive access to the CPU's
63    // counters.
64    optional bool exclusive = 11;
65
66    // The following bits restrict events to be counted when the CPU is in user,
67    // kernel, hypervisor or idle modes.
68    optional bool exclude_user = 12;
69    optional bool exclude_kernel = 13;
70    optional bool exclude_hv = 14;
71    optional bool exclude_idle = 15;
72
73    // Indicates whether mmap events should be recorded.
74    optional bool mmap = 16;
75
76    // Indicates whether process comm information should be recorded upon
77    // process creation.
78    optional bool comm = 17;
79
80    // Indicates that we are in frequency mode, not period mode.
81    optional bool freq = 18;
82
83    // Indicates whether we have per-task counts.
84    optional bool inherit_stat = 19;
85
86    // Indicates whether we enable perf events after an exec() function call.
87    optional bool enable_on_exec = 20;
88
89    // Indicates whether we trace fork/exit.
90    optional bool task = 21;
91
92    // Indicates whether we are using a watermark to wake up.
93    optional bool watermark = 22;
94
95    // CPUs often "skid" when recording events. That means the instruction
96    // pointer may not be the same as the one that caused the counter overflow.
97    // Indicates the capabilities of the CPU in terms of recording precise
98    // instruction pointer.
99    optional uint32 precise_ip = 23;
100
101    // Indicates whether we have non-exec mmap data.
102    optional bool mmap_data = 24;
103
104    // If set, all the event types will have the same sample_type.
105    optional bool sample_id_all = 25;
106
107    // Indicates whether we are counting events from the host (when running a
108    // VM).
109    optional bool exclude_host = 26;
110
111    // Exclude events that happen on a guest OS.
112    optional bool exclude_guest = 27;
113
114    // Exclude kernel callchains.
115    optional bool exclude_callchain_kernel = 36;
116
117    // Exclude user callchains.
118    optional bool exclude_callchain_user = 37;
119
120    // Include mmap2 events that have inode data.
121    optional bool mmap2 = 38;
122
123    // Flag comm events that are due to an exec.
124    optional bool comm_exec = 39;
125
126    // Contains the number of events after which we wake up.
127    optional uint32 wakeup_events = 28;
128
129    // Contains the number of bytes after which we wake up.
130    optional uint32 wakeup_watermark = 29;
131
132    // Information about the type of the breakpoint.
133    optional uint32 bp_type = 30;
134
135    // Contains the breakpoint address.
136    optional uint64 bp_addr = 31;
137
138    // This is an extension of config (see above).
139    optional uint64 config1 = 32;
140
141    // The length of the breakpoint data in bytes.
142    optional uint64 bp_len = 33;
143
144    // This is an extension of config (see above).
145    optional uint64 config2 = 34;
146
147    // Contains the type of branch, example: user, kernel, call, return, etc.
148    optional uint64 branch_sample_type = 35;
149
150    // Defines set of user regs to dump on samples.
151    optional uint64 sample_regs_user = 40;
152
153    // Defines size of the user stack to dump on samples.
154    optional uint32 sample_stack_user = 41;
155  }
156
157  // Describes a perf.data file attribute.
158  // Next tag: 3
159  message PerfFileAttr {
160    optional PerfEventAttr attr = 1;
161
162    // List of perf file attribute ids. Each id describes an event.
163    repeated uint64 ids = 2;
164  }
165
166  // Protobuf version of the perf_event_type struct found in perf/util/event.h.
167  // Contains the name of the event (such as "cycles" or "branch-misses") and
168  // the event id (which is not unique).
169  // Next tag: 4
170  message PerfEventType {
171    // Event id.  This is not unique across event types.
172    // The combination of the event id and the type field in PerfEventAttr is
173    // unique across event types.
174    optional uint64 id = 1;
175
176    // Event name.
177    optional string name = 2;
178
179    // Event name's md5 prefix.
180    optional uint64 name_md5_prefix = 3;
181  }
182
183  // This message contains information about a perf sample itself, as opposed to
184  // a perf event captured by a sample.
185  // Next tag: 7
186  message SampleInfo {
187    // Process ID / thread ID from which this sample was taken.
188    optional uint32 pid = 1;
189    optional uint32 tid = 2;
190
191    // Time this sample was taken (NOT the same as an event time).
192    // It is the number of nanoseconds since bootup.
193    optional uint64 sample_time_ns = 3;
194
195    // The ID of the sample's event type (cycles, instructions, etc).
196    // The event type IDs are defined in PerfFileAttr.
197    optional uint64 id = 4;
198
199    // The CPU on which this sample was taken.
200    optional uint32 cpu = 5;
201
202    // The stream id of the sample.
203    optional uint64 stream_id = 6;
204  }
205
206  // Next tag: 7
207  message CommEvent {
208    // Process id.
209    optional uint32 pid = 1;
210
211    // Thread id.
212    optional uint32 tid = 2;
213
214    // Comm string.
215    optional string comm = 3;
216
217    // Comm string's md5 prefix.
218    optional uint64 comm_md5_prefix = 4;
219
220    // Time the sample was taken.
221    // Deprecated, use |sample_info| instead.
222    optional uint64 sample_time = 5 [deprecated = true];
223
224    // Info about the perf sample containing this event.
225    optional SampleInfo sample_info = 6;
226  }
227
228  // Represents both mmap_event and mmap2_event.
229  // Next tag: 15
230  message MMapEvent {
231    // Process id.
232    optional uint32 pid = 1;
233
234    // Thread id.
235    optional uint32 tid = 2;
236
237    // Start address.
238    optional uint64 start = 3;
239
240    // Length.
241    optional uint64 len = 4;
242
243    // PG Offset.
244    optional uint64 pgoff = 5;
245
246    // Only in MMAP2 events, information about the mapped inode:
247    // Major/minor numbers
248    optional uint32 maj = 9;
249    optional uint32 min = 10;
250    // Inode number and generation.
251    optional uint64 ino = 11;
252    optional uint64 ino_generation = 12;
253    // Protection bits and flags.
254    optional uint32 prot = 13;
255    optional uint32 flags = 14;
256
257    // In both MMAP and MMAP2 events:
258
259    // Filename.
260    optional string filename = 6;
261
262    // Filename's md5 prefix.
263    optional uint64 filename_md5_prefix = 7;
264
265    // Info about the perf sample containing this event.
266    optional SampleInfo sample_info = 8;
267  }
268
269  // Next tag: 4
270  message ReadInfo {
271    optional uint64 time_enabled = 1;
272
273    optional uint64 time_running = 2;
274
275    message ReadValue {
276      optional uint64 value = 1;
277      optional uint64 id = 2;
278    }
279
280    // Based on the value of |PerfEventAttr::read_format & PERF_FORMAT_GROUP|,
281    // the read info could contain one or multiple read values and IDs. If the
282    // format is non-grouped, the repeated field will have only one entry.
283    repeated ReadValue read_value = 3;
284  }
285
286  // Next tag: 4
287  message BranchStackEntry {
288    // Branch source address.
289    optional uint64 from_ip = 1;
290
291    // Branch destination address.
292    optional uint64 to_ip = 2;
293
294    // Indicates a mispredicted branch.
295    optional bool mispredicted = 3;
296  }
297
298  // Next tag: 19
299  message SampleEvent {
300    // Instruction pointer.
301    optional uint64 ip = 1;
302
303    // Process id.
304    optional uint32 pid = 2;
305
306    // Thread id.
307    optional uint32 tid = 3;
308
309    // The time after boot when the sample was recorded, in nanoseconds.
310    optional uint64 sample_time_ns = 4;
311
312    // The address of the sample.
313    optional uint64 addr = 5;
314
315    // The id of the sample.
316    optional uint64 id = 6;
317
318    // The stream id of the sample.
319    optional uint64 stream_id = 7;
320
321    // The period of the sample.
322    optional uint64 period = 8;
323
324    // The CPU where the event was recorded.
325    optional uint32 cpu = 9;
326
327    // The raw size of the event in bytes.
328    optional uint32 raw_size = 10;
329
330    // The read field.
331    optional ReadInfo read_info = 18;
332
333    // Sample callchain info.
334    repeated uint64 callchain = 11;
335
336    // Branch stack info.
337    repeated BranchStackEntry branch_stack = 12;
338
339    // These are not yet implemented, but are listed as placeholders.
340    //
341    // optional RegsUser regs_user = 13;
342    // optional StackUser stack_user = 14;
343
344    // Sample weight for special events.
345    optional uint64 weight = 15;
346
347    // Sample data source flags.
348    optional uint64 data_src = 16;
349
350    // Sample transaction flags for special events.
351    optional uint64 transaction = 17;
352  }
353
354  // ForkEvent is used for both FORK and EXIT events, which have the same data
355  // format.  We don't want to call this "ForkOrExitEvent", in case a separate
356  // exit event is introduced in the future.
357  // Next tag: 12
358  message ForkEvent {
359    // Forked process ID.
360    optional uint32 pid = 1;
361
362    // Parent process ID.
363    optional uint32 ppid = 2;
364
365    // Forked process thread ID.
366    optional uint32 tid = 3;
367
368    // Parent process thread ID.
369    optional uint32 ptid = 4;
370
371    // Time of fork event in nanoseconds since bootup.
372    optional uint64 fork_time_ns = 5;
373
374    // Info about the perf sample containing this event.
375    optional SampleInfo sample_info = 11;
376  }
377
378  // Next tag: 4
379  message LostEvent {
380    // Id of the event which has been lost.  This should be an id found in a
381    // PerfFileAttr.
382    optional uint64 id = 1;
383
384    // Number of events that were lost.
385    optional uint64 lost = 2;
386
387    // Info about the perf sample containing this event.
388    optional SampleInfo sample_info = 3;
389  }
390
391  // Next tag: 5
392  message ThrottleEvent {
393    // Time of throttle event, in nanoseconds since system startup.
394    optional uint64 time_ns = 1;
395
396    // Event ID.
397    optional uint64 id = 2;
398
399    // Stream ID.
400    optional uint64 stream_id = 3;
401
402    // Info about the perf sample containing this event.
403    optional SampleInfo sample_info = 4;
404  }
405
406  // Next tag: 8
407  message ReadEvent {
408    // Process ID.
409    optional uint32 pid = 1;
410
411    // Thread ID.
412    optional uint32 tid = 2;
413
414    // Value of the event counter when it was queried.
415    optional uint64 value = 3;
416
417    // Time enabled.
418    optional uint64 time_enabled = 4;
419
420    // Time running.
421    optional uint64 time_running = 5;
422
423    // ID.
424    optional uint64 id = 6;
425
426    // Info about the perf sample containing this event.
427    optional SampleInfo sample_info = 7;
428  }
429
430  // Next tag: 7
431  message AuxEvent {
432    // Aux offset.
433    optional uint64 aux_offset = 1;
434
435    // Aux size.
436    optional uint64 aux_size = 2;
437
438    // Is the record was truncated to fit.
439    optional bool is_truncated = 3;
440
441    // Does the record contain snapshot from overwrite mode.
442    optional bool is_overwrite = 4;
443
444    // Does the record contain gaps.
445    optional bool is_partial = 5;
446
447    // Info about the perf sample containing this event.
448    optional SampleInfo sample_info = 6;
449  }
450
451  // Next tag: 8
452  message AuxtraceEvent {
453    // Size of AUX area tracing buffer.
454    optional uint64 size = 1;
455
456    // Offset as determined by aux_head / aux_tail members of struct
457    // perf_event_mmap_page.
458    optional uint64 offset = 2;
459
460    // Implementation specific reference determined when the data is recorded.
461    optional uint64 reference = 3;
462
463    // Index of AUX area tracing data buffer.
464    optional uint32 idx = 4;
465
466    // In per-thread mode, the tid this buffer is associated with.
467    optional uint32 tid = 5;
468
469    // In per-cpu mode, the cpu this buffer is associated with.
470    optional uint32 cpu = 6;
471
472    // The trace data.
473    optional bytes trace_data = 7;
474  }
475
476  // Next tag: 4
477  message EventHeader {
478    // Type of event.
479    optional uint32 type = 1;
480    optional uint32 misc = 2;
481    // Size of event.
482    optional uint32 size = 3;
483  }
484
485  // Next tag: 13
486  message PerfEvent {
487    optional EventHeader header = 1;
488    oneof event_type {
489      MMapEvent mmap_event = 2;
490      SampleEvent sample_event = 3;
491      CommEvent comm_event = 4;
492      // FORK and EXIT events are structurally identical. They only differ by
493      // the event type. But using two distinct fields allows us to
494      // differentiate between them without having to check the event type under
495      // |header|.
496      ForkEvent fork_event = 5;
497      ForkEvent exit_event = 9;
498      LostEvent lost_event = 6;
499      ThrottleEvent throttle_event = 7;
500      ReadEvent read_event = 8;
501      AuxEvent aux_event = 11;
502      AuxtraceEvent auxtrace_event = 12;
503    }
504    // Time after boot in nanoseconds corresponding to the event.
505    optional uint64 timestamp = 10;
506  }
507
508  // Next tag: 8
509  message PerfEventStats {
510    // Total number of events read from perf data.
511    optional uint32 num_events_read = 1;
512
513    // Total number of various types of events.
514    optional uint32 num_sample_events = 2;
515    optional uint32 num_mmap_events = 3;
516    optional uint32 num_fork_events = 4;
517    optional uint32 num_exit_events = 5;
518
519    // Number of sample events that were successfully mapped by the address
520    // mapper, a quipper module that is used to obscure addresses and convert
521    // them to DSO name + offset.  Sometimes it fails to process sample events.
522    // This field allows us to track the success rate of the address mapper.
523    optional uint32 num_sample_events_mapped = 6;
524
525    // Whether address remapping was enabled.
526    optional bool did_remap = 7;
527  }
528
529  // Next tag: 3
530  message PerfUint32Metadata {
531    // Type of metadata, such as nrcpus.
532    optional uint32 type = 1;
533
534    // uint32 data.
535    repeated uint32 data = 2;
536  }
537
538  // Next tag: 3
539  message PerfUint64Metadata {
540    // Type of metadata, such as totalmem.
541    optional uint32 type = 1;
542
543    // uint64 data.
544    repeated uint64 data = 2;
545  }
546
547  // Next tag: 3
548  message PerfTracingMetadata {
549    // The trace event metadata.
550    optional bytes tracing_data = 1;
551
552    // Trace event metedata Md5sum prefix.
553    optional uint64 tracing_data_md5_prefix = 2;
554  }
555
556  // Next tag: 6
557  message PerfBuildID {
558    // Misc field in perf_event_header.
559    optional uint32 misc = 1;
560
561    // Process ID.
562    optional uint32 pid = 2;
563
564    // Build id.  Should always contain kBuildIDArraySize bytes of data.
565    // perf_reader.h defines kBuildIDArraySize = 20.
566    optional bytes build_id_hash = 3;
567
568    // Filename.
569    optional string filename = 4;
570
571    // Filename Md5sum prefix.
572    optional uint64 filename_md5_prefix = 5;
573  }
574
575  // Next tag: 5
576  message PerfCPUTopologyMetadata {
577    // Core siblings.
578    repeated string core_siblings = 1;
579
580    // Core siblings' md5 prefixes.
581    repeated uint64 core_siblings_md5_prefix = 2;
582
583    // Thread siblings.
584    repeated string thread_siblings = 3;
585
586    // Thread siblings' md5 prefixes.
587    repeated uint64 thread_siblings_md5_prefix = 4;
588  }
589
590  // Next tag: 6
591  message PerfNodeTopologyMetadata {
592    // Node id.
593    optional uint32 id = 1;
594
595    // Total memory of the node.
596    optional uint64 total_memory = 2;
597
598    // Free memory of the node.
599    optional uint64 free_memory = 3;
600
601    // List of CPUs in the node.
602    optional string cpu_list = 4;
603
604    // CPU list's md5 prefix.
605    optional uint64 cpu_list_md5_prefix = 5;
606  }
607
608  // Next tag: 4
609  message PerfPMUMappingsMetadata {
610    // Mapping type.
611    optional uint32 type = 1;
612
613    // Mapping name.
614    optional string name = 2;
615
616    // Mapping name's md5 prefix.
617    optional uint64 name_md5_prefix = 3;
618  }
619
620  // Next tag: 5
621  message PerfGroupDescMetadata {
622    // Group name.
623    optional string name = 1;
624
625    // Group name's md5 prefix.
626    optional uint64 name_md5_prefix = 2;
627
628    // Group's leader index.
629    optional uint32 leader_idx = 3;
630
631    // Number of members in the group.
632    optional uint32 num_members = 4;
633  }
634
635  repeated PerfFileAttr file_attrs = 1;
636  repeated PerfEvent events = 2;
637
638  repeated PerfEventType event_types = 10;
639
640  // Time when quipper generated this perf data / protobuf, given as seconds
641  // since the epoch.
642  optional uint64 timestamp_sec = 3;
643
644  // Records some stats about the serialized perf events.
645  optional PerfEventStats stats = 4;
646
647  // Bit mask used to determine what metadata has been included.
648  // At the moment, only the first number is actually used.
649  // See adds_features in perf_reader.cc
650  repeated uint64 metadata_mask = 5;
651
652  optional PerfTracingMetadata tracing_data = 14;
653
654  repeated PerfBuildID build_ids = 7;
655
656  repeated PerfUint32Metadata uint32_metadata = 8;
657
658  repeated PerfUint64Metadata uint64_metadata = 9;
659
660  optional PerfCPUTopologyMetadata cpu_topology = 11;
661
662  repeated PerfNodeTopologyMetadata numa_topology = 12;
663
664  repeated PerfPMUMappingsMetadata pmu_mappings = 15;
665
666  repeated PerfGroupDescMetadata group_desc = 16;
667
668  // Next tag: 9
669  message StringMetadata {
670    // Next tag: 3
671    message StringAndMd5sumPrefix {
672      // The string value.
673      optional string value = 1;
674
675      // The string value's md5sum prefix.
676      optional uint64 value_md5_prefix = 2;
677    }
678
679    // Name of the machine, e.g. "localhost".
680    optional StringAndMd5sumPrefix hostname = 1;
681
682    // Kernel version, e.g. "3.4.0".
683    optional StringAndMd5sumPrefix kernel_version = 2;
684
685    // Perf version, e.g. "3.4.2642.g0aa604".
686    optional StringAndMd5sumPrefix perf_version = 3;
687
688    // CPU architecture family, e.g. "x86_64".
689    optional StringAndMd5sumPrefix architecture = 4;
690
691    // CPU description, e.g. "Intel(R) Celeron(R) CPU 867 @ 1.30GHz".
692    optional StringAndMd5sumPrefix cpu_description = 5;
693
694    // CPU ID string, with the format: "$VENDOR,$FAMILY,$MODEL,$STEP"
695    optional StringAndMd5sumPrefix cpu_id = 6;
696
697    // Command line used to run perf to collect this profile.
698    // This is split into string tokens to reflect the way it is stored in the
699    // raw perf data.  e.g. "perf record -a -- sleep 2" become stored as:
700    //   { "perf", "record", "-a", "--", "sleep", "2" }
701    repeated StringAndMd5sumPrefix perf_command_line_token = 7;
702
703    // The command line stored as a single string.
704    optional StringAndMd5sumPrefix perf_command_line_whole = 8;
705  }
706
707  optional StringMetadata string_metadata = 13;
708
709  extensions 32 to 100;
710}
711