This patch adds a new internal interface to be used by the NTP code in[snip]
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@xxxxxxxxx>
---
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
/* 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;
+ /* The current difference KTS - UTC. */Again, get rid of KTS and we can simplify these as:
+ int kts_utc_offset;
+ /* The current difference TAI - KTS. */
+ int tai_kts_offset;
+#ifdef CONFIG_DELETE_LEAP_SECONDS
+ /* Remembers whether to insert or to delete. */
+ int insert_leapsecond;
+#endif
/*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.
* 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);
+