mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: John Stultz <john.stultz@linaro.org>
To: LKML <linux-kernel@vger.kernel.org>
Cc: John Stultz <john.stultz@linaro.org>,
	Sasha Levin <sasha.levin@oracle.com>,
	Thomas Gleixner <tglx@linutronix.de>,
	Prarit Bhargava <prarit@redhat.com>,
	Richard Cochran <richardcochran@gmail.com>,
	Ingo Molnar <mingo@kernel.org>, stable <stable@vger.kernel.org>
Subject: [PATCH 5/9] timekeeping: Fix CLOCK_TAI timer/nanosleep delays
Date: Thu,  2 Jan 2014 14:23:23 -0800	[thread overview]
Message-ID: <1388701407-5029-5-git-send-email-john.stultz@linaro.org> (raw)
In-Reply-To: <1388701407-5029-1-git-send-email-john.stultz@linaro.org>

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@oracle.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Prarit Bhargava <prarit@redhat.com>
Cc: Richard Cochran <richardcochran@gmail.com>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: stable <stable@vger.kernel.org> #3.10+
Signed-off-by: John Stultz <john.stultz@linaro.org>
---
 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 44b7e6b..3f6a827 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


  parent reply	other threads:[~2014-01-02 22:24 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-01-02 22:22 [GIT PULL] Timekeeping changes for 3.14 John Stultz
2014-01-02 22:23 ` [PATCH 1/9] timekeeping: Fix lost updates to tai adjustment John Stultz
2014-01-02 22:23   ` [PATCH 2/9] timekeeping: Fix potential lost pv notification of time change John Stultz
2014-01-02 22:23   ` [PATCH 3/9] timekeeping: Avoid possible deadlock from clock_was_set_delayed John Stultz
2014-01-02 22:23   ` [PATCH 4/9] tick/timekeeping: Call update_wall_time outside the jiffies lock John Stultz
2014-01-02 22:23   ` John Stultz [this message]
2014-01-02 22:23   ` [PATCH 6/9] timekeeping: Fix missing timekeeping_update in suspend path John Stultz
2014-01-02 22:23   ` [PATCH 7/9] timekeeper: fix comment typo for tk_setup_internals() John Stultz
2014-01-02 22:23   ` [PATCH 8/9] rtc-cmos: Add an alarm disable quirk John Stultz
2014-01-02 22:23   ` [PATCH 9/9] timekeeping: Remove comment that's mostly out of date John Stultz
2014-01-12 13:15 ` [GIT PULL] Timekeeping changes for 3.14 Ingo Molnar

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=1388701407-5029-5-git-send-email-john.stultz@linaro.org \
    --to=john.stultz@linaro.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@kernel.org \
    --cc=prarit@redhat.com \
    --cc=richardcochran@gmail.com \
    --cc=sasha.levin@oracle.com \
    --cc=stable@vger.kernel.org \
    --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

Powered by JetHome