public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* NTP leap second question
  2005-09-14 17:53 ` john stultz
@ 2005-09-14 18:39   ` George Anzinger
  2005-09-14 18:54     ` john stultz
  0 siblings, 1 reply; 10+ messages in thread
From: George Anzinger @ 2005-09-14 18:39 UTC (permalink / raw)
  To: john stultz; +Cc: lkml, yoshfuji, Roman Zippel, Ulrich Windl, joe-lkml

It appears that a leap second is scheduled.  One of our customers is 
concerened about his application around this.  Could one of you NTP 
wizards help me to understand NTP a bit better.

First, I wonder if we suppressed the leap second insert and time then 
became out of sync by a second, would NTP "creap" the time back in sync 
or would the one second out of sync cause it to quit?

Assuming NTP would do the "creap" thing, is there a way to tell NTP not 
to insert the leap second?
-- 
George Anzinger   george@mvista.com
HRT (High-res-timers):  http://sourceforge.net/projects/high-res-timers/

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: NTP leap second question
  2005-09-14 18:39   ` NTP leap second question George Anzinger
@ 2005-09-14 18:54     ` john stultz
  2005-09-15  6:49       ` Ulrich Windl
  0 siblings, 1 reply; 10+ messages in thread
From: john stultz @ 2005-09-14 18:54 UTC (permalink / raw)
  To: george; +Cc: lkml, yoshfuji, Roman Zippel, Ulrich Windl, joe-lkml

On Wed, 2005-09-14 at 11:39 -0700, George Anzinger wrote:
> It appears that a leap second is scheduled.  One of our customers is 
> concerened about his application around this.  Could one of you NTP 
> wizards help me to understand NTP a bit better.

First: I'm not an NTP wizard by any means, but I'll see if I can't help.

> First, I wonder if we suppressed the leap second insert and time then 
> became out of sync by a second, would NTP "creap" the time back in sync 
> or would the one second out of sync cause it to quit?

The ntpd's slew-bound is .125s I believe, so a second offset would cause
ntpd to adjust the time using stime()/settimeofday(). You could run ntpd
with the -x option which forces it to always slew the clock. This
however could cause the initial sync to take quite some time.


> Assuming NTP would do the "creap" thing, is there a way to tell NTP not 
> to insert the leap second?

If I recall, leapsecond implementations are a pretty contentious issue.
Some folks have suggested having the kernels note the leapsecond and
slew the clock internally. This sounds nicer then just adding or
removing a second, but I do not know how that would affect synchronizing
between a number of systems. So I'll defer the larger discussion to the
real NTP wizards.


^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: NTP leap second question
@ 2005-09-14 22:20 linux
  2005-09-16 21:58 ` George Anzinger
  0 siblings, 1 reply; 10+ messages in thread
From: linux @ 2005-09-14 22:20 UTC (permalink / raw)
  To: linux-kernel; +Cc: george, johnstul

The simplest way to achieve this is to:
a) Hack ntpd to "not notice" the leap-second announce bits 01 in
   the packet header and pretend they're actually 00.  This will
   make it not insert a leap second.
b) Run it with the -x flag so that it always slews the time.

The real solution would be to implement Markus Kuhn's UTS proposal
(http://www.cl.cam.ac.uk/~mgk25/uts.txt), which is about the most
reasonable meshing of the expectation that there are 86400
seconds per day with the fact that there are not.

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: NTP leap second question
  2005-09-14 18:54     ` john stultz
@ 2005-09-15  6:49       ` Ulrich Windl
  2005-09-15 17:21         ` Kyle Moffett
  0 siblings, 1 reply; 10+ messages in thread
From: Ulrich Windl @ 2005-09-15  6:49 UTC (permalink / raw)
  To: john stultz; +Cc: lkml, yoshfuji, Roman Zippel, joe-lkml

On 14 Sep 2005 at 11:54, john stultz wrote:

> On Wed, 2005-09-14 at 11:39 -0700, George Anzinger wrote:
> > It appears that a leap second is scheduled.  One of our customers is 
> > concerened about his application around this.  Could one of you NTP 
> > wizards help me to understand NTP a bit better.
> 
> First: I'm not an NTP wizard by any means, but I'll see if I can't help.
> 
> > First, I wonder if we suppressed the leap second insert and time then 
> > became out of sync by a second, would NTP "creap" the time back in sync 
> > or would the one second out of sync cause it to quit?
> 
> The ntpd's slew-bound is .125s I believe, so a second offset would cause
> ntpd to adjust the time using stime()/settimeofday(). You could run ntpd
> with the -x option which forces it to always slew the clock. This
> however could cause the initial sync to take quite some time.
> 
> 
> > Assuming NTP would do the "creap" thing, is there a way to tell NTP not 
> > to insert the leap second?
> 
> If I recall, leapsecond implementations are a pretty contentious issue.
> Some folks have suggested having the kernels note the leapsecond and
> slew the clock internally. This sounds nicer then just adding or

