remarkable-linux/kernel/time
Martin Schwidefsky 4be77398ac time: Fix 1ns/tick drift w/ GENERIC_TIME_VSYSCALL_OLD
Since commit 1e75fa8be9 (time: Condense timekeeper.xtime
into xtime_sec - merged in v3.6), there has been an problem
with the error accounting in the timekeeping code, such that
when truncating to nanoseconds, we round up to the next nsec,
but the balancing adjustment to the ntp_error value was dropped.

This causes 1ns per tick drift forward of the clock.

In 3.7, this logic was isolated to only GENERIC_TIME_VSYSCALL_OLD
architectures (s390, ia64, powerpc).

The fix is simply to balance the accounting and to subtract the
added nanosecond from ntp_error. This allows the internal long-term
clock steering to keep the clock accurate.

While this fix removes the regression added in 1e75fa8be9, the
ideal solution is to move away from GENERIC_TIME_VSYSCALL_OLD
and use the new VSYSCALL method, which avoids entirely the
nanosecond granular rounding, and the resulting short-term clock
adjustment oscillation needed to keep long term accurate time.

[ jstultz: Many thanks to Martin for his efforts identifying this
  	   subtle bug, and providing the fix. ]

Originally-from: Martin Schwidefsky <schwidefsky@de.ibm.com>
Cc: Tony Luck <tony.luck@intel.com>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Cc: Andy Lutomirski <luto@amacapital.net>
Cc: Paul Turner <pjt@google.com>
Cc: Steven Rostedt <rostedt@goodmis.org>
Cc: Richard Cochran <richardcochran@gmail.com>
Cc: Prarit Bhargava <prarit@redhat.com>
Cc: Fenghua Yu <fenghua.yu@intel.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: stable <stable@vger.kernel.org>  #v3.6+
Link: http://lkml.kernel.org/r/1385149491-20307-1-git-send-email-john.stultz@linaro.org
Signed-off-by: John Stultz <john.stultz@linaro.org>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
2013-11-22 21:08:11 +01:00
..
alarmtimer.c alarmtimer: return EINVAL instead of ENOTSUPP if rtcdev doesn't exist 2013-10-18 16:23:58 -07:00
clockevents.c Merge branch 'timers-core-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip 2013-11-12 10:36:00 +09:00
clocksource.c time: Fix signedness bug in sysfs_get_uname() and its callers 2013-10-18 16:45:58 -07:00
jiffies.c
Kconfig nohz: Drop generic vtime obsolete dependency on CONFIG_64BIT 2013-09-30 15:37:01 +02:00
Makefile sched_clock: Make ARM's sched_clock generic for all architectures 2013-06-12 14:02:13 -07:00
ntp.c Linux 3.12-rc3 2013-10-03 07:52:21 +02:00
ntp_internal.h ntp: Rework do_adjtimex to take timespec and tai arguments 2013-04-04 13:18:15 -07:00
posix-clock.c
sched_clock.c sched_clock: Remove sched_clock_func() hook 2013-10-09 16:54:39 -07:00
tick-broadcast.c tick: broadcast: Deny per-cpu clockevents from being broadcast sources 2013-10-02 11:34:06 +02:00
tick-common.c tick: Document tick_do_timer_cpu 2013-11-19 14:59:50 +01:00
tick-internal.h time: Fix signedness bug in sysfs_get_uname() and its callers 2013-10-18 16:45:58 -07:00
tick-oneshot.c
tick-sched.c NOHZ: Check for nohz active instead of nohz enabled 2013-11-19 14:59:50 +01:00
timeconv.c
timekeeping.c time: Fix 1ns/tick drift w/ GENERIC_TIME_VSYSCALL_OLD 2013-11-22 21:08:11 +01:00
timekeeping_debug.c power: Add option to log time spent in suspend 2013-05-29 12:57:34 -07:00
timekeeping_internal.h power: Add option to log time spent in suspend 2013-05-29 12:57:34 -07:00
timer_list.c timer_list: correct the iterator for timer_list 2013-08-28 19:26:38 -07:00
timer_stats.c timer stats: Add a 'Collection: active/inactive' line to timer usage statistics 2013-10-10 09:59:25 +02:00