summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Mythri Alle <mythria@google.com> 2023-07-19 09:56:49 +0000
committer Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com> 2023-07-19 09:56:49 +0000
commite7d2bea79856ca3716a3df3988790fee21272c39 (patch)
tree0be0a5e96d28302608f5858a1b34f56ea3e3d2bb
parent20b42c83471934c5f9a9effce41d1e6e865c14e1 (diff)
parent25f11acb0589186d5e7784fc9337757f210f8e3c (diff)
Don't use timestamp counters on ARM32 am: d955ee5d83 am: 25f11acb05
Original change: https://googleplex-android-review.googlesource.com/c/platform/art/+/24114904 Change-Id: I8dfbd25525c82b396d25a350508eee8b5c263c3e Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
-rw-r--r--runtime/trace.cc20
1 files changed, 11 insertions, 9 deletions
diff --git a/runtime/trace.cc b/runtime/trace.cc
index 429a5ae591..92f46c299c 100644
--- a/runtime/trace.cc
+++ b/runtime/trace.cc
@@ -91,10 +91,14 @@ double tsc_to_microsec_scaling_factor = -1.0;
uint64_t GetTimestamp() {
uint64_t t = 0;
#if defined(__arm__)
- // See Architecture Reference Manual ARMv7-A and ARMv7-R edition section B4.1.34
- // Q and R specify that they should be written to lower and upper halves of 64-bit value.
- // See: https://llvm.org/docs/LangRef.html#asm-template-argument-modifiers
- asm volatile("mrrc p15, 1, %Q0, %R0, c14" : "=r"(t));
+ // On ARM 32 bit, we don't always have access to the timestamp counters from user space. There is
+ // no easy way to check if it is safe to read the timestamp counters. There is HWCAP_EVTSTRM which
+ // is set when generic timer is available but not necessarily from the user space. Kernel disables
+ // access to generic timer when there are known problems on the target CPUs. Sometimes access is
+ // disabled only for 32-bit processes even when 64-bit processes can accesses the timer from user
+ // space. These are not reflected in the HWCAP_EVTSTRM capability.So just fallback to
+ // clock_gettime on these processes. See b/289178149 for more discussion.
+ t = MicroTime();
#elif defined(__aarch64__)
// See Arm Architecture Registers Armv8 section System Registers
asm volatile("mrs %0, cntvct_el0" : "=r"(t));
@@ -173,11 +177,9 @@ void InitializeTimestampCounters() {
}
#if defined(__arm__)
- double seconds_to_microseconds = 1000 * 1000;
- uint64_t freq = 0;
- // See Architecture Reference Manual ARMv7-A and ARMv7-R edition section B4.1.21
- asm volatile("mrc p15, 0, %0, c14, c0, 0" : "=r"(freq));
- tsc_to_microsec_scaling_factor = seconds_to_microseconds / static_cast<double>(freq);
+ // On ARM 32 bit, we don't always have access to the timestamp counters from
+ // user space. Seem comment in GetTimestamp for more details.
+ tsc_to_microsec_scaling_factor = 1.0;
#elif defined(__aarch64__)
double seconds_to_microseconds = 1000 * 1000;
uint64_t freq = 0;