summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndroid Build Coastguard Worker <android-build-coastguard-worker@google.com>2023-07-06 20:21:33 +0000
committerGerrit Code Review <noreply-gerritcodereview@google.com>2023-07-06 20:21:33 +0000
commit1d163f5f506d86b9a1b9ec94bd43bacb0ba9fd36 (patch)
tree8b34ba9c9d38bcb1fc607ac203f205b5ef42ac14
parent5c1b24c921d5d423568ec973031ac8c81774fe7e (diff)
parentc11cddb4336e7094812507cc7ca0c579b8d89b27 (diff)
downloadextras-1d163f5f506d86b9a1b9ec94bd43bacb0ba9fd36.tar.gz
Merge "Snap for 10445396 from e89e0976796aa8c4a6a2091f7344e613e9b0de02 to android12-tests-release" into android12-tests-releaseandroid-vts-12.0_r9android-vts-12.0_r12android-vts-12.0_r11android-vts-12.0_r10android-cts-12.0_r9android-cts-12.0_r12android-cts-12.0_r11android-cts-12.0_r10
-rw-r--r--simpleperf/environment.cpp5
-rw-r--r--simpleperf/test_util.cpp7
2 files changed, 7 insertions, 5 deletions
diff --git a/simpleperf/environment.cpp b/simpleperf/environment.cpp
index 4c960350..35790370 100644
--- a/simpleperf/environment.cpp
+++ b/simpleperf/environment.cpp
@@ -331,9 +331,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 d85294f5..4a6c53d5 100644
--- a/simpleperf/test_util.cpp
+++ b/simpleperf/test_util.cpp
@@ -80,9 +80,10 @@ bool HasHardwareCounter() {
bool is_emulator = android::base::StartsWith(fingerprint, "google/sdk_gphone") ||
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);