summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorMark Salyzyn <salyzyn@google.com>2018-01-24 14:00:19 -0800
committerMichael Bestas <mkbestas@lineageos.org>2019-12-23 23:43:40 +0200
commite2495b88b595e304101a063cd9e28d9c17694d41 (patch)
treec642aade16e4e5079530f8e167a8206144380f2b /lib
parenta230b07de3633069ec1027bea2a30554faf93205 (diff)
ANDROID: clock_gettime(CLOCK_BOOTTIME,) slows down >20x
clock_gettime(CLOCK_BOOTTIME,) slows down after significant accumulation of suspend time creating a large offset between it and CLOCK_MONOTONIC time. The __iter_div_u64_rem() is only for the usage of adding a few second+nanosecond times and saving cycles on more expensive remainder and division operations, but iterates one second at a time which quickly goes out of scale in CLOCK_BOOTTIME's case since it was specified as nanoseconds only. The fix is to split off seconds from the boot time and cap the nanoseconds so that __iter_div_u64_rem does not iterate. Signed-off-by: Mark Salyzyn <salyzyn@google.com> Bug: 72406285 Change-Id: Ia647ef1e76b7ba3b0c003028d4b3b955635adabb
Diffstat (limited to 'lib')
-rw-r--r--lib/vdso/vgettimeofday.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/lib/vdso/vgettimeofday.c b/lib/vdso/vgettimeofday.c
index 00d93df8045f..8ca2b5374c2d 100644
--- a/lib/vdso/vgettimeofday.c
+++ b/lib/vdso/vgettimeofday.c
@@ -252,7 +252,8 @@ static notrace int do_monotonic_raw(const struct vdso_data *vd,
static notrace int do_boottime(const struct vdso_data *vd, struct timespec *ts)
{
u32 seq, mult, shift;
- u64 nsec, cycle_last, wtm_nsec;
+ u64 nsec, cycle_last;
+ vdso_wtm_clock_nsec_t wtm_nsec;
#ifdef ARCH_CLOCK_FIXED_MASK
static const u64 mask = ARCH_CLOCK_FIXED_MASK;
#else
@@ -277,7 +278,7 @@ static notrace int do_boottime(const struct vdso_data *vd, struct timespec *ts)
sec = vd->xtime_clock_sec;
nsec = vd->xtime_clock_snsec;
- sec += vd->wtm_clock_sec;
+ sec += vd->wtm_clock_sec + vd->btm_sec;
wtm_nsec = vd->wtm_clock_nsec + vd->btm_nsec;
} while (unlikely(vdso_read_retry(vd, seq)));