From: Alexandre Belloni <alexandre.belloni@free-electrons.com>
To: Arnd Bergmann <arnd@arndb.de>
Cc: john.stultz@linaro.org, ksummit-discuss@lists.linuxfoundation.org
Subject: Re: [Ksummit-discuss] Leap second handling
Date: Tue, 15 Dec 2015 15:15:18 +0100 [thread overview]
Message-ID: <20151215141518.GE8574@piout.net> (raw)
In-Reply-To: <2151085.9YAhiz9GYL@wuerfel>
Hi,
On 15/12/2015 at 13:12:03 +0100, Arnd Bergmann wrote :
> > So the question is how to deal with it. I can see three obvious ways:
> >
> > (1) Treat it the same as hh:mm:59.
> >
> > (2) Treat it the same as hh:mm+1:00, rolling over the carry through to the
> > year if necessary.
> >
> > (3) Assign specific time_t values to leap seconds in mktime64(). There's a
> > table of them here:
> >
> > https://en.wikipedia.org/wiki/Leap_second
> >
> > It wouldn't be hard to do within just the kernel, but this would put the
> > kernel at odds with userspace to the tune of nearly half a minute at the
> > current time. It might be sufficient to just fix the libc's in userspace
> > - but you can bet there's someone somewhere who checks that seconds
> > doesn't exceed 59.
> >
> > The kernel would also need to tell libc whether or not the time value it
> > gets includes leap seconds.
> >
> > Any thoughts?
>
> The kernel supports CLOCK_TAI as a timebase. While I think some operating systems
> use this as the default clock, we don't do that, and I assume we don't want
> to change this.
>
> ktime_get_clocktai() will return the time in this format, and the timekeeper
> stores the offset between boottime and TAI internally, and updates it whenever
> a leap second happens, so if you set a timer in CLOCK_TAI, it will expire at
> the right moment.
>
> What I think we don't do at all in the kernel is to keep track of past (or
> even future) leap seconds, so if you need to encode a date in the past,
> the kernel has no idea what the difference between UTC and TAI was at the
> time, and if you encode a time in the future, you don't know if we will
> insert a leap second before you get to that time. I think these are the
> harder questions to solve first if you want to handle the X.509 certificates
> right, before we get to the question of what happens for dates *on* the
> leap second.
>
My point of view is that we shouldn't do anything in the kernel and
instead handle that with proper TZ files (see leapseconds in
tzdata2015g). You can then handle your own leapseconds epoch and add
future leapseconds without having to update your kernel.
--
Alexandre Belloni, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com
next prev parent reply other threads:[~2015-12-15 14:15 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-12-15 11:33 David Howells
2015-12-15 12:12 ` Arnd Bergmann
2015-12-15 14:15 ` Alexandre Belloni [this message]
2015-12-16 5:12 ` John Stultz
2015-12-17 0:32 ` David Howells
2015-12-17 0:44 ` 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=20151215141518.GE8574@piout.net \
--to=alexandre.belloni@free-electrons.com \
--cc=arnd@arndb.de \
--cc=john.stultz@linaro.org \
--cc=ksummit-discuss@lists.linuxfoundation.org \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox