summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Kevin Jeon <kevinjeon@google.com> 2023-04-07 14:27:11 -0400
committer Kevin Jeon <kevinjeon@google.com> 2023-04-07 16:40:33 -0400
commitd0f8a98472c9846a5749dd3cccdaee91ffa0822d (patch)
tree5406d7c9864a21f2f061641bf92d9e8727aaca23
parent9a983f2f5ece94cdcddf86392d2987837a402e9b (diff)
Skip dumping backtraces for cached processes
This change updates dumpstate to skip dumping backtraces for cached processes. These processes are less likely to be causing bugreport-necessitating issues, and if they are frozen, will cause backtrace dumps to time out anyways. This results in a ~50% decrease (21.327s -> 10.568s) in the time taken to run DUMP TRACES. Test: On a local device, check with bugreportz that there are no more timed-out backtrace dumps (i.e. that the "Dump failed, likely due to a timeout" failure no longer occurs). Test: Run health/bugreport/capturebugreport on an internal build and verify that the DUMP TRACES section is much shorter. Bug: 276451949 Change-Id: Iecb6c2168a0dccefecf3b92be24c647eaf729556
-rw-r--r--cmds/dumpstate/dumpstate.cpp10
-rw-r--r--libs/dumputils/dump_utils.cpp16
-rw-r--r--libs/dumputils/include/dumputils/dump_utils.h2
3 files changed, 28 insertions, 0 deletions
diff --git a/cmds/dumpstate/dumpstate.cpp b/cmds/dumpstate/dumpstate.cpp
index 7537237f65..bb4d58b153 100644
--- a/cmds/dumpstate/dumpstate.cpp
+++ b/cmds/dumpstate/dumpstate.cpp
@@ -2196,6 +2196,16 @@ Dumpstate::RunStatus Dumpstate::DumpTraces(const char** path) {
continue;
}
+ // Skip cached processes.
+ if (IsCached(pid)) {
+ // For consistency, the header and footer to this message match those
+ // dumped by debuggerd in the success case.
+ dprintf(fd, "\n---- pid %d at [unknown] ----\n", pid);
+ dprintf(fd, "Dump skipped for cached process.\n");
+ dprintf(fd, "---- end %d ----", pid);
+ continue;
+ }
+
const std::string link_name = android::base::StringPrintf("/proc/%d/exe", pid);
std::string exe;
if (!android::base::Readlink(link_name, &exe)) {
diff --git a/libs/dumputils/dump_utils.cpp b/libs/dumputils/dump_utils.cpp
index 067ce17c33..97cb810404 100644
--- a/libs/dumputils/dump_utils.cpp
+++ b/libs/dumputils/dump_utils.cpp
@@ -16,6 +16,7 @@
#include <set>
#include <android-base/file.h>
+#include <android-base/parseint.h>
#include <android-base/properties.h>
#include <android-base/stringprintf.h>
#include <android-base/strings.h>
@@ -210,3 +211,18 @@ bool IsZygote(int pid) {
return cmdline == "zygote" || cmdline == "zygote64" || cmdline == "usap32" ||
cmdline == "usap64" || cmdline == "webview_zygote";
}
+
+bool IsCached(int pid) {
+ std::string oom_score_adj;
+ if (!android::base::ReadFileToString(android::base::StringPrintf("/proc/%d/oom_score_adj",
+ pid),
+ &oom_score_adj)) {
+ return false;
+ }
+ int32_t oom_score_adj_value;
+ if (!android::base::ParseInt(android::base::Trim(oom_score_adj), &oom_score_adj_value)) {
+ return false;
+ }
+ // An OOM score greater than 900 indicates a cached process.
+ return oom_score_adj_value >= 900;
+}
diff --git a/libs/dumputils/include/dumputils/dump_utils.h b/libs/dumputils/include/dumputils/dump_utils.h
index 7c5329d01b..f973d9fb52 100644
--- a/libs/dumputils/include/dumputils/dump_utils.h
+++ b/libs/dumputils/include/dumputils/dump_utils.h
@@ -25,4 +25,6 @@ std::set<int> get_interesting_pids();
bool IsZygote(int pid);
+bool IsCached(int pid);
+
#endif // DUMPUTILS_H_