Skip to contentSkip to conversation

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

PATCH New John Stultz 2 participants 2 messages Feb 5, 2015

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

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

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 <[email protected]>
Cc Ingo Molnar <[email protected]>
Cc stable <[email protected]> # 3.17+
---
 kernel/time/hrtimer.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/time/hrtimer.c +1 -1
index 37e50aa..d8c724c 100644
@@ -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;
Signature · 1 line
1.9.1
#1 lore raw
hrtimer: Fix incorrect tai offset calculation for non high-res timer systems
Commit-ID:  2d926c15d629a13914ce3e5f26354f6a0ac99e70
Gitweb:     http://git.kernel.org/tip/2d926c15d629a13914ce3e5f26354f6a0ac99e70
Author:     John Stultz <[email protected]>
AuthorDate: Wed, 4 Feb 2015 16:45:26 -0800
Committer:  Ingo Molnar <[email protected]>
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.

---
 kernel/time/hrtimer.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/time/hrtimer.c +1 -1
index 37e50aa..d8c724c 100644
@@ -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;