aboutsummaryrefslogtreecommitdiffstats
path: root/kernel/time/hrtimer.c
diff options
context:
space:
mode:
authorThomas Gleixner <tglx@linutronix.de>2015-04-14 17:08:58 -0400
committerThomas Gleixner <tglx@linutronix.de>2015-04-22 11:06:50 -0400
commitc1ad348b452aacd784fb97403d03d71723c72ee1 (patch)
tree8f57456095d7125463a9647701acfe24b9d96ffc /kernel/time/hrtimer.c
parent157d29e101c7d032e886df067aeea1b21a366cc5 (diff)
tick: Nohz: Rework next timer evaluation
The evaluation of the next timer in the nohz code is based on jiffies while all the tick internals are nano seconds based. We have also to convert hrtimer nanoseconds to jiffies in the !highres case. That's just wrong and introduces interesting corner cases. Turn it around and convert the next timer wheel timer expiry and the rcu event to clock monotonic and base all calculations on nanoseconds. That identifies the case where no timer is pending clearly with an absolute expiry value of KTIME_MAX. Makes the code more readable and gets rid of the jiffies magic in the nohz code. Signed-off-by: Thomas Gleixner <tglx@linutronix.de> Reviewed-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com> Acked-by: Peter Zijlstra <peterz@infradead.org> Cc: Preeti U Murthy <preeti@linux.vnet.ibm.com> Cc: Viresh Kumar <viresh.kumar@linaro.org> Cc: Marcelo Tosatti <mtosatti@redhat.com> Cc: Frederic Weisbecker <fweisbec@gmail.com> Cc: Josh Triplett <josh@joshtriplett.org> Cc: Lai Jiangshan <laijs@cn.fujitsu.com> Cc: John Stultz <john.stultz@linaro.org> Cc: Marcelo Tosatti <mtosatti@redhat.com> Link: http://lkml.kernel.org/r/20150414203502.184198593@linutronix.de Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Diffstat (limited to 'kernel/time/hrtimer.c')
-rw-r--r--kernel/time/hrtimer.c14
1 files changed, 5 insertions, 9 deletions
diff --git a/kernel/time/hrtimer.c b/kernel/time/hrtimer.c
index fc6b6d25f93d..179b991cfdcb 100644
--- a/kernel/time/hrtimer.c
+++ b/kernel/time/hrtimer.c
@@ -1080,26 +1080,22 @@ EXPORT_SYMBOL_GPL(hrtimer_get_remaining);
1080/** 1080/**
1081 * hrtimer_get_next_event - get the time until next expiry event 1081 * hrtimer_get_next_event - get the time until next expiry event
1082 * 1082 *
1083 * Returns the delta to the next expiry event or KTIME_MAX if no timer 1083 * Returns the next expiry time or KTIME_MAX if no timer is pending.
1084 * is pending.
1085 */ 1084 */
1086ktime_t hrtimer_get_next_event(void) 1085u64 hrtimer_get_next_event(void)
1087{ 1086{
1088 struct hrtimer_cpu_base *cpu_base = this_cpu_ptr(&hrtimer_bases); 1087 struct hrtimer_cpu_base *cpu_base = this_cpu_ptr(&hrtimer_bases);
1089 ktime_t mindelta = { .tv64 = KTIME_MAX }; 1088 u64 expires = KTIME_MAX;
1090 unsigned long flags; 1089 unsigned long flags;
1091 1090
1092 raw_spin_lock_irqsave(&cpu_base->lock, flags); 1091 raw_spin_lock_irqsave(&cpu_base->lock, flags);
1093 1092
1094 if (!__hrtimer_hres_active(cpu_base)) 1093 if (!__hrtimer_hres_active(cpu_base))
1095 mindelta = ktime_sub(__hrtimer_get_next_event(cpu_base), 1094 expires = __hrtimer_get_next_event(cpu_base).tv64;
1096 ktime_get());
1097 1095
1098 raw_spin_unlock_irqrestore(&cpu_base->lock, flags); 1096 raw_spin_unlock_irqrestore(&cpu_base->lock, flags);
1099 1097
1100 if (mindelta.tv64 < 0) 1098 return expires;
1101 mindelta.tv64 = 0;
1102 return mindelta;
1103} 1099}
1104#endif 1100#endif
1105 1101