diff options
author | Paul Mackerras <paulus@samba.org> | 2006-03-09 04:32:05 +0100 |
---|---|---|
committer | Paul Mackerras <paulus@samba.org> | 2006-03-09 04:32:05 +0100 |
commit | 516450179454de9e689e0a53ed8f34b896e8651c (patch) | |
tree | 78eae2f77de6cd39b18c7393fc5854456fc3fb1f /kernel/hrtimer.c | |
parent | Merge ../powerpc-merge (diff) | |
parent | Merge git://git.kernel.org/pub/scm/linux/kernel/git/paulus/powerpc-merge (diff) | |
download | linux-516450179454de9e689e0a53ed8f34b896e8651c.tar.xz linux-516450179454de9e689e0a53ed8f34b896e8651c.zip |
Merge ../linux-2.6
Diffstat (limited to 'kernel/hrtimer.c')
-rw-r--r-- | kernel/hrtimer.c | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/kernel/hrtimer.c b/kernel/hrtimer.c index 5ae51f1bc7c8..14bc9cfa6399 100644 --- a/kernel/hrtimer.c +++ b/kernel/hrtimer.c @@ -505,6 +505,41 @@ ktime_t hrtimer_get_remaining(const struct hrtimer *timer) return rem; } +#ifdef CONFIG_NO_IDLE_HZ +/** + * hrtimer_get_next_event - get the time until next expiry event + * + * Returns the delta to the next expiry event or KTIME_MAX if no timer + * is pending. + */ +ktime_t hrtimer_get_next_event(void) +{ + struct hrtimer_base *base = __get_cpu_var(hrtimer_bases); + ktime_t delta, mindelta = { .tv64 = KTIME_MAX }; + unsigned long flags; + int i; + + for (i = 0; i < MAX_HRTIMER_BASES; i++, base++) { + struct hrtimer *timer; + + spin_lock_irqsave(&base->lock, flags); + if (!base->first) { + spin_unlock_irqrestore(&base->lock, flags); + continue; + } + timer = rb_entry(base->first, struct hrtimer, node); + delta.tv64 = timer->expires.tv64; + spin_unlock_irqrestore(&base->lock, flags); + delta = ktime_sub(delta, base->get_time()); + if (delta.tv64 < mindelta.tv64) + mindelta.tv64 = delta.tv64; + } + if (mindelta.tv64 < 0) + mindelta.tv64 = 0; + return mindelta; +} +#endif + /** * hrtimer_init - initialize a timer to the given clock * |