All of lore.kernel.org
 help / color / mirror / Atom feed
From: Richard Cochran <richardcochran@gmail.com>
To: <linux-kernel@vger.kernel.org>
Cc: John Stultz <john.stultz@linaro.org>,
	Thomas Gleixner <tglx@linutronix.de>
Subject: [PATCH 0/1] ntp bug fix
Date: Thu, 26 Apr 2012 14:11:31 +0200	[thread overview]
Message-ID: <cover.1335442155.git.richardcochran@gmail.com> (raw)

I have been cooking up a patch series to keep the core time in TAI
instead of UTC. In the course of that work I noticed a bug in the
current NTP code. During a leap second insertion, the kernel will
advertise the wrong TAI offset.

There is a nice explanation of this issue in the NIST leap second
list, which I quote below. With reference to that, the Linux kernel
handles the UTC time value like in the first case, but sets the TAI
offset as in the second case, resulting in a discontinuity in the
apparent TAI time.

* Excerpt from ftp://time.nist.gov/pub/leap-seconds.list

   If your system keeps time as the number of seconds since some epoch
   (e.g., NTP timestamps), then the algorithm for assigning a UTC time
   stamp to an event that happens during a positive leap second is not
   well defined. The official name of that leap second is 23:59:60,
   but there is no way of representing that time in these systems.

   Many systems of this type effectively stop the system clock for one
   second during the leap second and use a time that is equivalent to
   23:59:59 UTC twice. For these systems, the corresponding TAI
   timestamp would be obtained by advancing to the next entry in the
   following table when the time equivalent to 23:59:59 UTC is used
   for the second time. Thus the leap second which occurred on 30 June
   1972 at 23:59:59 UTC would have TAI timestamps computed as follows:

   30 June 1972 23:59:59 (2287785599, first time):  TAI= UTC + 10 seconds
   30 June 1972 23:59:60 (2287785599,second time):  TAI= UTC + 11 seconds
   1  July 1972 00:00:00 (2287785600)               TAI= UTC + 11 seconds

   If your system realizes the leap second by repeating 00:00:00 UTC
   twice (this is possible but not usual), then the advance to the
   next entry in the table must occur the second time that a time
   equivlent to 00:00:00 UTC is used. Thus, using the same example as
   above:

   30 June 1972 23:59:59 (2287785599):              TAI= UTC + 10 seconds
   30 June 1972 23:59:60 (2287785600, first time):  TAI= UTC + 10 seconds
   1  July 1972 00:00:00 (2287785600,second time):  TAI= UTC + 11 seconds

   in both cases the use of timestamps based on TAI produces a smooth
   time scale with no discontinuity in the time interval.


Richard Cochran (1):
  ntp: advertise correct TAI offset during leap second

 kernel/time/ntp.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

-- 
1.7.2.5


             reply	other threads:[~2012-04-26 12:11 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-04-26 12:11 Richard Cochran [this message]
2012-04-26 12:11 ` [PATCH 1/1] ntp: advertise correct TAI offset during leap second Richard Cochran
2012-04-27 22:23   ` John Stultz
2012-04-28  6:17     ` Richard Cochran
2012-04-30 19:48       ` John Stultz
2012-05-01  6:16         ` Richard Cochran
2012-05-05 10:02           ` Richard Cochran
2012-05-05 19:27             ` John Stultz
2012-05-03 18:54   ` John Stultz

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=cover.1335442155.git.richardcochran@gmail.com \
    --to=richardcochran@gmail.com \
    --cc=john.stultz@linaro.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=tglx@linutronix.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.