Judging by the number of searches hitting my blog this last few weeks, some people seem to be concerned about the leap second event at the end of the month. The common search pattern is variations of “how do test for leap second bug”.
The code in question has been given some scrutiny over recent weeks, and some fixes got merged..
fad0c66c4bb836d57a5f125ecd38bed653ca863a timekeeping: Fix CLOCK_MONOTONIC inconsistency during leapsecond
dd48d708ff3e917f6d6b6c2b696c3f18c019feed ntp: Correct TAI offset during leap second
6b43ae8a619d17c4935c3320d2ef9e92bdeed05d ntp: Fix leap-second hrtimer livelock
Just to put my mind at rest, I booted a kernel with this patch..
diff --git a/kernel/time/ntp.c b/kernel/time/ntp.c
index 70b33ab..5f4a1f0 100644
--- a/kernel/time/ntp.c
+++ b/kernel/time/ntp.c
@@ -396,6 +396,13 @@ int second_overflow(unsigned long secs)
spin_lock_irqsave(&ntp_lock, flags);
+ if (time_state == TIME_OK) {
+ if (secs % 86400 == 0) {
+ printk("Faking leap second.\n");
+ time_state = TIME_INS;
+ }
+ }
+
/*
* Leap second processing. If in leap-insert state at the end of the
* day, the system clock is set back one second; if in leap-delete
Which futzes with the leap second state machine to make it think it’s Jun 31st, and it’s just been told to insert a leap second.
At midnight UTC, things were pretty boring..
Jun 14 19:59:59 bitcrush kernel: [68242.572516] Faking leap second.
Jun 14 19:59:59 bitcrush kernel: [68242.573379] Clock: inserting leap second 23:59:60 UTC
And then things just kept running as normal. As they should. So hopefully, this time we’ll have an uneventful leap second, unlike the past few.
(as long as you’re running a recent-ish kernel that is).
Update: Richard Cochran has a test program here, which doesn’t involve hacking the kernel code.