1 /* 2 * Copyright (C) 2019 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_TRACE_PROCESSOR_STORAGE_STATS_H_ 18 #define SRC_TRACE_PROCESSOR_STORAGE_STATS_H_ 19 20 #include <stddef.h> 21 22 namespace perfetto { 23 namespace trace_processor { 24 namespace stats { 25 26 // Compile time list of parsing and processing stats. 27 // clang-format off 28 #define PERFETTO_TP_STATS(F) \ 29 F(android_log_num_failed, kSingle, kError, kTrace), \ 30 F(android_log_num_skipped, kSingle, kError, kTrace), \ 31 F(android_log_num_total, kSingle, kInfo, kTrace), \ 32 F(counter_events_out_of_order, kSingle, kError, kAnalysis), \ 33 F(ftrace_bundle_tokenizer_errors, kSingle, kError, kAnalysis), \ 34 F(ftrace_cpu_bytes_read_begin, kIndexed, kInfo, kTrace), \ 35 F(ftrace_cpu_bytes_read_end, kIndexed, kInfo, kTrace), \ 36 F(ftrace_cpu_commit_overrun_begin, kIndexed, kError, kTrace), \ 37 F(ftrace_cpu_commit_overrun_end, kIndexed, kError, kTrace), \ 38 F(ftrace_cpu_dropped_events_begin, kIndexed, kError, kTrace), \ 39 F(ftrace_cpu_dropped_events_end, kIndexed, kError, kTrace), \ 40 F(ftrace_cpu_entries_begin, kIndexed, kInfo, kTrace), \ 41 F(ftrace_cpu_entries_end, kIndexed, kInfo, kTrace), \ 42 F(ftrace_cpu_now_ts_begin, kIndexed, kInfo, kTrace), \ 43 F(ftrace_cpu_now_ts_end, kIndexed, kInfo, kTrace), \ 44 F(ftrace_cpu_oldest_event_ts_begin, kIndexed, kInfo, kTrace), \ 45 F(ftrace_cpu_oldest_event_ts_end, kIndexed, kInfo, kTrace), \ 46 F(ftrace_cpu_overrun_begin, kIndexed, kInfo, kTrace), \ 47 F(ftrace_cpu_overrun_end, kIndexed, kDataLoss, kTrace, \ 48 "The kernel ftrace buffer cannot keep up with the rate of events " \ 49 "produced. Indexed by CPU. This is likely a misconfiguration."), \ 50 F(ftrace_cpu_read_events_begin, kIndexed, kInfo, kTrace), \ 51 F(ftrace_cpu_read_events_end, kIndexed, kInfo, kTrace), \ 52 F(fuchsia_non_numeric_counters, kSingle, kError, kAnalysis), \ 53 F(fuchsia_timestamp_overflow, kSingle, kError, kAnalysis), \ 54 F(fuchsia_invalid_event, kSingle, kError, kAnalysis), \ 55 F(gpu_counters_invalid_spec, kSingle, kError, kAnalysis), \ 56 F(gpu_counters_missing_spec, kSingle, kError, kAnalysis), \ 57 F(gpu_render_stage_parser_errors, kSingle, kError, kAnalysis), \ 58 F(graphics_frame_event_parser_errors, kSingle, kInfo, kAnalysis), \ 59 F(guess_trace_type_duration_ns, kSingle, kInfo, kAnalysis), \ 60 F(interned_data_tokenizer_errors, kSingle, kInfo, kAnalysis), \ 61 F(invalid_clock_snapshots, kSingle, kError, kAnalysis), \ 62 F(invalid_cpu_times, kSingle, kError, kAnalysis), \ 63 F(meminfo_unknown_keys, kSingle, kError, kAnalysis), \ 64 F(mismatched_sched_switch_tids, kSingle, kError, kAnalysis), \ 65 F(mm_unknown_type, kSingle, kError, kAnalysis), \ 66 F(parse_trace_duration_ns, kSingle, kInfo, kAnalysis), \ 67 F(power_rail_unknown_index, kSingle, kError, kTrace), \ 68 F(proc_stat_unknown_counters, kSingle, kError, kAnalysis), \ 69 F(rss_stat_unknown_keys, kSingle, kError, kAnalysis), \ 70 F(rss_stat_negative_size, kSingle, kInfo, kAnalysis), \ 71 F(rss_stat_unknown_thread_for_mm_id, kSingle, kInfo, kAnalysis), \ 72 F(sched_switch_out_of_order, kSingle, kError, kAnalysis), \ 73 F(slice_out_of_order, kSingle, kError, kAnalysis), \ 74 F(stackprofile_invalid_string_id, kSingle, kError, kTrace), \ 75 F(stackprofile_invalid_mapping_id, kSingle, kError, kTrace), \ 76 F(stackprofile_invalid_frame_id, kSingle, kError, kTrace), \ 77 F(stackprofile_invalid_callstack_id, kSingle, kError, kTrace), \ 78 F(stackprofile_parser_error, kSingle, kError, kTrace), \ 79 F(systrace_parse_failure, kSingle, kError, kAnalysis), \ 80 F(task_state_invalid, kSingle, kError, kAnalysis), \ 81 F(traced_buf_buffer_size, kIndexed, kInfo, kTrace), \ 82 F(traced_buf_bytes_overwritten, kIndexed, kInfo, kTrace), \ 83 F(traced_buf_bytes_read, kIndexed, kInfo, kTrace), \ 84 F(traced_buf_bytes_written, kIndexed, kInfo, kTrace), \ 85 F(traced_buf_chunks_discarded, kIndexed, kInfo, kTrace), \ 86 F(traced_buf_chunks_overwritten, kIndexed, kInfo, kTrace), \ 87 F(traced_buf_chunks_read, kIndexed, kInfo, kTrace), \ 88 F(traced_buf_chunks_rewritten, kIndexed, kInfo, kTrace), \ 89 F(traced_buf_chunks_written, kIndexed, kInfo, kTrace), \ 90 F(traced_buf_chunks_committed_out_of_order, kIndexed, kInfo, kTrace), \ 91 F(traced_buf_padding_bytes_cleared, kIndexed, kInfo, kTrace), \ 92 F(traced_buf_padding_bytes_written, kIndexed, kInfo, kTrace), \ 93 F(traced_buf_patches_failed, kIndexed, kInfo, kTrace), \ 94 F(traced_buf_patches_succeeded, kIndexed, kInfo, kTrace), \ 95 F(traced_buf_readaheads_failed, kIndexed, kInfo, kTrace), \ 96 F(traced_buf_readaheads_succeeded, kIndexed, kInfo, kTrace), \ 97 F(traced_buf_trace_writer_packet_loss, kIndexed, kInfo, kTrace), \ 98 F(traced_buf_write_wrap_count, kIndexed, kInfo, kTrace), \ 99 F(traced_chunks_discarded, kSingle, kInfo, kTrace), \ 100 F(traced_data_sources_registered, kSingle, kInfo, kTrace), \ 101 F(traced_data_sources_seen, kSingle, kInfo, kTrace), \ 102 F(traced_patches_discarded, kSingle, kInfo, kTrace), \ 103 F(traced_producers_connected, kSingle, kInfo, kTrace), \ 104 F(traced_producers_seen, kSingle, kInfo, kTrace), \ 105 F(traced_total_buffers, kSingle, kInfo, kTrace), \ 106 F(traced_tracing_sessions, kSingle, kInfo, kTrace), \ 107 F(track_event_parser_errors, kSingle, kInfo, kAnalysis), \ 108 F(track_event_tokenizer_errors, kSingle, kInfo, kAnalysis), \ 109 F(tokenizer_skipped_packets, kSingle, kInfo, kAnalysis), \ 110 F(vmstat_unknown_keys, kSingle, kError, kAnalysis), \ 111 F(vulkan_allocations_invalid_string_id, kSingle, kError, kTrace), \ 112 F(clock_sync_failure, kSingle, kError, kAnalysis), \ 113 F(clock_sync_cache_miss, kSingle, kInfo, kAnalysis), \ 114 F(process_tracker_errors, kSingle, kError, kAnalysis), \ 115 F(json_tokenizer_failure, kSingle, kError, kTrace), \ 116 F(heap_graph_invalid_string_id, kIndexed, kError, kTrace), \ 117 F(heap_graph_non_finalized_graph, kSingle, kError, kTrace), \ 118 F(heap_graph_malformed_packet, kIndexed, kError, kTrace), \ 119 F(heap_graph_missing_packet, kIndexed, kError, kTrace), \ 120 F(heap_graph_location_parse_error, kSingle, kError, kTrace), \ 121 F(heapprofd_buffer_corrupted, kIndexed, kError, kTrace, \ 122 "Shared memory buffer corrupted. This is a bug or memory corruption " \ 123 "in the target. Indexed by target upid."), \ 124 F(heapprofd_hit_guardrail, kIndexed, kError, kTrace, \ 125 "HeapprofdConfig specified a CPU or Memory Guardrail that was hit. " \ 126 "Indexed by target upid."), \ 127 F(heapprofd_buffer_overran, kIndexed, kDataLoss, kTrace, \ 128 "The shared memory buffer between the target and heapprofd overran. " \ 129 "The profile was truncated early. Indexed by target upid."), \ 130 F(heapprofd_client_disconnected, kIndexed, kInfo, kTrace), \ 131 F(heapprofd_malformed_packet, kIndexed, kError, kTrace), \ 132 F(heapprofd_missing_packet, kSingle, kError, kTrace), \ 133 F(heapprofd_rejected_concurrent, kIndexed, kError, kTrace, \ 134 "The target was already profiled by another tracing session, so the " \ 135 "profile was not taken. Indexed by target upid."), \ 136 F(heapprofd_non_finalized_profile, kSingle, kError, kTrace), \ 137 F(metatrace_overruns, kSingle, kError, kTrace), \ 138 F(packages_list_has_parse_errors, kSingle, kError, kTrace), \ 139 F(packages_list_has_read_errors, kSingle, kError, kTrace), \ 140 F(compact_sched_has_parse_errors, kSingle, kError, kTrace), \ 141 F(misplaced_end_event, kSingle, kDataLoss, kAnalysis), \ 142 F(sched_waking_out_of_order, kSingle, kError, kAnalysis), \ 143 F(compact_sched_switch_skipped, kSingle, kInfo, kAnalysis), \ 144 F(compact_sched_waking_skipped, kSingle, kInfo, kAnalysis), \ 145 F(empty_chrome_metadata, kSingle, kError, kTrace), \ 146 F(perf_cpu_lost_records, kIndexed, kDataLoss, kTrace), \ 147 F(ninja_parse_errors, kSingle, kError, kTrace), \ 148 F(perf_samples_skipped, kSingle, kInfo, kTrace), \ 149 F(perf_samples_skipped_dataloss, kSingle, kDataLoss, kTrace), \ 150 F(thread_time_in_state_out_of_order, kSingle, kError, kAnalysis), \ 151 F(thread_time_in_state_unknown_cpu_freq, kSingle, kError, kAnalysis) 152 // clang-format on 153 154 enum Type { 155 kSingle, // Single-value property, one value per key. 156 kIndexed // Indexed property, multiple value per key (e.g. cpu_stats[1]). 157 }; 158 159 enum Severity { 160 kInfo, // Diagnostic counters 161 kDataLoss, // Correct operation that still resulted in data loss 162 kError // If any kError counter is > 0 trace_processor_shell will 163 // raise an error. This is *not* surfaced in the web UI. 164 // TODO(b/148587181): Surface these errors in the UI. 165 }; 166 167 enum Source { 168 // The counter is collected when recording the trace on-device and is just 169 // being reflected in the stats table. 170 kTrace, 171 172 // The counter is genrated when importing / processing the trace in the trace 173 // processor. 174 kAnalysis 175 }; 176 177 // Ignore GCC warning about a missing argument for a variadic macro parameter. 178 #pragma GCC system_header 179 180 // Declares an enum of literals (one for each stat). The enum values of each 181 // literal corresponds to the string index in the arrays below. 182 #define PERFETTO_TP_STATS_ENUM(name, ...) name 183 enum KeyIDs : size_t { PERFETTO_TP_STATS(PERFETTO_TP_STATS_ENUM), kNumKeys }; 184 185 // The code below declares an array for each property (name, type, ...). 186 187 #define PERFETTO_TP_STATS_NAME(name, ...) #name 188 constexpr char const* kNames[] = {PERFETTO_TP_STATS(PERFETTO_TP_STATS_NAME)}; 189 190 #define PERFETTO_TP_STATS_TYPE(_, type, ...) type 191 constexpr Type kTypes[] = {PERFETTO_TP_STATS(PERFETTO_TP_STATS_TYPE)}; 192 193 #define PERFETTO_TP_STATS_SEVERITY(_, __, severity, ...) severity 194 constexpr Severity kSeverities[] = { 195 PERFETTO_TP_STATS(PERFETTO_TP_STATS_SEVERITY)}; 196 197 #define PERFETTO_TP_STATS_SOURCE(_, __, ___, source, ...) source 198 constexpr Source kSources[] = {PERFETTO_TP_STATS(PERFETTO_TP_STATS_SOURCE)}; 199 200 } // namespace stats 201 } // namespace trace_processor 202 } // namespace perfetto 203 204 #endif // SRC_TRACE_PROCESSOR_STORAGE_STATS_H_ 205