Skip to contentSkip to conversation

time: Fix CLOCK_MONOTONIC inconsistency during leapsecond

PATCH In review John Stultz 1 participant 2 messages May 30, 2012 – Jun 4, 2012 Timekeeping, clocksource core, NTP, alarmtimer

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 time: Fix CLOCK_MONOTONIC inconsistency during leapsecond

Make sure we update wall_to_monotonic when adding a leapsecond. This could otherwise cause discontinuities in CLOCK_MONOTONIC.

This fixes a regression caused by
6b43ae8a619d17c4935c3320d2ef9e92bdeed05d

---
 kernel/time/timekeeping.c |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)
kernel/time/timekeeping.c +2 -0
index 6e46cac..6f46a00 100644
@@ -962,6 +962,7 @@ static cycle_t logarithmic_accumulation(cycle_t offset, int shift)
 		timekeeper.xtime.tv_sec++;
 		leap = second_overflow(timekeeper.xtime.tv_sec);
 		timekeeper.xtime.tv_sec += leap;
+		timekeeper.wall_to_monotonic.tv_sec -= leap;
 	}
 
 	/* Accumulate raw time */
@@ -1077,6 +1078,7 @@ static void update_wall_time(void)
 		timekeeper.xtime.tv_sec++;
 		leap = second_overflow(timekeeper.xtime.tv_sec);
 		timekeeper.xtime.tv_sec += leap;
+		timekeeper.wall_to_monotonic.tv_sec -= leap;
 	}
 
 	timekeeping_update(false);
Signature · 1 line
1.7.3.2.146.gca209
#1 lore raw

[tip:timers/urgent] timekeeping: Fix CLOCK_MONOTONIC inconsistency during leapsecond

Commit-ID:  fad0c66c4bb836d57a5f125ecd38bed653ca863a
Gitweb:     http://git.kernel.org/tip/fad0c66c4bb836d57a5f125ecd38bed653ca863a
Author:     John Stultz <[email protected]>
AuthorDate: Wed, 30 May 2012 10:54:57 -0700
Committer:  Thomas Gleixner <[email protected]>
CommitDate: Mon, 4 Jun 2012 21:46:29 +0200

timekeeping: Fix CLOCK_MONOTONIC inconsistency during leapsecond

Commit 6b43ae8a61 (ntp: Fix leap-second hrtimer livelock) broke the leapsecond update of CLOCK_MONOTONIC. The missing leapsecond update to wall_to_monotonic causes discontinuities in CLOCK_MONOTONIC.

Adjust wall_to_monotonic when NTP inserted a leapsecond.

---
 kernel/time/timekeeping.c |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)
kernel/time/timekeeping.c +2 -0
index 6e46cac..6f46a00 100644
@@ -962,6 +962,7 @@ static cycle_t logarithmic_accumulation(cycle_t offset, int shift)
 		timekeeper.xtime.tv_sec++;
 		leap = second_overflow(timekeeper.xtime.tv_sec);
 		timekeeper.xtime.tv_sec += leap;
+		timekeeper.wall_to_monotonic.tv_sec -= leap;
 	}
 
 	/* Accumulate raw time */
@@ -1077,6 +1078,7 @@ static void update_wall_time(void)
 		timekeeper.xtime.tv_sec++;
 		leap = second_overflow(timekeeper.xtime.tv_sec);
 		timekeeper.xtime.tv_sec += leap;
+		timekeeper.wall_to_monotonic.tv_sec -= leap;
 	}
 
 	timekeeping_update(false);