aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDrew Richardson <drew.richardson@arm.com>2014-08-19 08:44:27 -0700
committerJon Medhurst <tixy@linaro.org>2014-08-21 11:43:32 +0100
commitd403c3a216410919123459fc01151e87ddc38729 (patch)
treedb7a087c3eac2631c7b56349140bcc70183b1299
parent892ee55f71cdbbe0d8a471dcc0758cf9620b9944 (diff)
gator: Use get_monotonic_boottime to get uptime
In Linux 3.17-rc1, monotonic_to_bootbased was removed. Since Linux 3.11, uptime_proc_show in fs/proc/uptime.c has used get_monotonic_boottime to get uptime. Mirror the logic of uptime_proc_show. Signed-off-by: Drew Richardson <drew.richardson@arm.com>
-rw-r--r--driver/gator_main.c19
1 files changed, 13 insertions, 6 deletions
diff --git a/driver/gator_main.c b/driver/gator_main.c
index 0d867f2..2841203 100644
--- a/driver/gator_main.c
+++ b/driver/gator_main.c
@@ -812,19 +812,26 @@ static void gator_summary(void)
u64 timestamp, uptime;
struct timespec ts;
char uname_buf[512];
- void (*m2b)(struct timespec *ts);
snprintf(uname_buf, sizeof(uname_buf), "%s %s %s %s %s GNU/Linux", utsname()->sysname, utsname()->nodename, utsname()->release, utsname()->version, utsname()->machine);
getnstimeofday(&ts);
timestamp = timespec_to_ns(&ts);
- do_posix_clock_monotonic_gettime(&ts);
- // monotonic_to_bootbased is not defined for some versions of Android
- m2b = symbol_get(monotonic_to_bootbased);
- if (m2b) {
- m2b(&ts);
+ // Similar to reading /proc/uptime from fs/proc/uptime.c, calculate uptime
+#if LINUX_VERSION_CODE < KERNEL_VERSION(3, 11, 0)
+ {
+ void (*m2b)(struct timespec *ts);
+ do_posix_clock_monotonic_gettime(&ts);
+ // monotonic_to_bootbased is not defined for some versions of Android
+ m2b = symbol_get(monotonic_to_bootbased);
+ if (m2b) {
+ m2b(&ts);
+ }
}
+#else
+ get_monotonic_boottime(&ts);
+#endif
uptime = timespec_to_ns(&ts);
// Disable preemption as gator_get_time calls smp_processor_id to verify time is monotonic