arm64: Add support for CLOCK_MONOTONIC_RAW in clock_gettime() vDSO
authorKevin Brodsky <kevin.brodsky@arm.com>
Tue, 12 Jul 2016 10:24:00 +0000 (11:24 +0100)
committerCatalin Marinas <catalin.marinas@arm.com>
Tue, 12 Jul 2016 15:06:32 +0000 (16:06 +0100)
commit49eea433b326a0ac5c7c941a011b2c65990bd19b
treec5467bb68257b8c34477f686642c3af422a39ff8
parentb33f491f5a9aaf171b7de0f905362eb0314af478
arm64: Add support for CLOCK_MONOTONIC_RAW in clock_gettime() vDSO

So far the arm64 clock_gettime() vDSO implementation only supported
the following clocks, falling back to the syscall for the others:
- CLOCK_REALTIME{,_COARSE}
- CLOCK_MONOTONIC{,_COARSE}

This patch adds support for the CLOCK_MONOTONIC_RAW clock, taking
advantage of the recent refactoring of the vDSO time functions. Like
the non-_COARSE clocks, this only works when the "arch_sys_counter"
clocksource is in use (allowing us to read the current time from the
virtual counter register), otherwise we also have to fall back to the
syscall.

Most of the data is shared with CLOCK_MONOTONIC, and the algorithm is
similar. The reference implementation in kernel/time/timekeeping.c
shows that:
- CLOCK_MONOTONIC = tk->wall_to_monotonic + tk->xtime_sec +
  timekeeping_get_ns(&tk->tkr_mono)
- CLOCK_MONOTONIC_RAW = tk->raw_time + timekeeping_get_ns(&tk->tkr_raw)
- tkr_mono and tkr_raw are identical (in particular, same
  clocksource), except these members:
  * mult (only mono's multiplier is NTP-adjusted)
  * xtime_nsec (always 0 for raw)

Therefore, tk->raw_time and tkr_raw->mult are now also stored in the
vDSO data page.

Cc: Ali Saidi <ali.saidi@arm.com>
Signed-off-by: Kevin Brodsky <kevin.brodsky@arm.com>
Reviewed-by: Dave Martin <dave.martin@arm.com>
Acked-by: Will Deacon <will.deacon@arm.com>
Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>
arch/arm64/include/asm/vdso_datapage.h
arch/arm64/kernel/asm-offsets.c
arch/arm64/kernel/vdso.c
arch/arm64/kernel/vdso/gettimeofday.S