xref: /aosp_15_r20/external/perfetto/src/traced/probes/ftrace/ftrace_stats.h (revision 6dbdd20afdafa5e3ca9b8809fa73465d530080dc)
1 /*
2  * Copyright (C) 2018 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 
17 #ifndef SRC_TRACED_PROBES_FTRACE_FTRACE_STATS_H_
18 #define SRC_TRACED_PROBES_FTRACE_FTRACE_STATS_H_
19 
20 #include <cinttypes>
21 #include <string>
22 #include <vector>
23 
24 namespace perfetto {
25 
26 namespace protos {
27 namespace pbzero {
28 class FtraceStats;
29 class FtraceCpuStats;
30 class FtraceKprobeStats;
31 }  // namespace pbzero
32 }  // namespace protos
33 
34 struct FtraceCpuStats {
35   uint64_t cpu;
36   uint64_t entries;
37   uint64_t overrun;
38   uint64_t commit_overrun;
39   uint64_t bytes;
40   double oldest_event_ts;
41   double now_ts;
42   uint64_t dropped_events;
43   uint64_t read_events;
44 
45   void Write(protos::pbzero::FtraceCpuStats*) const;
46 };
47 
48 struct FtraceKprobeStats {
49   int64_t hits;
50   int64_t misses;
51 };
52 
53 struct FtraceSetupErrors {
54   std::string atrace_errors;
55   std::vector<std::string> unknown_ftrace_events;
56   std::vector<std::string> failed_ftrace_events;
57 };
58 
59 struct FtraceStats {
60   std::vector<FtraceCpuStats> cpu_stats;
61   FtraceSetupErrors setup_errors;
62   uint32_t kernel_symbols_parsed = 0;
63   uint32_t kernel_symbols_mem_kb = 0;
64   FtraceKprobeStats kprobe_stats = {};
65 
66   void Write(protos::pbzero::FtraceStats*) const;
67 };
68 
69 }  // namespace perfetto
70 
71 #endif  // SRC_TRACED_PROBES_FTRACE_FTRACE_STATS_H_
72