[3.11.y.z extended stable] Patch "timekeeping: Fix CLOCK_TAI timer/nanosleep delays" has been added to staging queue

Luis Henriques luis.henriques at canonical.com
Fri Feb 14 10:12:03 UTC 2014


This is a note to let you know that I have just added a patch titled

    timekeeping: Fix CLOCK_TAI timer/nanosleep delays

to the linux-3.11.y-queue branch of the 3.11.y.z extended stable tree 
which can be found at:

 http://kernel.ubuntu.com/git?p=ubuntu/linux.git;a=shortlog;h=refs/heads/linux-3.11.y-queue

If you, or anyone else, feels it should not be added to this tree, please 
reply to this email.

For more information about the 3.11.y.z tree, see
https://wiki.ubuntu.com/Kernel/Dev/ExtendedStable

Thanks.
-Luis

------

>From c3255c0d362bc865e53d884af46eb8f7df4e0b82 Mon Sep 17 00:00:00 2001
From: John Stultz <john.stultz at linaro.org>
Date: Tue, 10 Dec 2013 17:13:35 -0800
Subject: timekeeping: Fix CLOCK_TAI timer/nanosleep delays

commit 04005f6011e3b504cd4d791d9769f7cb9a3b2eae upstream.

A think-o in the calculation of the monotonic -> tai time offset
results in CLOCK_TAI timers and nanosleeps to expire late (the
latency is ~2x the tai offset).

Fix this by adding the tai offset from the realtime offset instead
of subtracting.

Cc: Sasha Levin <sasha.levin at oracle.com>
Cc: Thomas Gleixner <tglx at linutronix.de>
Cc: Prarit Bhargava <prarit at redhat.com>
Cc: Richard Cochran <richardcochran at gmail.com>
Cc: Ingo Molnar <mingo at kernel.org>
Signed-off-by: John Stultz <john.stultz at linaro.org>
Signed-off-by: Luis Henriques <luis.henriques at canonical.com>
---
 kernel/time/timekeeping.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/kernel/time/timekeeping.c b/kernel/time/timekeeping.c
index f223826..cd0c384 100644
--- a/kernel/time/timekeeping.c
+++ b/kernel/time/timekeeping.c
@@ -77,7 +77,7 @@ static void tk_set_wall_to_mono(struct timekeeper *tk, struct timespec wtm)
 	tk->wall_to_monotonic = wtm;
 	set_normalized_timespec(&tmp, -wtm.tv_sec, -wtm.tv_nsec);
 	tk->offs_real = timespec_to_ktime(tmp);
-	tk->offs_tai = ktime_sub(tk->offs_real, ktime_set(tk->tai_offset, 0));
+	tk->offs_tai = ktime_add(tk->offs_real, ktime_set(tk->tai_offset, 0));
 }

 static void tk_set_sleep_time(struct timekeeper *tk, struct timespec t)
@@ -595,7 +595,7 @@ s32 timekeeping_get_tai_offset(void)
 static void __timekeeping_set_tai_offset(struct timekeeper *tk, s32 tai_offset)
 {
 	tk->tai_offset = tai_offset;
-	tk->offs_tai = ktime_sub(tk->offs_real, ktime_set(tai_offset, 0));
+	tk->offs_tai = ktime_add(tk->offs_real, ktime_set(tai_offset, 0));
 }

 /**
--
1.8.3.2





More information about the kernel-team mailing list