No! Never slew a leap second: It will take too long! It's all over after one 
second. If you slew, you time will be incorrect for an extended time.

Ulrich


> removing a second, but I do not know how that would affect synchronizing
> between a number of systems. So I'll defer the larger discussion to the
> real NTP wizards.
> 



^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: NTP leap second question
  2005-09-15  6:49       ` Ulrich Windl
@ 2005-09-15 17:21         ` Kyle Moffett
  2005-09-15 18:35           ` Alan Cox
  0 siblings, 1 reply; 10+ messages in thread
From: Kyle Moffett @ 2005-09-15 17:21 UTC (permalink / raw)
  To: Ulrich Windl; +Cc: john stultz, lkml, yoshfuji, Roman Zippel, joe-lkml

On Sep 15, 2005, at 02:49:21, Ulrich Windl wrote:
> On 14 Sep 2005 at 11:54, john stultz wrote:
>> If I recall, leapsecond implementations are a pretty contentious  
>> issue.  Some folks have suggested having the kernels note the  
>> leapsecond and slew the clock internally. This sounds nicer then  
>> just adding or
>
> No! Never slew a leap second: It will take too long! It's all over  
> after one second. If you slew, you time will be incorrect for an  
> extended time.

I think he said "It's a contentious issue", and "Some have  
suggested".  No need to get your underwear in a bunch over it.  There  
are arguments for both sides.  Besides, it's not like it matters much  
in the grand scheme of things, it's only a second.  With the current  
proposals, the leap-second-slewing would only be in effect for 1000  
seconds, and you'd never be very far off true time (The simplest  
implementation is one second off, if you add one bit of state you'll  
only ever be a half-second off).  If you're willing to make it a bit  
slower and a bit more code, you could even make the slewing nonlinear  
with a continuous derivative, so it's only in place for ~20 seconds,  
and only changes rapidly near the leapsecond boundary itself.  On the  
other hand, if your box is running a nuclear reactor, you might want  
to do a bit more verification, but Linux isn't certified for that  
anyways!! :-D

Cheers,
Kyle Moffett

--
Simple things should be simple and complex things should be possible
   -- Alan Kay




^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: NTP leap second question
  2005-09-15 17:21         ` Kyle Moffett
@ 2005-09-15 18:35           ` Alan Cox
  0 siblings, 0 replies; 10+ messages in thread
From: Alan Cox @ 2005-09-15 18:35 UTC (permalink / raw)
  To: Kyle Moffett
  Cc: Ulrich Windl, john stultz, lkml, yoshfuji, Roman Zippel, joe-lkml

On Iau, 2005-09-15 at 13:21 -0400, Kyle Moffett wrote:
> only ever be a half-second off).  If you're willing to make it a bit  
> slower and a bit more code, you could even make the slewing nonlinear  
> with a continuous derivative, so it's only in place for ~20 seconds,  

It all depends what time you are using and how you are using it. There
isn't one time system and assuming there is makes all the mess.

Your kernel time ticks along at a steady rate based on a fixed period
second where that period hopefully is a passable approximation of the
rate of progression of time measured by a big pile of cæsium atomic
clocks and defined in terms of atomic radiation.

UTC (civilian time) effectively follows rotations of the earth but using
fixed interval seconds. The rotation is a bit variable so 'leap seconds'
are inserted to keep the two within 1 second of one another.  A seperate
standard (UT1) computes a 'universal' measure of earth rotation as UT0
(true earth rotation) is dependant on where you are (because the poles
wobble). And you can measure time with seconds defined as a fraction of
an earth rotation (ie variable length seconds) which is what in reality
most people use and think.

In other words, you need to decide what you are measuring before you
decide how to measure it. If you wish to record the point at which an
event occurred in civilian time then UTC is correct. If you wish to
measure the duration elapsed between two points in time then TAI (or raw
time_t) is probably more useful.

If you are recording events to some legally defined standard you have to
go read what the government has inflicted on your radio station/telco
etc and follow that.

Glibc will do the conversion work for you providing your timezone
database is kept up to date.

Alan


^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: NTP leap second question
  2005-09-14 22:20 NTP leap second question linux
@ 2005-09-16 21:58 ` George Anzinger
  2005-09-17  1:23   ` Alan Cox
  0 siblings, 1 reply; 10+ messages in thread
From: George Anzinger @ 2005-09-16 21:58 UTC (permalink / raw)
  To: linux; +Cc: linux-kernel, johnstul

linux@horizon.com wrote:
> The simplest way to achieve this is to:
> a) Hack ntpd to "not notice" the leap-second announce bits 01 in
>    the packet header and pretend they're actually 00.  This will
>    make it not insert a leap second.

Would a rude and crude way to do this be to shut down ntpd at say 
11:55PM and restart it at 00:01?

What I am asking is when is the flag sent to the kernel.  My reading of 
the kernel code says that it will insert the second on the second roll 
immeadiatly after the flag is set.


> b) Run it with the -x flag so that it always slews the time.
> 
> The real solution would be to implement Markus Kuhn's UTS proposal
> (http://www.cl.cam.ac.uk/~mgk25/uts.txt), which is about the most
> reasonable meshing of the expectation that there are 86400
> seconds per day with the fact that there are not.
> -
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at  http://www.tux.org/lkml/
> 

-- 
George Anzinger   george@mvista.com
HRT (High-res-timers):  http://sourceforge.net/projects/high-res-timers/

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: NTP leap second question
  2005-09-17  1:23   ` Alan Cox
