summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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;