From aa7a37be7567e9028132ae84cec1ff156ccda573 Mon Sep 17 00:00:00 2001 From: jpolo1224 Date: Sun, 9 Aug 2026 02:56:50 -0400 Subject: [PATCH] Report real CPU usage on Android get_per_core_usage() fills the per-core vector with zeros and then wraps the whole Linux /proc/stat body in #ifndef ANDROID, because an app cannot read the per-cpu lines. The exclusion left the zeros in place, so the monitor did not go quiet -- it reported an idle machine. On device it logged "CPU Usage: Total: 0.0%, Cores: 0.0%, 0.0%, ..." while three emulator threads were pegged at 100%, which hides exactly the class of problem the monitor exists to surface. Report process usage from times(), which is POSIX and readable by our own process, and leave the per-core vector empty so perf_monitor prints no "Cores:" list rather than a fabricated one. --- rpcs3/util/cpu_stats.cpp | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/rpcs3/util/cpu_stats.cpp b/rpcs3/util/cpu_stats.cpp index 0f4149e90..dfb1b7dea 100644 --- a/rpcs3/util/cpu_stats.cpp +++ b/rpcs3/util/cpu_stats.cpp @@ -290,6 +290,20 @@ namespace utils { perf_log.error("Failed to open /proc/stat (%s)", strerror(errno)); } +#else + // Android has no per-core numbers to report: an app is not allowed to read the + // per-cpu lines of /proc/stat, which is why this branch was excluded in the first + // place. But excluding it left total_usage at 0.0 and per_core_usage full of the + // zeros filled in above, so the monitor did not go quiet -- it reported an idle + // machine. Observed on device logging "CPU Usage: Total: 0.0%, Cores: 0.0%, 0.0%, + // ..." while three emulator threads were pegged at 100%, which actively hides the + // class of bug this monitor exists to surface. + // + // times() is process-wide, POSIX, and readable by our own process, so report that + // and leave the per-core vector empty. perf_monitor only prints the "Cores:" list + // when it is non-empty, so nothing fabricates a per-core figure we cannot measure. + per_core_usage.clear(); + total_usage = get_usage(); #endif #else total_usage = get_usage();