ANDROID: clock_gettime(CLOCK_BOOTTIME,) slows down >20x
authorMark Salyzyn <salyzyn@google.com>
Wed, 24 Jan 2018 22:00:19 +0000 (14:00 -0800)
committerBruno Martins <bgcngm@gmail.com>
Fri, 20 Oct 2023 17:09:54 +0000 (18:09 +0100)
commit5d3ae93a03557bb65d6c1e71641b5e98f03a9943
treeff88afaf59f2731c5b26f7ecc1f6686386313ac0
parent85e718571987b0bc28e15d7606c4f77f0de981ae
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
arch/arm/include/asm/vdso_datapage.h
arch/arm/kernel/vdso.c
arch/arm64/include/asm/vdso_datapage.h
arch/arm64/kernel/vdso.c
arch/arm64/kernel/vdso32/compiler.h
lib/vdso/vgettimeofday.c