[PATCH v2 0/3] arm64: perf_event: Fix time offset prior to epoch

From: Leo Yan
Date: Tue May 05 2020 - 09:56:00 EST


This patch set is to fix time offset prior to epoch for Arm arch timer.
This series is mainly following on suggestions on LKML [1].

To acheive the accurate time offset for a clock source prior to epoch,
patch 01 adds a new variant sched_clock_register_epoch() which allows to
output an extra argument for time offset prior to sched clock's
registration.

Patch 02 is to add handling for time offset in Arm arch timer driver, As
Will Deacon suggested to "disable the perf userpage if sched_clock
changes clocksource too" [2], after thinking about this suggestion, the
race condition doesn't exist between sched_clock's registration and perf
userpage. The reason is sched_clock's registration is finished in
system's initialisation phase and at this point it has no chance to use
any userpage by Perf tool. For this reason let's keep the code simple
and don't acquire all Perf events' seqlock during sched_clock's
registration.

Patch 03 is simply to pass time offset from arch timer driver
(clocksource driver) to perf event.

[1] https://lkml.org/lkml/2020/3/20/199
[2] https://lkml.org/lkml/2020/5/1/906

Changes from v1:
- Added patch 01 to retrieve more accurate offset when sched clock
registration;
- Added patch 02 to handle time offset in arch timer driver.

Leo Yan (3):
time/sched_clock: Add new variant sched_clock_register_epoch()
clocksource/drivers/arm_arch_timer: Handle time offset prior to epoch
arm64: perf_event: Fix time_offset for arch timer

arch/arm64/kernel/perf_event.c | 8 ++++++--
drivers/clocksource/arm_arch_timer.c | 10 +++++++++-
include/clocksource/arm_arch_timer.h | 6 ++++++
include/linux/sched_clock.h | 10 ++++++++++
kernel/time/sched_clock.c | 13 ++++++++++++-
5 files changed, 43 insertions(+), 4 deletions(-)

--
2.17.1