diff options
author | android-build-team Robot <android-build-team-robot@google.com> | 2021-01-23 00:11:03 +0000 |
---|---|---|
committer | android-build-team Robot <android-build-team-robot@google.com> | 2021-01-23 00:11:03 +0000 |
commit | e03dfa9f62027bc0d8284b5d028e3f13b24c5eae (patch) | |
tree | 43e7a1a4c8fa5b889c6e2b4c3e91f5e444c48fbb | |
parent | 01f9fc91ebda6fe1d94febe66e43a3bb236bb0ba (diff) | |
parent | 8ea10819ca6a3333f488fdfdf2e8eef5cc3ac3cf (diff) | |
download | libhidl-android11-qpr3-release.tar.gz |
Snap for 7097726 from 8ea10819ca6a3333f488fdfdf2e8eef5cc3ac3cf to rvc-qpr3-releaseandroid-11.0.0_r46android-11.0.0_r43android-11.0.0_r40android-11.0.0_r39android-11.0.0_r38android11-qpr3-s1-releaseandroid11-qpr3-release
Change-Id: Ib811e16031a8e45c9b8977d5997ab366c6fc0859
-rw-r--r-- | transport/ServiceManagement.cpp | 64 |
1 files changed, 1 insertions, 63 deletions
diff --git a/transport/ServiceManagement.cpp b/transport/ServiceManagement.cpp index 5f92dc1..a7e9626 100644 --- a/transport/ServiceManagement.cpp +++ b/transport/ServiceManagement.cpp @@ -153,70 +153,8 @@ __attribute__((noinline)) static void tryShortenProcessName(const std::string& d namespace details { -/* - * Returns the age of the current process by reading /proc/self/stat and comparing starttime to the - * current time. This is useful for measuring how long it took a HAL to register itself. - */ -__attribute__((noinline)) static long getProcessAgeMs() { - constexpr const int PROCFS_STAT_STARTTIME_INDEX = 21; - std::string content; - if (!android::base::ReadFileToString("/proc/self/stat", &content, false)) { - LOG(ERROR) << "Process age: Could not read /proc/self/stat"; - return -1; - } - - std::vector<std::string> stats = android::base::Split(content, " "); - if (PROCFS_STAT_STARTTIME_INDEX >= stats.size()) { - LOG(ERROR) << "Process age: Could not read starttime from /proc/self/stat"; - return -1; - } - - const std::string& startTimeString = stats.at(PROCFS_STAT_STARTTIME_INDEX); - unsigned long long startTimeInClockTicks = 0; - if (!android::base::ParseUint(startTimeString, &startTimeInClockTicks)) { - LOG(ERROR) << "Process age: Could not parse start time: " << startTimeString; - return -1; - } - - const int64_t ticksPerSecond = sysconf(_SC_CLK_TCK); - if (ticksPerSecond <= 0) { - LOG(ERROR) << "Process age: Invalid _SC_CLK_TCK: " << ticksPerSecond; - return -1; - } - - const int64_t uptime = android::uptimeMillis(); - if (uptime < 0) { - LOG(ERROR) << "Process age: Invalid uptime: " << uptime; - return -1; - } - - unsigned long long startTimeTicks; - if (__builtin_umulll_overflow(1000ULL, startTimeInClockTicks, &startTimeTicks)) { - LOG(ERROR) << "Process age: Too many ticks, overflow: " << startTimeInClockTicks; - return -1; - } - - long startTimeMs = startTimeTicks / ticksPerSecond; - if (startTimeMs >= uptime) { - LOG(ERROR) << "Process age: process started in future: " << startTimeMs << " after " - << uptime; - return -1; - } - - return uptime - startTimeMs; -} - static void onRegistrationImpl(const std::string& descriptor, const std::string& instanceName) { - long halStartDelay = getProcessAgeMs(); - if (halStartDelay >= 0) { - // The "start delay" printed here is an estimate of how long it took the HAL to go from - // process creation to registering itself as a HAL. Actual start time could be longer - // because the process might not have joined the threadpool yet, so it might not be ready to - // process transactions. - LOG(INFO) << "Registered " << descriptor << "/" << instanceName << " (start delay of " - << halStartDelay << "ms)"; - } - + LOG(INFO) << "Registered " << descriptor << "/" << instanceName; tryShortenProcessName(descriptor); } |