@ 2005-09-17  1:05     ` George Anzinger
  2005-09-17  1:53       ` Alan Cox
  0 siblings, 1 reply; 10+ messages in thread
From: George Anzinger @ 2005-09-17  1:05 UTC (permalink / raw)
  To: Alan Cox; +Cc: linux, linux-kernel, johnstul

Alan Cox wrote:
> On Gwe, 2005-09-16 at 14:58 -0700, George Anzinger wrote:
> 
>>What I am asking is when is the flag sent to the kernel.  My reading of 
>>the kernel code says that it will insert the second on the second roll 
>>immeadiatly after the flag is set.
> 
> 
> Kernel clock ticks are not adjusted or slewed or anything else for a
> leap second when correctly configured. UTC leap second adjustment is
> performed by glibc for locales that expect it (which I think is all of
> them)

Eh??  Then what is one to make of the code in timer.c that add 
leapseconds?  It seems to be controlled by the adjtime() system call.

Sure looks like it sets the system clock (xtime) ahead or back by a 
second at midnight if the flag is set to do so.

-- 
George Anzinger   george@mvista.com
HRT (High-res-timers):  http://sourceforge.net/projects/high-res-timers/

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: NTP leap second question
  2005-09-16 21:58 ` George Anzinger
@ 2005-09-17  1:23   ` Alan Cox
  2005-09-17  1:05     ` George Anzinger
  0 siblings, 1 reply; 10+ messages in thread
From: Alan Cox @ 2005-09-17  1:23 UTC (permalink / raw)
  To: george; +Cc: linux, linux-kernel, johnstul

On Gwe, 2005-09-16 at 14:58 -0700, George Anzinger wrote:
> What I am asking is when is the flag sent to the kernel.  My reading of 
> the kernel code says that it will insert the second on the second roll 
> immeadiatly after the flag is set.

Kernel clock ticks are not adjusted or slewed or anything else for a
leap second when correctly configured. UTC leap second adjustment is
performed by glibc for locales that expect it (which I think is all of
them)

Alan


^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: NTP leap second question
  2005-09-17  1:05     ` George Anzinger
@ 2005-09-17  1:53       ` Alan Cox
  0 siblings, 0 replies; 10+ messages in thread
From: Alan Cox @ 2005-09-17  1:53 UTC (permalink / raw)
  To: george; +Cc: linux, linux-kernel, johnstul

> Eh??  Then what is one to make of the code in timer.c that add 
> leapseconds?  It seems to be controlled by the adjtime() system call.
> 
> Sure looks like it sets the system clock (xtime) ahead or back by a 
> second at midnight if the flag is set to do so.

Yes it supports that - but since nobody runs the system clock in GMT it
should never be getting set by any caller. At least as far as I can see
from the code in glibc any glibc using system should never have xntpd
set the flag


^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2005-09-17  1:27 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-09-14 22:20 NTP leap second question linux
2005-09-16 21:58 ` George Anzinger
2005-09-17  1:23   ` Alan Cox
2005-09-17  1:05     ` George Anzinger
2005-09-17  1:53       ` Alan Cox
  -- strict thread matches above, loose matches on Subject: below --
2005-09-14 17:48 [RFC][PATCH] NTP shift_right cleanup (v. A1) john stultz
2005-09-14 17:53 ` john stultz
2005-09-14 18:39   ` NTP leap second question George Anzinger
2005-09-14 18:54     ` john stultz
2005-09-15  6:49       ` Ulrich Windl
2005-09-15 17:21         ` Kyle Moffett
2005-09-15 18:35           ` Alan Cox

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox