Add ELOG for CPU and memory limits
Bug: 74584014
Change-Id: Ib49963935ae848da661ffb1cdf16919cb05a4155
diff --git a/src/base/watchdog.cc b/src/base/watchdog.cc
index 991e82f..c7188c1 100644
--- a/src/base/watchdog.cc
+++ b/src/base/watchdog.cc
@@ -20,6 +20,7 @@
#include "perfetto/base/scoped_file.h"
#include <fcntl.h>
+#include <inttypes.h>
#include <signal.h>
#include <stdint.h>
#include <fstream>
@@ -165,6 +166,10 @@
// remains under our threshold.
if (memory_window_bytes_.Push(rss_bytes)) {
if (memory_window_bytes_.Mean() > memory_limit_bytes_) {
+ PERFETTO_ELOG(
+ "Memory watchdog trigger. Memory window of %f bytes is above the "
+ "%" PRIu32 " bytes limit.",
+ memory_window_bytes_.Mean(), memory_limit_bytes_);
kill(getpid(), SIGABRT);
}
}
@@ -187,6 +192,9 @@
double percentage = static_cast<double>(difference_ticks) /
static_cast<double>(window_interval_ticks) * 100;
if (percentage > cpu_limit_percentage_) {
+ PERFETTO_ELOG("CPU watchdog trigger. %f%% CPU use is above the %" PRIu32
+ "%% CPU limit.",
+ percentage, cpu_limit_percentage_);
kill(getpid(), SIGABRT);
}
}