You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@kudu.apache.org by ad...@apache.org on 2019/12/29 18:58:46 UTC
[kudu] 05/07: KUDU-3029 Define CycleClock::Now for aarch64
This is an automated email from the ASF dual-hosted git repository.
adar pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/kudu.git
commit f9304fddcdf96f27d4f9c9895efb7487afaca6e5
Author: huangtianhua <hu...@gmail.com>
AuthorDate: Thu Dec 19 06:48:52 2019 +0000
KUDU-3029 Define CycleClock::Now for aarch64
System timer of ARMv8 runs at a different frequency than the CPU's.
Add definition of CycleClock::Now to support aarch64.
Change-Id: If389e6faf3899ac33bf9e954fe9c4f6b909227da
Reviewed-on: http://gerrit.cloudera.org:8080/14929
Reviewed-by: Adar Dembo <ad...@cloudera.com>
Tested-by: Kudu Jenkins
---
src/kudu/gutil/cycleclock-inl.h | 12 ++++++++++++
1 file changed, 12 insertions(+)
diff --git a/src/kudu/gutil/cycleclock-inl.h b/src/kudu/gutil/cycleclock-inl.h
index 7738592..c913d51 100644
--- a/src/kudu/gutil/cycleclock-inl.h
+++ b/src/kudu/gutil/cycleclock-inl.h
@@ -192,6 +192,18 @@ inline int64 CycleClock::Now() {
}
// ----------------------------------------------------------------
+#elif defined(__aarch64__)
+#include "kudu/gutil/sysinfo.h"
+inline int64 CycleClock::Now() {
+ // System timer of ARMv8 runs at a different frequency than the CPU's.
+ // The frequency is fixed, typically in the range 1-50MHz. It can be
+ // read at CNTFRQ special register. We assume the OS has set up
+ // the virtual timer properly.
+ int64_t virtual_timer_value;
+ asm volatile("mrs %0, cntvct_el0" : "=r"(virtual_timer_value));
+ return virtual_timer_value;
+}
+// ----------------------------------------------------------------
#else
// The soft failover to a generic implementation is automatic only for some
// platforms. For other platforms the developer is expected to make an attempt