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 17// Partial clone of frameworks/proto_logging/stats/atoms.proto. CarWatchdogService only uses small 18// number of atoms. 19 20syntax = "proto2"; 21 22package android.car.watchdog; 23option java_package = "com.android.car.watchdog"; 24option java_outer_classname = "AtomsProto"; 25 26/** 27 * Logs the current state of an application/process before it is killed. 28 * 29 * Keep in sync with proto file at frameworks/proto_logging/stats/atoms.proto 30 */ 31message CarWatchdogKillStatsReported { 32 // Linux process uid for the package. 33 optional int32 uid = 1; 34 35 // State of the uid when it was killed. 36 enum UidState { 37 UNKNOWN_UID_STATE = 0; 38 BACKGROUND_MODE = 1; 39 FOREGROUND_MODE = 2; 40 } 41 optional UidState uid_state = 2; 42 43 // System state indicating whether the system was in normal mode or garage mode. 44 enum SystemState { 45 UNKNOWN_SYSTEM_STATE = 0; 46 USER_INTERACTION_MODE = 1; 47 USER_NO_INTERACTION_MODE = 2; 48 GARAGE_MODE = 3; 49 } 50 optional SystemState system_state = 3; 51 52 // Reason for killing the application. 53 // Keep in sync with proto file at packages/services/Car/cpp/watchdog/proto 54 enum KillReason { 55 UNKNOWN_KILL_REASON = 0; 56 KILLED_ON_ANR = 1; 57 KILLED_ON_IO_OVERUSE = 2; 58 KILLED_ON_MEMORY_OVERUSE = 3; 59 } 60 optional KillReason kill_reason = 4; 61 62 // Stats of the processes owned by the application when the application was killed. 63 // The process stack traces are not collected when the application was killed due to IO_OVERUSE. 64 optional CarWatchdogProcessStats process_stats = 5; 65 66 // The application's I/O overuse stats logged only when the kill reason is KILLED_ON_IO_OVERUSE. 67 optional CarWatchdogIoOveruseStats io_overuse_stats = 6; 68} 69 70/** 71 * Logs the I/O overuse stats for an application on detecting I/O overuse. 72 * 73 * Keep in sync with proto file at frameworks/proto_logging/stats/atoms.proto 74 */ 75message CarWatchdogIoOveruseStatsReported { 76 // Linux process uid for the package. 77 optional int32 uid = 1; 78 79 // The application's I/O overuse stats. 80 optional CarWatchdogIoOveruseStats io_overuse_stats = 2; 81} 82 83/** 84 * Logs I/O overuse stats for a package. 85 * 86 * Keep in sync with proto file at frameworks/proto_logging/stats/atoms.proto 87 */ 88message CarWatchdogIoOveruseStats { 89 enum Period { 90 UNKNOWN_PERIOD = 0; 91 DAILY = 1; 92 WEEKLY = 2; 93 } 94 95 // Threshold and usage stats period. 96 optional Period period = 1; 97 98 // Threshold in-terms of write bytes defined for the package. 99 optional CarWatchdogPerStateBytes threshold = 2; 100 101 // Number of write bytes in each state for the specified period. 102 optional CarWatchdogPerStateBytes written_bytes = 3; 103 104 // Application or service uptime during the aforemetioned period. 105 optional uint64 uptime_millis = 4; 106}; 107 108/** 109 * Logs bytes attributed to each application and system states. 110 * 111 * Keep in sync with proto file at frameworks/proto_logging/stats/atoms.proto 112 */ 113message CarWatchdogPerStateBytes { 114 // Number of bytes attributed to the application foreground. 115 optional int64 foreground_bytes = 1; 116 117 // Number of bytes attributed to the application background. 118 optional int64 background_bytes = 2; 119 120 // Number of bytes attributed to the garage mode. 121 optional int64 garage_mode_bytes = 3; 122} 123 124/** 125 * Logs each CarWatchdogProcessStat in CarWatchdogProcessStats. 126 * 127 * Keep in sync with proto file at frameworks/proto_logging/stats/atoms.proto 128 */ 129message CarWatchdogProcessStats { 130 // Records the stats of the processes owned by an application. 131 repeated CarWatchdogProcessStat process_stat = 1; 132} 133 134/** 135 * Logs a process's stats. 136 * 137 * Keep in sync with proto file at frameworks/proto_logging/stats/atoms.proto 138 */ 139message CarWatchdogProcessStat { 140 // Command name of the process. 141 optional string process_name = 1; 142 143 // Process uptime. 144 optional uint64 uptime_millis = 2; 145 146 // Number of major page faults caused by the process and its children. 147 optional uint64 major_page_faults = 3; 148 149 // Peak virtual memory size in kb. 150 optional uint64 vm_peak_kb = 4; 151 152 // Virtual memory size in kb. 153 optional uint64 vm_size_kb = 5; 154 155 // Peak resident set size (high water mark) in kb. 156 optional uint64 vm_hwm_kb = 6; 157 158 // Resident set size in kb. 159 optional uint64 vm_rss_kb = 7; 160} 161 162/** 163 * Logs total I/O usage summary for all applications and services running in the system. 164 * 165 * Keep in sync with proto file at 166 * packages/services/Car/service/src/com/android/car/watchdog/proto/atoms.proto 167 * 168 * Pulled from: 169 * packages/services/Car/service/src/com/android/car/watchdog/WatchdogPerfHandler.java 170 */ 171message CarWatchdogSystemIoUsageSummary { 172 // I/O usage summary for the system. 173 optional CarWatchdogIoUsageSummary io_usage_summary = 1; 174 175 // Start time of the event in milliseconds since epoch. 176 // Note: This field must be a top-level field as it is used to slice the metrics. 177 optional int64 start_time_millis = 2; 178} 179 180/** 181 * Logs I/O usage summary for an UID. 182 * 183 * Keep in sync with proto file at 184 * packages/services/Car/service/src/com/android/car/watchdog/proto/atoms.proto 185 * 186 * Pulled from: 187 * packages/services/Car/service/src/com/android/car/watchdog/WatchdogPerfHandler.java 188 */ 189message CarWatchdogUidIoUsageSummary { 190 // UID of the application/service whose usage summary are recorded. 191 optional int32 uid = 1; 192 193 // I/O usage summary for the UID. 194 optional CarWatchdogIoUsageSummary io_usage_summary = 2; 195 196 // Start time of the event in milliseconds since epoch. 197 // Note: This field must be a top-level field as it is used to slice the metrics. 198 optional int64 start_time_millis = 3; 199} 200 201/** 202 * Logs I/O usage summary for a time period. 203 * 204 * Keep in sync with proto file at 205 * packages/services/Car/service/src/com/android/car/watchdog/proto/atoms.proto 206 * 207 * Pulled from: 208 * packages/services/Car/service/src/com/android/car/watchdog/WatchdogPerfHandler.java 209 */ 210message CarWatchdogIoUsageSummary { 211 // Summary event time period. 212 optional CarWatchdogEventTimePeriod event_time_period = 1; 213 214 // Daily I/O usage summary for the period. Logs summary entries only for days with I/O usage. 215 // The entries are ordered beginning from the event_time_period.start_time_millis. 216 repeated CarWatchdogDailyIoUsageSummary daily_io_usage_summary = 2; 217} 218 219/** 220 * Logs a car watchdog event's time period. 221 * 222 * Keep in sync with proto file at 223 * packages/services/Car/service/src/com/android/car/watchdog/proto/atoms.proto 224 * 225 * Pulled from: 226 * packages/services/Car/service/src/com/android/car/watchdog/WatchdogPerfHandler.java 227 */ 228message CarWatchdogEventTimePeriod { 229 enum Period { 230 UNKNOWN_PERIOD = 0; 231 WEEKLY = 1; 232 BIWEEKLY = 2; 233 MONTHLY = 3; 234 } 235 236 // Deprecated field - Start time of the event in milliseconds since epoch. 237 optional uint64 start_time_millis = 1 [deprecated = true]; 238 239 // Period for the event. 240 optional Period period = 2; 241} 242 243/** 244 * Logs daily I/O usage summary. 245 * 246 * Keep in sync with proto file at 247 * packages/services/Car/service/src/com/android/car/watchdog/proto/atoms.proto 248 * 249 * Pulled from: 250 * packages/services/Car/service/src/com/android/car/watchdog/WatchdogPerfHandler.java 251 */ 252message CarWatchdogDailyIoUsageSummary { 253 // Total bytes written to disk during a day. 254 optional CarWatchdogPerStateBytes written_bytes = 1; 255 256 // Total uptime for the system or service or application during a day. 257 optional uint64 uptime_millis = 2; 258 259 // Total disk I/O overuses during a day. 260 optional int32 overuse_count = 3; 261} 262