From 6fe47695294b203a9c52c3485e58d01acb11b254 Mon Sep 17 00:00:00 2001 From: Olivier Gaillard Date: Thu, 20 Jan 2022 21:48:12 +0000 Subject: Add half watchdogs to dropbox and make the watchdog timeout configurable. The content of the half watchdog is now more consistent with watchdogs to make it more actionable (watchdog subject, memory psi, cpu data). The half watchdog is also published to dropbox in a similar way to the watchdog. We also use a thread to publish to dropbox to make sure that we do not block the watchdog handler code. For the half watchdog, we know wait for 5s to get the cpu data (similar to the watchdog) which delays the next run. That's only 10% of the default timeout though so that's not a big difference. For the configurable watchdog timeout, we delay fetching the value to be able to start the watchdog as early as possible when system server starts to detect blocked threads that might happen early. As well, even if fetching settings is broken, the watchdog will still be running with the default timeout values. Test: tested that the half watchdog is added to dropbox ~/master$ adb shell dumpsys dropbox | grep watchdog 2022-01-25 23:22:19 system_server_pre_watchdog (compressed text, 21612 bytes) 2022-01-25 23:22:56 system_server_watchdog (compressed text, 21386 bytes) 2022-01-25 23:29:09 system_server_pre_watchdog (compressed text, 21621 bytes) The watchdogs and half wathdogs were generated by adding a message with a long sleep on the ui thread Runnable runnable = new Runnable() { @Override public void run() { SystemClock.sleep(40_000); // 40s } }; Message msg = Message.obtain(UiThread.getHandler(), runnable); msg.setAsynchronous(true); UiThread.getHandler().sendMessage(msg); Bug: 209932320 Change-Id: I1bca723d1d7bee98dc7e1aade73a2e4384d6f035 --- services/java/com/android/server/SystemServer.java | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'services/java/com/android/server/SystemServer.java') diff --git a/services/java/com/android/server/SystemServer.java b/services/java/com/android/server/SystemServer.java index c9aeabd17191..a07501a707c4 100644 --- a/services/java/com/android/server/SystemServer.java +++ b/services/java/com/android/server/SystemServer.java @@ -1503,6 +1503,10 @@ public final class SystemServer implements Dumpable { SQLiteCompatibilityWalFlags.reset(); t.traceEnd(); + t.traceBegin("UpdateWatchdogTimeout"); + Watchdog.getInstance().registerSettingsObserver(context); + t.traceEnd(); + // Records errors and logs, for example wtf() // Currently this service indirectly depends on SettingsProvider so do this after // InstallSystemProviders. -- cgit v1.2.3