summaryrefslogtreecommitdiff
path: root/arch/arm64/kernel/time.c
diff options
context:
space:
mode:
Diffstat (limited to 'arch/arm64/kernel/time.c')
-rw-r--r--arch/arm64/kernel/time.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/arch/arm64/kernel/time.c b/arch/arm64/kernel/time.c
index 29c39d5..03dc371 100644
--- a/arch/arm64/kernel/time.c
+++ b/arch/arm64/kernel/time.c
@@ -61,6 +61,13 @@ unsigned long profile_pc(struct pt_regs *regs)
EXPORT_SYMBOL(profile_pc);
#endif
+static u64 sched_clock_mult __read_mostly;
+
+unsigned long long notrace sched_clock(void)
+{
+ return arch_timer_read_counter() * sched_clock_mult;
+}
+
void __init time_init(void)
{
u32 arch_timer_rate;
@@ -71,6 +78,9 @@ void __init time_init(void)
if (!arch_timer_rate)
panic("Unable to initialise architected timer.\n");
+ /* Cache the sched_clock multiplier to save a divide in the hot path. */
+ sched_clock_mult = NSEC_PER_SEC / arch_timer_rate;
+
/* Calibrate the delay loop directly */
lpj_fine = arch_timer_rate / HZ;
}