summaryrefslogtreecommitdiff
path: root/chromium/components/metrics/proto/perf_data.proto
blob: 99f67f8021b7356c316393418ec6d709f3b4be8f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

syntax = "proto2";

option optimize_for = LITE_RUNTIME;
option java_outer_classname = "PerfDataProtos";
option java_package = "org.chromium.components.metrics";

package metrics;

// Stores information from a perf session generated via running:
// "perf record"
//
// See $kernel/tools/perf/design.txt for more details.

// Please do not modify this protobuf directly, except to mirror the upstream
// version found here:
// https://chromium.googlesource.com/chromiumos/platform/chromiumos-wide-profiling/+/master/perf_data.proto
// with some fields omitted for privacy reasons. Because it is a read-only copy
// of the upstream protobuf, "Next tag:" comments are also absent.

message PerfDataProto {

  // Perf event attribute. Stores the event description.
  // This data structure is defined in the linux kernel:
  // $kernel/tools/perf/util/event.h.
  message PerfEventAttr {
    // Type of the event. Type is an enumeration and can be:
    // IP: an instruction-pointer was stored in the event.
    // MMAP: a DLL was loaded.
    // FORK: a process was forked.
    // etc.
    optional uint32 type = 1;

    // Size of the event data in bytes.
    optional uint32 size = 2;

    // The config stores the CPU-specific counter information.
    optional uint64 config = 3;

    // Sample period of the event. Indicates how often the event is
    // triggered in terms of # of events. After |sample_period| events, an event
    // will be recorded and stored.
    optional uint64 sample_period = 4;

    // Sample frequency of the event. Indicates how often the event is
    // triggered in terms of # per second. The kernel will try to record
    // |sample_freq| events per second.
    optional uint64 sample_freq = 5;

    // Sample type is a bitfield that records attributes of the sample. Example,
    // whether an entire callchain was recorded, etc.
    optional uint64 sample_type = 6;

    // Bitfield that indicates whether reads on the counter will return the
    // total time enabled and total time running.
    optional uint64 read_format = 7;

    // Indicates whether the counter starts off disabled.
    optional bool disabled = 8;

    // Indicates whether child processes inherit the counter.
    optional bool inherit = 9;

    // Indicates whether the counter is pinned to a particular CPU.
    optional bool pinned = 10;

    // Indicates whether this counter's group has exclusive access to the CPU's
    // counters.
    optional bool exclusive = 11;

    // The following bits restrict events to be counted when the CPU is in user,
    // kernel, hypervisor or idle modes.
    optional bool exclude_user = 12;
    optional bool exclude_kernel = 13;
    optional bool exclude_hv = 14;
    optional bool exclude_idle = 15;

    // Indicates whether mmap events should be recorded.
    optional bool mmap = 16;

    // Indicates whether process comm information should be recorded upon
    // process creation.
    optional bool comm = 17;

    // Indicates that we are in frequency mode, not period mode.
    optional bool freq = 18;

    // Indicates whether we have per-task counts.
    optional bool inherit_stat = 19;

    // Indicates whether we enable perf events after an exec() function call.
    optional bool enable_on_exec = 20;

    // Indicates whether we trace fork/exit.
    optional bool task = 21;

    // Indicates whether we are using a watermark to wake up.
    optional bool watermark = 22;

    // CPUs often "skid" when recording events. That means the instruction
    // pointer may not be the same as the one that caused the counter overflow.
    // Indicates the capabilities of the CPU in terms of recording precise
    // instruction pointer.
    optional uint32 precise_ip = 23;

    // Indicates whether we have non-exec mmap data.
    optional bool mmap_data = 24;

    // If set, all the event types will have the same sample_type.
    optional bool sample_id_all = 25;

    // Indicates whether we are counting events from the host (when running a
    // VM).
    optional bool exclude_host = 26;

    // Exclude events that happen on a guest OS.
    optional bool exclude_guest = 27;

    // Contains the number of events after which we wake up.
    optional uint32 wakeup_events = 28;

    // Contains the number of bytes after which we wake up.
    optional uint32 wakeup_watermark = 29;

    // Information about the type of the breakpoint.
    optional uint32 bp_type = 30;

    // Contains the breakpoint address.
    optional uint64 bp_addr = 31;

    // This is an extension of config (see above).
    optional uint64 config1 = 32;

    // The length of the breakpoint data in bytes.
    optional uint64 bp_len = 33;

    // This is an extension of config (see above).
    optional uint64 config2 = 34;

    // Contains the type of branch, example: user, kernel, call, return, etc.
    optional uint64 branch_sample_type = 35;
  }

  // Describes a perf.data file attribute.
  message PerfFileAttr {
    optional PerfEventAttr attr = 1;

    // List of perf file attribute ids. Each id describes an event.
    repeated uint64 ids = 2;
  }

  // This message contains information about a perf sample itself, as opposed to
  // a perf event captured by a sample.
  message SampleInfo {
    // Process ID / thread ID from which this sample was taken.
    optional uint32 pid = 1;
    optional uint32 tid = 2;

    // Time this sample was taken (NOT the same as an event time).
    // It is the number of nanoseconds since bootup.
    optional uint64 sample_time_ns = 3;

    // The ID of the sample's event type (cycles, instructions, etc).
    // The event type IDs are defined in PerfFileAttr.
    optional uint64 id = 4;

    // The CPU on which this sample was taken.
    optional uint32 cpu = 5;
  }

  message CommEvent {
    // Process id.
    optional uint32 pid = 1;

    // Thread id.
    optional uint32 tid = 2;

    // Comm string's md5 prefix.
    // The comm string was field 3 and has been intentionally left out.
    optional uint64 comm_md5_prefix = 4;

    // Time the sample was taken.
    // Deprecated, use |sample_info| instead.
    optional uint64 sample_time = 5 [deprecated=true];

    // Info about the perf sample containing this event.
    optional SampleInfo sample_info = 6;
  }

  message MMapEvent {
    // Process id.
    optional uint32 pid = 1;

    // Thread id.
    optional uint32 tid = 2;

    // Start address.
    optional uint64 start = 3;

    // Length.
    optional uint64 len = 4;

    // PG Offset.
    optional uint64 pgoff = 5;

    // Filename's md5 prefix.
    // The filename was field 6 and has been intentionally left out.
    optional uint64 filename_md5_prefix = 7;

    // Info about the perf sample containing this event.
    optional SampleInfo sample_info = 8;
  }

  message BranchStackEntry {
    // Branch source address.
    optional uint64 from_ip = 1;

    // Branch destination address.
    optional uint64 to_ip = 2;

    // Indicates a mispredicted branch.
    optional bool mispredicted = 3;
  }

  message SampleEvent {
    // Instruction pointer.
    optional uint64 ip = 1;

    // Process id.
    optional uint32 pid = 2;

    // Thread id.
    optional uint32 tid = 3;

    // The time after boot when the sample was recorded, in nanoseconds.
    optional uint64 sample_time_ns = 4;

    // The address of the sample.
    optional uint64 addr = 5;

    // The id of the sample.
    optional uint64 id = 6;

    // The stream id of the sample.
    optional uint64 stream_id = 7;

    // The period of the sample.
    optional uint64 period = 8;

    // The CPU where the event was recorded.
    optional uint32 cpu = 9;

    // The raw size of the event in bytes.
    optional uint32 raw_size = 10;

    // Sample callchain info.
    repeated uint64 callchain = 11;

    // Branch stack info.
    repeated BranchStackEntry branch_stack = 12;

    // Not added from original: fields 13 and 14.

    // Sample weight for special events.
    optional uint64 weight = 15;

    // Sample data source flags.
    // Possible flag values:
    // http://lxr.free-electrons.com/source/include/uapi/linux/perf_event.h#L849
    optional uint64 data_src = 16;

    // Sample transaction flags for special events.
    // Flag fields:
    // http://lxr.free-electrons.com/source/include/uapi/linux/perf_event.h#L209
    optional uint64 transaction = 17;
  }

  // ForkEvent is used for both FORK and EXIT events, which have the same data
  // format.  We don't want to call this "ForkOrExitEvent", in case a separate
  // exit event is introduced in the future.
  message ForkEvent {
    // Forked process ID.
    optional uint32 pid = 1;

    // Parent process ID.
    optional uint32 ppid = 2;

    // Forked process thread ID.
    optional uint32 tid = 3;

    // Parent process thread ID.
    optional uint32 ptid = 4;

    // Time of fork event in nanoseconds since bootup.
    optional uint64 fork_time_ns = 5;

    // Info about the perf sample containing this event.
    optional SampleInfo sample_info = 11;
  }

  message EventHeader {
    // Type of event.
    optional uint32 type = 1;
    optional uint32 misc = 2;
    // Size of event.
    optional uint32 size = 3;
  }

  message PerfEvent {
    optional EventHeader header = 1;

    optional MMapEvent mmap_event = 2;
    optional SampleEvent sample_event = 3;
    optional CommEvent comm_event = 4;
    // FORK and EXIT events are structurally identical. They only differ by the
    // event type. But using two distinct fields makes things easier.
    optional ForkEvent fork_event = 5;
    optional ForkEvent exit_event = 9;

    // Not added from original: optional LostEvent lost_event = 6;
    // Not added from original: optional ThrottleEvent throttle_event = 7;
    // Not added from original: optional ReadEvent read_event = 8;
  }

  message PerfEventStats {
    // Total number of events read from perf data.
    optional uint32 num_events_read = 1;

    // Total number of various types of events.
    optional uint32 num_sample_events = 2;
    optional uint32 num_mmap_events = 3;
    optional uint32 num_fork_events = 4;
    optional uint32 num_exit_events = 5;

    // Number of sample events that were successfully mapped by the address
    // mapper, a quipper module that is used to obscure addresses and convert
    // them to DSO name + offset.  Sometimes it fails to process sample events.
    // This field allows us to track the success rate of the address mapper.
    optional uint32 num_sample_events_mapped = 6;

    // Whether address remapping was enabled.
    optional bool did_remap = 7;
  }

  message PerfBuildID {
    // Misc field in perf_event_header.
    // Indicates whether the file is mapped in kernel mode or user mode.
    optional uint32 misc = 1;

    // Process ID.
    optional uint32 pid = 2;

    // Build id.  Should always contain kBuildIDArraySize bytes of data.
    // perf_reader.h in Chrome OS defines kBuildIDArraySize = 20.
    optional bytes build_hash = 3;

    // Filename Md5sum prefix.
    // The filename was field 4 and has been intentionally left out.
    optional uint64 filename_md5_prefix = 5;
  }

  repeated PerfFileAttr file_attrs = 1;
  repeated PerfEvent events = 2;

  // Time when quipper generated this perf data / protobuf, given as seconds
  // since the epoch.
  optional uint64 timestamp_sec = 3;

  // Records some stats about the serialized perf events.
  optional PerfEventStats stats = 4;

  // Not added from original: repeated uint64 metadata_mask = 5;

  // Build ID metadata.
  repeated PerfBuildID build_ids = 7;

  // Not added from original: repeated PerfUint32Metadata uint32_metadata = 8;
  // Not added from original: repeated PerfUint64Metadata uint64_metadata = 9;
  // Not added from original:
  //     optional PerfCPUTopologyMetadata cpu_topology = 11;
  // Not added from original:
  //     repeated PerfNodeTopologyMetadata numa_topology = 12;

  message StringMetadata {
    message StringAndMd5sumPrefix {
      // The string value was field 1 and has been intentionally left out.

      // The string value's md5sum prefix.
      optional uint64 value_md5_prefix = 2;
    }

    // Not added from original: optional StringAndMd5sumPrefix hostname = 1;
    // Not added from original:
    //     optional StringAndMd5sumPrefix kernel_version =2;
    // Not added from original: optional StringAndMd5sumPrefix perf_version = 3;
    // Not added from original: optional StringAndMd5sumPrefix architecture = 4;
    // Not added from original:
    //     optional StringAndMd5sumPrefix cpu_description = 5;
    // Not added from original: optional StringAndMd5sumPrefix cpu_id = 6;
    // Not added from original:
    //     repeated StringAndMd5sumPrefix perf_command_line_token = 7;

    // The command line stored as a single string.
    optional StringAndMd5sumPrefix perf_command_line_whole = 8;
  }

  // All the string metadata from the perf data file.
  optional StringMetadata string_metadata = 13;
}