public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: John Stultz <john.stultz@linaro.org>
To: Richard Cochran <richardcochran@gmail.com>
Cc: linux-kernel@vger.kernel.org, Thomas Gleixner <tglx@linutronix.de>
Subject: Re: [PATCH RFC V1 4/5] timekeeping: Offer an interface to manipulate leap seconds.
Date: Fri, 27 Apr 2012 16:08:03 -0700	[thread overview]
Message-ID: <4F9B26D3.1030100@linaro.org> (raw)
In-Reply-To: <52e139c98370c405288cbbb4ac76c435dc36731f.1335510125.git.richardcochran@gmail.com>

On 04/27/2012 01:12 AM, Richard Cochran wrote:
> This patch adds a new internal interface to be used by the NTP code in
> order to set the next leap second event. Also, it adds a kernel command
> line option that can be used to dial the TAI - UTC offset at boot.
>
> Signed-off-by: Richard Cochran<richardcochran@gmail.com>
> ---
>   kernel/time/leap-seconds.h |   23 ++++++
>   kernel/time/timekeeping.c  |  175 ++++++++++++++++++++++++++++++++++++++++++++
>   2 files changed, 198 insertions(+), 0 deletions(-)
>   create mode 100644 kernel/time/leap-seconds.h
[snip]
>   /* Structure holding internal timekeeping values. */
>   struct timekeeper {
>   	/* Current clocksource used for timekeeping. */
> @@ -50,6 +53,16 @@ struct timekeeper {
>
>   	/* The current time */
>   	struct timespec xtime;
> +	/* The Kernel Time Scale (KTS) value of the next leap second. */
> +	time_t next_leapsecond;

I'm not a big fan of this new Kernel Time Scale. I don't think we really 
need a new time domain, and it only muddles things.
Why not have next_leapsecond be specified in CLOCK_MONOTONIC time?

> +	/* The current difference KTS - UTC. */
> +	int kts_utc_offset;
> +	/* The current difference TAI - KTS. */
> +	int tai_kts_offset;
Again, get rid of KTS and we can simplify these as:
CLOCK_TAI = CLOCK_MONOTONIC + mono_to_tai;
UTC/CLOCK_REALTIME = CLOCK_TAI + utc_offset;

This basically requires changing the timekeeping core from keeping track 
of CLOCK_REALTIME as its time base, and instead having it use 
CLOCK_MONOTONIC. This actually is something I proposed a long time ago, 
but was deferred because folks were concerned that the extra addition 
would slow gettimeofday() down.  However, that was back when everything 
internally used jiffies. These days ktime_get() is probably called 
internally more frequently, and so optimizing for CLOCK_MONOTONIC makes 
sense.



> +#ifdef CONFIG_DELETE_LEAP_SECONDS
> +	/* Remembers whether to insert or to delete. */
> +	int insert_leapsecond;
> +#endif

I'm not a big fan of this additional config option.  The maintenance 
burden for the extra condition is probably not worth the code size 
trade-off.  Or it needs way more justification.

>   	/*
>   	 * wall_to_monotonic is what we need to add to xtime (or xtime corrected
>   	 * for sub jiffie times) to get to monotonic time.  Monotonic is pegged
> @@ -87,6 +100,30 @@ __cacheline_aligned_in_smp DEFINE_SEQLOCK(xtime_lock);
>   int __read_mostly timekeeping_suspended;
>
>
> +static int __init tai_offset_setup(char *str)
> +{
> +	get_option(&str,&timekeeper.kts_utc_offset);
> +	return 1;
> +}
> +__setup("tai_offset=", tai_offset_setup);
> +
Oooof.. Yuck.  I really don't like the boot time tai_offset argument. 
What sysadmin wants to change their grub settings after a leapsecond so 
that the next reboot its set properly?  I'd suggest tai_offset be set to 
zero until userland updates it at boot time.  CLOCK_TAI is not 
CLOCK_MONOTONIC, and it can jump around if the user calls 
settimeofday(), so I don't see a major reason for it to be initialized 
via a boot argument.  Its true that right now there's no userland 
infrastructure to set it (other then ntp, but I've never verified it 
actually gets set), but there also aren't any users consuming it either.

thanks
-john


  reply	other threads:[~2012-04-27 23:08 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-04-27  8:12 [PATCH RFC V1 0/5] Rationalize time keeping Richard Cochran
2012-04-27  8:12 ` [PATCH RFC V1 1/5] Add functions to convert continuous timescales to UTC Richard Cochran
2012-04-27  8:12 ` [PATCH RFC V1 2/5] ntp: Fix a stale comment and a few stray newlines Richard Cochran
2012-04-27 22:25   ` John Stultz
2012-04-27  8:12 ` [PATCH RFC V1 3/5] timekeeping: Fix a few minor newline issues Richard Cochran
2012-04-27 22:25   ` John Stultz
2012-04-27  8:12 ` [PATCH RFC V1 4/5] timekeeping: Offer an interface to manipulate leap seconds Richard Cochran
2012-04-27 23:08   ` John Stultz [this message]
2012-04-28  8:47     ` Richard Cochran
2012-05-05 10:17     ` Richard Cochran
2012-05-07 17:36       ` John Stultz
2012-04-27  8:12 ` [PATCH RFC V1 5/5] timekeeping: Use a continuous timescale to tell time Richard Cochran
2012-05-28 16:49   ` Richard Cochran
2012-04-27 22:49 ` [PATCH RFC V1 0/5] Rationalize time keeping John Stultz
2012-04-28  8:04   ` Richard Cochran
2012-04-30 20:56     ` John Stultz
2012-05-01  7:17       ` Richard Cochran
2012-05-01  8:01         ` John Stultz
2012-05-01 18:43           ` Richard Cochran
2012-05-03  7:02       ` Richard Cochran
2012-05-03 15:48         ` John Stultz
2012-05-03 18:21   ` Richard Cochran
2012-05-03 18:44     ` John Stultz
2012-05-03 19:28       ` Richard Cochran
2012-05-03 19:42         ` John Stultz
2012-05-03 19:57 ` John Stultz
2012-05-05  7:34   ` Richard Cochran
2012-05-05 19:25     ` 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=4F9B26D3.1030100@linaro.org \
    --to=john.stultz@linaro.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=richardcochran@gmail.com \
    --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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox