diff options
author | Android Build Coastguard Worker <android-build-coastguard-worker@google.com> | 2023-07-08 04:42:02 +0000 |
---|---|---|
committer | Android Build Coastguard Worker <android-build-coastguard-worker@google.com> | 2023-07-08 04:42:02 +0000 |
commit | 0b7f6188999de41831050dc8e7fb6ff730b7ff67 (patch) | |
tree | 90bb3813b2e964d5e7e5c3cb42cc08f6e267240e | |
parent | 1265f0a23957196e60991d64fcfa31c29fc77565 (diff) | |
parent | d6f259b4285f74ed240a6392a7c2b2812ed1320f (diff) | |
download | extras-0b7f6188999de41831050dc8e7fb6ff730b7ff67.tar.gz |
Snap for 10460766 from d6f259b4285f74ed240a6392a7c2b2812ed1320f to mainline-healthfitness-release
Change-Id: Iea0f5dd966a447278ad6076de7a6bc508287e642
-rw-r--r-- | simpleperf/environment.cpp | 5 | ||||
-rw-r--r-- | simpleperf/test_util.cpp | 7 |
2 files changed, 7 insertions, 5 deletions
diff --git a/simpleperf/environment.cpp b/simpleperf/environment.cpp index 39803289..5ff09160 100644 --- a/simpleperf/environment.cpp +++ b/simpleperf/environment.cpp @@ -343,9 +343,10 @@ bool SetPerfEventLimits(uint64_t sample_freq, size_t cpu_percent, uint64_t mlock } // Wait for init process to change perf event limits based on properties. const size_t max_wait_us = 3 * 1000000; + const size_t interval_us = 10000; int finish_mask = 0; - for (size_t i = 0; i < max_wait_us && finish_mask != 7; ++i) { - usleep(1); // Wait 1us to avoid busy loop. + for (size_t i = 0; i < max_wait_us && finish_mask != 7; i += interval_us) { + usleep(interval_us); // Wait 10ms to avoid busy loop. if ((finish_mask & 1) == 0) { uint64_t freq; if (!GetMaxSampleFrequency(&freq) || freq == sample_freq) { diff --git a/simpleperf/test_util.cpp b/simpleperf/test_util.cpp index d93ddcd8..60d8ea35 100644 --- a/simpleperf/test_util.cpp +++ b/simpleperf/test_util.cpp @@ -85,9 +85,10 @@ bool HasHardwareCounter() { android::base::StartsWith(fingerprint, "google/sdk_gpc") || android::base::StartsWith(fingerprint, "generic/cf"); - if (arch == ARCH_X86_64 || arch == ARCH_X86_32 || is_emulator) { - // On x86 and x86_64, it's likely to run on an emulator or vm without hardware perf - // counters. It's hard to enumerate them all. So check the support at runtime. + if (arch == ARCH_X86_64 || arch == ARCH_X86_32 || !IsInNativeAbi() || is_emulator) { + // On x86 and x86_64, or when we are not in native abi, it's likely to run on an emulator or + // vm without hardware perf counters. It's hard to enumerate them all. So check the support + // at runtime. const simpleperf::EventType* type = simpleperf::FindEventTypeByName("cpu-cycles", false); CHECK(type != nullptr); perf_event_attr attr = CreateDefaultPerfEventAttr(*type); |