From f9af3fa4d54f253bcb42cf571bd309dea60bffb1 Mon Sep 17 00:00:00 2001 From: Jiakai Zhang Date: Fri, 26 Jul 2024 17:37:50 +0100 Subject: Fix big negative dex2oatWallTimeMillis. We calculate dex2oatWallTimeMillis by (uptime - starttime). To get a reasonable result, both times need to be from the same clock. However, it's unclear which clock the kernel uses for the latter. proc_pid_stat(5) does not have anything helpful on this matter: (22) starttime %llu The time the process started after system boot. Before Linux 2.6, this value was expressed in jiffies. Since Linux 2.6, the value is expressed in clock ticks (divide by sysconf(_SC_CLK_TCK)). The format for this field was %lu before Linux 2.6. To make sure we use the same clock, we obtain the uptime on process start as the start time. Bug: 315061143 Test: Presubmit Change-Id: I5f344e953a945656474b3f625368c1ccb5aa52d8 --- runtime/exec_utils.h | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'runtime/exec_utils.h') diff --git a/runtime/exec_utils.h b/runtime/exec_utils.h index ebcc2e4e66..61e9beae32 100644 --- a/runtime/exec_utils.h +++ b/runtime/exec_utils.h @@ -118,7 +118,10 @@ class EXPORT ExecUtils { virtual int64_t GetTicksPerSec() const; private: - bool GetStat(pid_t pid, /*out*/ ProcessStat* stat, /*out*/ std::string* error_msg) const; + bool GetStat(pid_t pid, + int64_t start_time, + /*out*/ ProcessStat* stat, + /*out*/ std::string* error_msg) const; }; inline bool Exec(const std::vector& arg_vector, /*out*/ std::string* error_msg) { -- cgit v1.2.3-59-g8ed1b