aboutsummaryrefslogtreecommitdiff
path: root/cpp/watchdog
AgeCommit message (Collapse)Author
2022-03-03Move proc fs access check outside constructor.Lakshman Annadorai
The car watchdog native daemon unittest, libwatchdog_test, is killed due to sepolicy violation. This violation happens when the unittest accesses proc fs files. Move the proc fs access check outside the constructors, so classes that depend on the proc fs collectors can mock them safely after calling the real constructors. - Update UidStatsCollector to check whether UidIoStatsCollector is enabled. - Refactor WatchdogPerfServiceTest to use a test class as it makes the tests cleaner. - Add missing GUARDED_BY statements in UidStatsCollector. Test: atest libwatchdog_test Bug: 216642418 Bug: 215711169 Change-Id: If750481cb95803253c2787c7e4459b68271bb8d7 Merged-In: If750481cb95803253c2787c7e4459b68271bb8d7 (cherry picked from commit 287c8fc74d88b0c781d1ba7808730df65e2f950e)
2022-02-03Start carwatchdogd during init instead of early init.Lakshman Annadorai
- This is done to ensure system stability during boot-up and provide guarantee that watchdog access resources after they are available. Test: System boot-up is okay. Bug: 217510234 Change-Id: I002a57c43703a805e241482d6d094f5e8f5259f4 Merged-In: I002a57c43703a805e241482d6d094f5e8f5259f4 (cherry picked from commit 6b997d890e32954c5cb7fe03181acae04b115a18)
2022-01-28Fix memset size in PackageInfoResolverTest.Lakshman Annadorai
Bug: 207508335 Test: WITH_TIDY=1 mm; atest libwatchdog_test Change-Id: I3e1546ce1b0ee09cec3345a93a4243a0cac4936b Merged-In: I3e1546ce1b0ee09cec3345a93a4243a0cac4936b (cherry picked from commit 9a4a33690b5c622f6ad17d6a0dd394125ea2589a)
2021-11-19Remove stats for deleted user on watchdog daemon side.Lakshman Annadorai
- CarService receives user removed broadcast when a user is deleted. Forward this signal to watchdog daemon, so the daemon can remove the I/O usage stats cached for the deleted user. Test: atest CarWatchdogServiceUnitTest libwatchdog_test Bug: 183413754 Change-Id: Ib3ceead4175e80e307f5044e41bd56b8768273a6 Merged-In: Ib3ceead4175e80e307f5044e41bd56b8768273a6 (cherry-picked from commit 0669122f9e31e34db53d62e19b6d99d02b9554c4)
2021-11-10Remove unused actionTakenOnResourceOveruse watchdog daemon AIDL method.Lakshman Annadorai
- actionTakenOnResourceOveruse is supposed to be used by CarService to notify watchdog daemon of the actions taken on packages on resource overuse. And the watchdog daemon will use the notification to upload metrics. - However, the metrics logging was moved to Carservice and watchdog daemon doesn't need to be notified of the actions taken on resource overuse. Test: CarWatchdogServiceUnitTest WatchdogStorageUnitTest \ libwatchdog_test CarWatchdogDaemonHelperTest Bug: 203247108 Change-Id: Ie14e79c988adc6ab2ea8b06775d65459d1b1db5b Merged-In: Ie14e79c988adc6ab2ea8b06775d65459d1b1db5b (cherry picked from commit 98b6b1b3a5460873f1ee915775e0d1ee4efe221f)
2021-10-27Merge "Enlengthen VHAL health check if a device is slow" into sc-v2-devTreeHugger Robot
2021-10-25Enlengthen VHAL health check if a device is slowEric Jeong
- Car watchdog uses the given interval to check VHAL health, if ro.carwatchdog.vhal_healthcheck.interval is set. - If it is not set or shoter than 3s, car watchdog uses the default interval, 3s. Bug: 193742550 Test: VHAL on AA emulator should not be killed by car watchdog Change-Id: I39e4b886ca22c02409475ba170f666b85bffadf0
2021-10-21Watchdog detects multiple resource overuses during consecutive polls.Jahdiel Alvarez
- Added forgivenWriteBytes fields to PackageIoOveruseStats in order to sync the forgivenWriteBytes calculated in watchdog daemon to CarService. - Watchdog daemon attributes the number of overuses proportional to the number of times an app/service exceeds the threshold in between polls. Test: atest libwatchdog_test CarWatchdogServiceUnitTest CtsCarTestCases:CarWatchdogDaemonTest CtsCarTestCases:CarWatchdogManagerTest Bug: 195328834 Merged-In: Ifc3e223a95675189126093056e8c5c0192c17c46 Change-Id: Ifc3e223a95675189126093056e8c5c0192c17c46
2021-10-15Fetch today's I/O usage stats collected during previous boot.Lakshman Annadorai
Watchdog daemon fetches today's I/O usage stat, that were collected during the previous boot, from CarWatchdogService, so the daemon can the have the aggregated view of the total bytes written to disk since the beginning of the day. Test: atest CarWatchdogServiceUnitTest WatchdogStorageUnitTest libwatchdog_test Bug: 192665981 Change-Id: Ieb3f3ba27d4d94f68f94788a364007fbc022a872 Merged-In: Ieb3f3ba27d4d94f68f94788a364007fbc022a872 (cherry picked from commit 766a91829ffdb341a6d59ed65e7e0d2f38273357)
2021-10-13Link internal libraries as static_libs or whole_static_libs.Lakshman Annadorai
- Link VHal HIDL as whole static lib in the test binary. This requires removing the HIDL dependency as shared lib from carwatchdog defaults. Test: atest libwatchdog_test Fix: 202443874 Change-Id: Iaffe71ae9ad4a4f5e6da3ba0af72d817977c5baa Merged-In: Iaffe71ae9ad4a4f5e6da3ba0af72d817977c5baa
2021-09-20Reuse constructPackageInfo method from PackageInfoTestUtils.Lakshman Annadorai
- Use const references in tets matchers. - Address some minor nits. Test: atest libwatchdog_test Bug: 199782126 Change-Id: If39d5ef31d9705f6471f0875ac3e1f93aa1932b6
2021-09-20Update IoOveruseMonitor to use UidStatsCollector.Lakshman Annadorai
- IoOveruseMonitor process per-UID I/O stats and detects I/O overuse. Update this class to use UidStatsCollector instead of directly using process or I/O stats collectors. - Remove the logic to resolve package/service name from UID because this is already done by UidStatsCollector. - Address some minor nits in IoOveruseMonitor. Test: atest libwatchdog_test Bug: 199782126 Change-Id: I74dfc03204ebd72b3404da8b9efe3210eb146338
2021-09-20Update IoPerfCollection to use UidStatsCollector.Lakshman Annadorai
- IoPerfCollection process performance data and reports them to bugreport. Update this class to use UidStatsCollector instead of directly using process or I/O stats collectors. - Remove the logic to resolve package/service name from UID because this is already done by UidStatsCollector. - Refactor internal structs to cache user package stats for both I/O and proc stats. This makes easier to extend IoPerfCollection to process and report (to bugreport) memory and CPU stats in the future. - Update ProcStats struct field names to be similar to that of IoPerfCollection. Test: atest libwatchdog_test Bug: 199782126 Change-Id: I924d65b60e4b8c8eb41283b7c7f75bbe11aabb51
2021-09-20Update WatchdogPerfService to use UidStatsCollector.Lakshman Annadorai
- WatchdogPerfService triggers the performance data collection and processing. Update this class to use UidStatsCollector instead of directly using process or I/O stats collectors. - Mark const methods with the const keyword. Test: atest libwatchdog_test Bug: 199782126 Change-Id: I79e3c5d466657ff9589b8bbb9606ccb496c8c76a
2021-09-20Aggreated per-UID I/O and process stats with UidStatsCollector.Lakshman Annadorai
- Per-UID I/O stats and process stats are collected by different collectors. Aggregate these stats per-UID and resolve package/service names before forwarding them to data processors. - The constructPackageInfo test methods are used in multiple tests and are duplicated across the tests. Add a new PackageInfoTestUtils to consolidate these methods. Other tests will be updated to use this test utils in the following changes. Test: atest libwatchdog_test Bug: 199782126 Change-Id: Ib1221c968c3b6b8ff45971f4d369adbc06051188
2021-09-20Aggregate per-UID stats during /proc/PID stats collection.Lakshman Annadorai
- Refactor UidProcStatsCollector to perform per-UID stats aggregation as soon as per-PID stats are collected. - Add UidProcStatsCollectorInterface for mocking in the test because marking implementation methods as virtual for testing purposes has performance overhead in prod. - Return only aggregated per-UID and per-PID stats and drop unnecessary per-thread stats. - Remove per process memory stats read from /proc/[PID]/status file because they are inaccurate and memory stats will be read with libmeminfo. - Replace isEqual test methods with test matchers. - Add UidProcStatsCollector's test matchers to a separate test utils. This will be also used by UidStatsCollectorTest in the following change. Test: atest libwatchdog_test Bug: 199782126 Change-Id: I30a20abf8fe882b3e401889d67a1eb4f494a25ab
2021-09-20Refactor UidIoStatsCollector implementation.Lakshman Annadorai
- Remove unnecessary nesting of IoUsage inside UidIoUsage. - Rename the internal struct such that it is similar to the class name. - Add UidIoStatsCollectorInterface for mocking in the test because marking implementation methods as virtual for testing purposes has performance overhead in prod. - Remove redundant uid information in the struct. Test: atest libwatchdog_test Bug: 199782126 Change-Id: Ieacb4352ecd7b46c049a24213dd511cf5fa36182
2021-09-14Rename UidIoStats and ProcPidStat classes.Lakshman Annadorai
- Rename UidIoStats to UidIoStatsCollector and ProcPidStat to UidProcStatsCollector. - These classes will be refactored in the following changes. The renaming is done in a separate CL, so git will preserve the file history. Test: atest libwatchdog_test Bug: 199782126 Change-Id: I492d0ee82e2ec38acec1419cad9feaefc14335f1
2021-08-19Merge "Allow carwatchdogd to read/write from /data/system/car." into sc-v2-devTreeHugger Robot
2021-08-12Allow carwatchdogd to read/write from /data/system/car.Lakshman Annadorai
On init, carwatchdogd reads the resource overuse configurations from the /data/system/car/watchdog directory. On each config update, carwatchdogd writes the resource overuse configurations to the /data/system/car/watchdog directory. Test: No seplicy violations Fixes: 193181896 Change-Id: Ie5cf9d08963a50c380e76cce68ef30f8de5d7c3c
2021-08-09Make CarService set resource configurations validation more robustJahdiel Alvarez
Initial validation for setting ResourceOveruseConfigurations through CarWatchdogService. Test: atest libwatchdog_test CarWatchdogServiceUnitTest Bug: 194925492 Change-Id: I1732257a814ad5aca0955195a9674b652a96b013
2021-07-21Merge "Handle shared UID in watchdog daemon." into sc-v2-devLakshman Annadorai
2021-07-19Support temporary disabling watchdog killingJahdiel Alvarez
Added command: "adb shell cmd car_service watchdog-control-health-check true|false" Set flag to true to disable car watchdog's process health checks. False, to enable it. When using the debugger in CarService use the command "adb shell cmd car_service watchdog-control-health-check true" in order to avoid car watchdog killing car service because of ANR. Once you finish, debugging run the command but with the false flag, to enable watchdog again. Test: atest libwatchdog_test CarWatchdogDaemonHelperTest CarWatchdogServiceUnitTest Test: Run adb shell cmd car_service watchdog-control-health-check true Bug: 182570176 Change-Id: I566cf25f5e091e50eea97e45909dfa24224f4a81
2021-07-15Loose timeout for car watchdog ANREric Jeong
- On emulator, VHAL is killed by car watchdog sometime because VHAL is not able to generate heartbeat on time due to emulator's low performance. - We are going to add a configurable setting to control timeout per device(b/193742550), but as a temporary solution we increase the timeout to 6s for all devices. Bug: 193263201 Test: make sure emulator VHAL is not crashed at boot phase Change-Id: I78a2f08c147fa69cc5e54edbdddfa8500c90f70f
2021-07-14Handle shared UID in watchdog daemon.Lakshman Annadorai
- Daemon should mark a shared UID as safe-to-kill when at least one package is marked as safe-to-kill in the config. - Shared package names contain the "shared:" prefix and the package specific thresholds and safe-to-kill checking are done with the prefix. - When app cateogry is not mapped by the shared package name, fallback to fetching app category mapped to any package under the shared UID. Test: atest libwatchdog_test Bug: 191892687 Change-Id: If3a0f3887eeac9475b984441b1e1965d72f7720c
2021-07-01Merge "Fix packageSpecificThreshold in system_overuse_configuration.xml" ↵TreeHugger Robot
into sc-dev
2021-07-01Fix packageSpecificThreshold in system_overuse_configuration.xmlJahdiel Alvarez
Test: Test: Open KitchenSink app. Select watchdog. Run: adb shell dumpsys android.automotive.watchdog.ICarWatchdog/default --start_perf --max-duration 600 --interval 1 Run: adb shell dumpsys android.automotive.watchdog.ICarWatchdog/default --reset_resource_overuse_stats shared:com.google.android.car.uid.kitchensink Finally, select I/O Overuse Warning button. Bug: 192580516 Change-Id: I2773660df686825b385026b53ecbbc56adb7f7cc
2021-06-30Update PowerCycle and GarageMode handling in watchdog.Lakshman Annadorai
PowerCycle states in the PowerCycle.aidl are ambiguous and unused. Refactor the AIDL enums to match the actual power cycle states. Add a new GarageMode AIDL enum to represent the garage mode states. Test: atest libwatchdog_test CarWatchdogServiceUnitTest Bug: 191815866 Change-Id: I6084c71675b940f570457b1ba5e5a0082680602b
2021-06-29Write resource overuse configs to disk on a new update.Lakshman Annadorai
Resource overuse configs will be marked for writting to disk on each update. The writing will happen asynchronously on a new thread. When the writing fails, the error is logged and writing is not retried as this is a rare scenario and an indication of the system in a bad state. Test: atest libwatchdog_test Bug: 185287136 Change-Id: Ie9f1a845a6ded96e66fbf931746998bcf0e0466e
2021-06-22Merge "Handle garage mode I/O overuse monitoring." into sc-devTreeHugger Robot
2021-06-22Handle garage mode I/O overuse monitoring.Lakshman Annadorai
- Propagate CarService's PowerCycle change notification to WatchdogPerfHandler and handle garage mode switching in I/O overuse monitor. Test: atest libwatchdog_test Bug: 185498771 Bug: 187943270 Change-Id: I4429f135903328815e3e4d791fe7a9d4f678dc09
2021-06-22Merge "Implement resource overuse configuration XML writing." into sc-devTreeHugger Robot
2021-06-16Specify aidl version in vint fragment xmlEric Jeong
- android.automotive.watchdog supports verion 2 and 3, while carwatchdogd specifies no aidl version, which means version 1 is used by default. - This leads to vts test fail. - carpowerpolicyd doesn't specify aidl version, either. This CL explicitly sepcifies aidl version as 1.0 for android.frameworks.automotive.powerpolicy. Bug: 190737762 Bug: 190615475 Test: in vts-tradefed, run vts -m vts_treble_vintf_framework_test -t FrameworkManifest/SingleManifestTest#ManifestAidlHalsServed/0 Change-Id: I7b31ab5b65f90a31f5939b4be95a42c3352c0e37
2021-06-10Implement resource overuse configuration XML writing.Lakshman Annadorai
The XML writer will be used by the IoOveruseConfigs module to write configs to disk on update. Test: atest libwatchdog_test Bug: 185287136 Change-Id: If12e61b095749fb982f139622421c7c0a43db59a
2021-06-09Reformat repeating threshold tags in XML configs.Lakshman Annadorai
Reformat repeating thresholds such that they are enclosed within an outer tag. System-wide thresholds are enclosed with systemWideThresholds tag and individual thresholds are enclosed with in alertThreshold tag. Package specific and app category thresholds are enclosed with in packageSpecificThresholds and appCategorySpecificThresholds tags, respectively and individual thresholds are enclosed with in perStateThreshold tag. Test: atest libwatchdog_test Bug: 186445673 Change-Id: I1ede554bc5d0b1478c669f25180ed03765c39b78
2021-06-09Revert^2 "Read the on-device XML configurations on initial..."Lakshman Annadorai
Revert submission 14910053-revert-14793817-DTYDVHIJVU Reason for revert: Added the offending artifacts to the allowed list. Reverted Changes: I3dc9c8d42:Revert "Read the on-device XML configurations on i... I5784c9cb2:Revert "Convert per state thresholds read from XML... Test: atest libwatchdog_test Bug: 186445673 Change-Id: I65f6009e52d0b733197513484a980cdbb5550aaf
2021-06-09Revert^2 "Convert per state thresholds read from XML configs."Lakshman Annadorai
b62fb474b6eef1c948951b0b97103fad103abba3 Test: atest libwatchdog_test Bug: 186445673 Change-Id: I5ccfb50af9260821001340e0ba373d267d804346
2021-06-09Revert "Convert per state thresholds read from XML configs."Santos Cordon
Revert submission 14793817 Reason for revert: b/190582171 Reverted Changes: I431fe6b70:Convert per state thresholds read from XML configs... I94e08d618:Read the on-device XML configurations on initializ... Bug: 190582171 Change-Id: I5784c9cb2d36d68cf16a84ec1cbfa2adc316e704
2021-06-09Revert "Read the on-device XML configurations on initialization."Santos Cordon
Revert submission 14793817 Reason for revert: b/190582171 Reverted Changes: I431fe6b70:Convert per state thresholds read from XML configs... I94e08d618:Read the on-device XML configurations on initializ... Bug: 190582171 Change-Id: I3dc9c8d4278cd2243127086ebb90299177ff7d5e
2021-06-08Merge "Add VTS tests for CarWatchdog daemon's public AIDLs." into sc-devTreeHugger Robot
2021-06-07Add VTS tests for CarWatchdog daemon's public AIDLs.Lakshman Annadorai
Test: atest VtsAidlWatchdogTargetTest Fixes: 178112547 Change-Id: I95828b3f48d66c047533255bd301b27967f65eb7
2021-06-07Read the on-device XML configurations on initialization.Lakshman Annadorai
Update watchdog daemon to read the on-device resource overuse configurations, that are stored as XML files, on initialization. When latest configs are available under the data partition, watchdog daemon uses the latest configs. Otherwise, the XML configurations from the build are used. If all of these fail, watchdog daemon fallbacks to using int max as the default thresholds. When either of the vendor or third-party configurations aren't available, watchdog daemon uses the system component's thresholds for the vendor or third-party components. Test: atest libwatchdog_test Bug: 186445673 Change-Id: I94e08d618ff0cd164aadf4d37eae93e19b2dae67
2021-06-07Convert per state thresholds read from XML configs.Lakshman Annadorai
Per-state thresholds defined in the XML configs are represented in MiB. Convert these threholds to bytes before updating the in-memory cache. Test: atest libwatchdog_test Bug: 186445673 Change-Id: I431fe6b704472b945e617e0aa4cb6c365a1bcd08
2021-05-26Merge "Implement resource overuse config XML parser." into sc-devLakshman Annadorai
2021-05-25Implement resource overuse config XML parser.Lakshman Annadorai
The XML parser will be used by the I/O overuse monitoring module to parse on device XML config. Test: atest libwatchdog_test Bug: 186445673 Change-Id: I4415c315116ea75e8da1c4c535440e8e5bf6f750
2021-05-24Freeze AIDL APIs for SCJiyong Park
Bug: 188713899 Test: m Change-Id: I82932910e83a5efcea6d02d9a9440ca52d963c8d
2021-05-12Update get/set resource overuse configs CarService APIs.Lakshman Annadorai
Update the get/set resource overuse config CarService APIs return values to handle errors returned when processing these requests. Test: atest CarWatchdogManagerUnitTest CarWatchdogServiceUnitTest Bug: 186119640 Change-Id: Ia36c776f17939305e24cd048bb13f631b90f2f7b
2021-05-12Add dumpsys flag to reset resource overuse stats.Lakshman Annadorai
Command: adb dumpsys android.automotive.watchdog.ICarWatchdog/default --reset_resource_overuse_stats packageName,packageName Test: atest libwatchdog_test CarWatchdogServiceUnitTest Bug: 186045281 Change-Id: Ie674ae0cb6b828434c37311c2f8175de209f429e
2021-04-29Merge "Replace uint64_t with int64_t as bytes datatype in daemon." into sc-devTreeHugger Robot
2021-04-29Replace uint64_t with int64_t as bytes datatype in daemon.Lakshman Annadorai
int64_t has space to represent the 8 exabytes, which is a very large value. Test: atest libwatchdog_test Bug: 186784050 Change-Id: I312b5ae04e9bbdf0831206f586ea9c4c6818a306