mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] hrtimer: Fix incorrect tai offset calculation for non high-res timer systems
@ 2015-02-05  0:45 John Stultz
  2015-02-05  7:42 ` [tip:timers/urgent] " tip-bot for John Stultz
  0 siblings, 1 reply; 2+ messages in thread
From: John Stultz @ 2015-02-05  0:45 UTC (permalink / raw)
  To: lkml; +Cc: John Stultz, Thomas Gleixner, Ingo Molnar, stable

For tip/timers/urgent

I noticed some CLOCK_TAI timer test failures on one of my
less-frequently used configurations. And after digging in I
found in 76f4108892d9 (Cleanup hrtimer accessors to the
timekepeing state), the hrtimer_get_softirq_time tai offset
calucation was incorrectly rewritten, as the tai offset we return
shold be from CLOCK_MONOTONIC, and not CLOCK_REALTIME.

This results in CLOCK_TAI timers expiring early on non-highres
capable machines.

This patch fixes the issue, calculating the tai time properly from
the monotonic base.

Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: stable <stable@vger.kernel.org> # 3.17+
Signed-off-by: John Stultz <john.stultz@linaro.org>
---
 kernel/time/hrtimer.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/kernel/time/hrtimer.c b/kernel/time/hrtimer.c
index 37e50aa..d8c724c 100644
--- a/kernel/time/hrtimer.c
+++ b/kernel/time/hrtimer.c
@@ -122,7 +122,7 @@ static void hrtimer_get_softirq_time(struct hrtimer_cpu_base *base)
 	mono = ktime_get_update_offsets_tick(&off_real, &off_boot, &off_tai);
 	boot = ktime_add(mono, off_boot);
 	xtim = ktime_add(mono, off_real);
-	tai = ktime_add(xtim, off_tai);
+	tai = ktime_add(mono, off_tai);
 
 	base->clock_base[HRTIMER_BASE_REALTIME].softirq_time = xtim;
 	base->clock_base[HRTIMER_BASE_MONOTONIC].softirq_time = mono;
-- 
1.9.1


^ permalink raw reply	[flat|nested] 2+ messages in thread

* [tip:timers/urgent] hrtimer: Fix incorrect tai offset calculation for non high-res timer systems
  2015-02-05  0:45 [PATCH] hrtimer: Fix incorrect tai offset calculation for non high-res timer systems John Stultz
@ 2015-02-05  7:42 ` tip-bot for John Stultz
  0 siblings, 0 replies; 2+ messages in thread
From: tip-bot for John Stultz @ 2015-02-05  7:42 UTC (permalink / raw)
  To: linux-tip-commits; +Cc: mingo, hpa, john.stultz, linux-kernel, tglx

Commit-ID:  2d926c15d629a13914ce3e5f26354f6a0ac99e70
Gitweb:     http://git.kernel.org/tip/2d926c15d629a13914ce3e5f26354f6a0ac99e70
Author:     John Stultz <john.stultz@linaro.org>
AuthorDate: Wed, 4 Feb 2015 16:45:26 -0800
Committer:  Ingo Molnar <mingo@kernel.org>
CommitDate: Thu, 5 Feb 2015 08:39:37 +0100

hrtimer: Fix incorrect tai offset calculation for non high-res timer systems

I noticed some CLOCK_TAI timer test failures on one of my
less-frequently used configurations. And after digging in I
found in 76f4108892d9 (Cleanup hrtimer accessors to the
timekepeing state), the hrtimer_get_softirq_time tai offset
calucation was incorrectly rewritten, as the tai offset we
return shold be from CLOCK_MONOTONIC, and not CLOCK_REALTIME.

This results in CLOCK_TAI timers expiring early on non-highres
capable machines.

This patch fixes the issue, calculating the tai time properly
from the monotonic base.

Signed-off-by: John Stultz <john.stultz@linaro.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: stable <stable@vger.kernel.org> # 3.17+
Link: http://lkml.kernel.org/r/1423097126-10236-1-git-send-email-john.stultz@linaro.org
Signed-off-by: Ingo Molnar <mingo@kernel.org>
---
 kernel/time/hrtimer.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/kernel/time/hrtimer.c b/kernel/time/hrtimer.c
index 37e50aa..d8c724c 100644
--- a/kernel/time/hrtimer.c
+++ b/kernel/time/hrtimer.c
@@ -122,7 +122,7 @@ static void hrtimer_get_softirq_time(struct hrtimer_cpu_base *base)
 	mono = ktime_get_update_offsets_tick(&off_real, &off_boot, &off_tai);
 	boot = ktime_add(mono, off_boot);
 	xtim = ktime_add(mono, off_real);
-	tai = ktime_add(xtim, off_tai);
+	tai = ktime_add(mono, off_tai);
 
 	base->clock_base[HRTIMER_BASE_REALTIME].softirq_time = xtim;
 	base->clock_base[HRTIMER_BASE_MONOTONIC].softirq_time = mono;

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2015-02-05  7:43 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-02-05  0:45 [PATCH] hrtimer: Fix incorrect tai offset calculation for non high-res timer systems John Stultz
2015-02-05  7:42 ` [tip:timers/urgent] " tip-bot for John Stultz

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®