1/*
2 * Copyright (C) 2021 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 *      http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17syntax = "proto2";
18
19package perfetto.protos;
20
21message PerfEvents {
22  // What event to sample on, and how often. Commented from the perspective of
23  // its use in |PerfEventConfig|.
24  message Timebase {
25    // How often the per-cpu sampling will occur. Not guaranteed to be honored
26    // as the kernel can throttle the sampling rate if it's too high.
27    // If unset, an implementation-defined default is used.
28    oneof interval {
29      // Per-cpu sampling frequency in Hz, as requested from the kernel. Not the
30      // same as 1/period.
31      // Details: the actual sampling will still be based on a period, but the
32      // kernel will dynamically adjust it based on the observed event rate, to
33      // approximate this frequency. Works best with steady-rate events like
34      // timers.
35      uint64 frequency = 2;
36
37      // Per-cpu sampling will occur every |period| counts of |event|.
38      // Prefer |frequency| by default, as it's easier to oversample with a
39      // fixed period.
40      uint64 period = 1;
41    }
42
43    // Counting event to use as a timebase for the sampling.
44    // If unset, implies the CPU timer (SW_CPU_CLOCK) as the event,
45    // which is what you usually want.
46    // See common/perf_events.proto for the definitions.
47    oneof event {
48      Counter counter = 4;
49      Tracepoint tracepoint = 3;
50    }
51  }
52
53  enum Counter {
54    UNKNOWN_COUNTER = 0;
55    // software:
56    SW_CPU_CLOCK = 1;
57    SW_PAGE_FAULTS = 2;
58    // hardware:
59    HW_CPU_CYCLES = 10;
60    HW_INSTRUCTIONS = 11;
61  }
62
63  message Tracepoint {
64    // Group and name for the tracepoint, acceptable forms:
65    // * "sched/sched_switch"
66    // * "sched:sched_switch"
67    optional string name = 1;
68
69    // Optional field-level filter for the tracepoint. Only events matching this
70    // filter will be counted (and therefore contribute to the sampling period).
71    // Example: "prev_pid >= 42 && next_pid == 0".
72    // For full syntax, see kernel documentation on "Event filtering":
73    // https://www.kernel.org/doc/Documentation/trace/events.txt
74    optional string filter = 2;
75  }
76}
77