]> git.proxmox.com Git - mirror_ubuntu-eoan-kernel.git/commit
timekeeping: Rework frequency adjustments to work better w/ nohz
authorJohn Stultz <john.stultz@linaro.org>
Sat, 7 Dec 2013 01:25:21 +0000 (17:25 -0800)
committerJohn Stultz <john.stultz@linaro.org>
Wed, 23 Jul 2014 22:01:56 +0000 (15:01 -0700)
commitdc491596f6394382fbc74ad331156207d619fa0a
treec5496cc0145eaeea40e42aac5e2baecc0a7923d0
parente2dff1ec0cc81fcf3e0696604bacc3e1c816538c
timekeeping: Rework frequency adjustments to work better w/ nohz

The existing timekeeping_adjust logic has always been complicated
to understand. Further, since it was developed prior to NOHZ becoming
common, its not surprising it performs poorly when NOHZ is enabled.

Since Miroslav pointed out the problematic nature of the existing code
in the NOHZ case, I've tried to refactor the code to perform better.

The problem with the previous approach was that it tried to adjust
for the total cumulative error using a scaled dampening factor. This
resulted in large errors to be corrected slowly, while small errors
were corrected quickly. With NOHZ the timekeeping code doesn't know
how far out the next tick will be, so this results in bad
over-correction to small errors, and insufficient correction to large
errors.

Inspired by Miroslav's patch, I've refactored the code to try to
address the correction in two steps.

1) Check the future freq error for the next tick, and if the frequency
error is large, try to make sure we correct it so it doesn't cause
much accumulated error.

2) Then make a small single unit adjustment to correct any cumulative
error that has collected over time.

This method performs fairly well in the simulator Miroslav created.

Major credit to Miroslav for pointing out the issue, providing the
original patch to resolve this, a simulator for testing, as well as
helping debug and resolve issues in my implementation so that it
performed closer to his original implementation.

Cc: Miroslav Lichvar <mlichvar@redhat.com>
Cc: Richard Cochran <richardcochran@gmail.com>
Cc: Prarit Bhargava <prarit@redhat.com>
Reported-by: Miroslav Lichvar <mlichvar@redhat.com>
Signed-off-by: John Stultz <john.stultz@linaro.org>
include/linux/timekeeper_internal.h
kernel/time/timekeeping.c