* [PATCH] timekeeping: Fix 1ns/tick drift with GENERIC_TIME_VSYSCALL_OLD
@ 2016-05-31 13:06 Thomas Graziadei
2016-05-31 23:11 ` John Stultz
2016-06-17 20:55 ` John Stultz
0 siblings, 2 replies; 4+ messages in thread
From: Thomas Graziadei @ 2016-05-31 13:06 UTC (permalink / raw)
To: linux-kernel; +Cc: john.stultz, tglx, thomas.graziadei
From: Thomas Graziadei <thomas.graziadei@omicronenergy.com>
The user notices the problem in a raw and real time drift, calling
clock_gettime with CLOCK_REALTIME / CLOCK_MONOTONIC_RAW on a system
with no ntp correction taking place (no ntpd or ptp stuff running).
The problem is, that old_vsyscall_fixup adds an extra 1ns even though
xtime_nsec is already held in full nsecs and the remainder in this
case is 0. Do the rounding up buisness only if needed.
Signed-off-by: Thomas Graziadei <thomas.graziadei@omicronenergy.com>
---
kernel/time/timekeeping.c | 10 ++++++----
1 file changed, 6 insertions(+), 4 deletions(-)
diff --git a/kernel/time/timekeeping.c b/kernel/time/timekeeping.c
index 479d25c..a196e08 100644
--- a/kernel/time/timekeeping.c
+++ b/kernel/time/timekeeping.c
@@ -480,10 +480,12 @@ static inline void old_vsyscall_fixup(struct timekeeper *tk)
* users are removed, this can be killed.
*/
remainder = tk->tkr_mono.xtime_nsec & ((1ULL << tk->tkr_mono.shift) - 1);
- tk->tkr_mono.xtime_nsec -= remainder;
- tk->tkr_mono.xtime_nsec += 1ULL << tk->tkr_mono.shift;
- tk->ntp_error += remainder << tk->ntp_error_shift;
- tk->ntp_error -= (1ULL << tk->tkr_mono.shift) << tk->ntp_error_shift;
+ if (remainder != 0) {
+ tk->tkr_mono.xtime_nsec -= remainder;
+ tk->tkr_mono.xtime_nsec += 1ULL << tk->tkr_mono.shift;
+ tk->ntp_error += remainder << tk->ntp_error_shift;
+ tk->ntp_error -= (1ULL << tk->tkr_mono.shift) << tk->ntp_error_shift;
+ }
}
#else
#define old_vsyscall_fixup(tk)
--
1.9.1
^ permalink raw reply related [flat|nested] 4+ messages in thread* Re: [PATCH] timekeeping: Fix 1ns/tick drift with GENERIC_TIME_VSYSCALL_OLD
2016-05-31 13:06 [PATCH] timekeeping: Fix 1ns/tick drift with GENERIC_TIME_VSYSCALL_OLD Thomas Graziadei
@ 2016-05-31 23:11 ` John Stultz
2016-06-01 11:43 ` Thomas Graziadei
2016-06-17 20:55 ` John Stultz
1 sibling, 1 reply; 4+ messages in thread
From: John Stultz @ 2016-05-31 23:11 UTC (permalink / raw)
To: Thomas Graziadei; +Cc: lkml, Thomas Gleixner, Tony Luck, Benjamin Herrenschmidt
On Tue, May 31, 2016 at 6:06 AM, Thomas Graziadei
<thomas.graziadei@omicronenergy.com> wrote:
> From: Thomas Graziadei <thomas.graziadei@omicronenergy.com>
>
> The user notices the problem in a raw and real time drift, calling
> clock_gettime with CLOCK_REALTIME / CLOCK_MONOTONIC_RAW on a system
> with no ntp correction taking place (no ntpd or ptp stuff running).
Hmm.. Curious. Was it actually drifting, or was it just
oscillating/ringing near the RAW clock's value?
> The problem is, that old_vsyscall_fixup adds an extra 1ns even though
> xtime_nsec is already held in full nsecs and the remainder in this
> case is 0. Do the rounding up buisness only if needed.
The patch looks ok. But I'm curious what architecture you were seeing
this on (ia64, powerpc?), as it would be much nicer to have those
architectures migrate off of the old low-res vsyscall calculation and
use the newer method with sub-ns precision, instead of trying to
further fix up the deprecated method.
I had submitted a patch to convert ia64 awhile back, but I don't
recall getting much feedback.
thanks
-john
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] timekeeping: Fix 1ns/tick drift with GENERIC_TIME_VSYSCALL_OLD
2016-05-31 23:11 ` John Stultz
@ 2016-06-01 11:43 ` Thomas Graziadei
0 siblings, 0 replies; 4+ messages in thread
From: Thomas Graziadei @ 2016-06-01 11:43 UTC (permalink / raw)
To: John Stultz; +Cc: lkml, Thomas Gleixner, Tony Luck, Benjamin Herrenschmidt
On 06/01/2016 01:11 AM, John Stultz wrote:
> On Tue, May 31, 2016 at 6:06 AM, Thomas Graziadei
> <thomas.graziadei@omicronenergy.com> wrote:
>> From: Thomas Graziadei <thomas.graziadei@omicronenergy.com>
>>
>> The user notices the problem in a raw and real time drift, calling
>> clock_gettime with CLOCK_REALTIME / CLOCK_MONOTONIC_RAW on a system
>> with no ntp correction taking place (no ntpd or ptp stuff running).
>
> Hmm.. Curious. Was it actually drifting, or was it just
> oscillating/ringing near the RAW clock's value?
It is actually drifting.
This is the output from a little test program:
realtime : 1464775074:846282133
raw time : 1054:851963700
drift_real: 999402ns
total duration: 1000s 158517540ns
>
>> The problem is, that old_vsyscall_fixup adds an extra 1ns even though
>> xtime_nsec is already held in full nsecs and the remainder in this
>> case is 0. Do the rounding up buisness only if needed.
>
> The patch looks ok. But I'm curious what architecture you were seeing
> this on (ia64, powerpc?), as it would be much nicer to have those
> architectures migrate off of the old low-res vsyscall calculation and
> use the newer method with sub-ns precision, instead of trying to
> further fix up the deprecated method.
>
> I had submitted a patch to convert ia64 awhile back, but I don't
> recall getting much feedback.
>
We are using a powerpc architecture.
I guess you are right, it would be nicer to use the new method but then
on the other hand, this timing topic is rather new to me.
> thanks
> -john
>
thanks,
Thomas
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] timekeeping: Fix 1ns/tick drift with GENERIC_TIME_VSYSCALL_OLD
2016-05-31 13:06 [PATCH] timekeeping: Fix 1ns/tick drift with GENERIC_TIME_VSYSCALL_OLD Thomas Graziadei
2016-05-31 23:11 ` John Stultz
@ 2016-06-17 20:55 ` John Stultz
1 sibling, 0 replies; 4+ messages in thread
From: John Stultz @ 2016-06-17 20:55 UTC (permalink / raw)
To: Thomas Graziadei; +Cc: lkml, Thomas Gleixner
On Tue, May 31, 2016 at 6:06 AM, Thomas Graziadei
<thomas.graziadei@omicronenergy.com> wrote:
> From: Thomas Graziadei <thomas.graziadei@omicronenergy.com>
>
> The user notices the problem in a raw and real time drift, calling
> clock_gettime with CLOCK_REALTIME / CLOCK_MONOTONIC_RAW on a system
> with no ntp correction taking place (no ntpd or ptp stuff running).
>
> The problem is, that old_vsyscall_fixup adds an extra 1ns even though
> xtime_nsec is already held in full nsecs and the remainder in this
> case is 0. Do the rounding up buisness only if needed.
>
> Signed-off-by: Thomas Graziadei <thomas.graziadei@omicronenergy.com>
I went ahead and queued this, but I'd still like to see the powerpc
and ia64 maintainers migrate off of the old vsyscall methods.
thanks
-john
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2016-06-17 20:55 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-05-31 13:06 [PATCH] timekeeping: Fix 1ns/tick drift with GENERIC_TIME_VSYSCALL_OLD Thomas Graziadei
2016-05-31 23:11 ` John Stultz
2016-06-01 11:43 ` Thomas Graziadei
2016-06-17 20:55 ` John Stultz
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox