From 7e6bc9b077c1cfeddbc84d278b1a275eea2682e9 Mon Sep 17 00:00:00 2001 From: Ingo Molnar Date: Fri, 3 Jul 2009 08:30:20 -0500 Subject: [PATCH] timers: preempt-rt support commit c90fc5b4462b0291bfce50ddf31e142471dc4803 in tip. Signed-off-by: Ingo Molnar Signed-off-by: Thomas Gleixner Signed-off-by: Paul Gortmaker --- kernel/timer.c | 33 ++++++++++++++------------------- 1 files changed, 14 insertions(+), 19 deletions(-) diff --git a/kernel/timer.c b/kernel/timer.c index e368fe7..e342eef 100644 --- a/kernel/timer.c +++ b/kernel/timer.c @@ -1228,6 +1228,18 @@ unsigned long get_next_timer_interrupt(unsigned long now) struct tvec_base *base = __get_cpu_var(tvec_bases); unsigned long expires; +#ifdef CONFIG_PREEMPT_RT + /* + * On PREEMPT_RT we cannot sleep here. If the trylock does not + * succeed then we return the worst-case 'expires in 1 tick' + * value: + */ + if (spin_trylock(&base->lock)) { + expires = __next_timer_interrupt(base); + spin_unlock(&base->lock); + } else + expires = now + 1; +#else spin_lock(&base->lock); if (time_before_eq(base->next_timer, base->timer_jiffies)) base->next_timer = __next_timer_interrupt(base); @@ -1236,7 +1248,7 @@ unsigned long get_next_timer_interrupt(unsigned long now) if (time_before_eq(expires, now)) return now; - +#endif return cmp_next_hrtimer_event(now, expires); } #endif @@ -1261,30 +1273,12 @@ void update_process_times(int user_tick) } /* - * Time of day handling: - */ -static inline void update_times(void) -{ - static unsigned long last_tick = INITIAL_JIFFIES; - unsigned long ticks, flags; - - write_raw_seqlock_irqsave(&xtime_lock, flags); - ticks = jiffies - last_tick; - if (ticks) { - last_tick += ticks; - update_wall_time(); - } - write_raw_sequnlock_irqrestore(&xtime_lock, flags); -} - -/* * This function runs timers and the timer-tq in bottom half context. */ static void run_timer_softirq(struct softirq_action *h) { struct tvec_base *base = __get_cpu_var(tvec_bases); - update_times(); hrtimer_run_pending(); if (time_after_eq(jiffies, base->timer_jiffies)) @@ -1310,6 +1304,7 @@ void run_local_timers(void) void do_timer(unsigned long ticks) { jiffies_64 += ticks; + update_wall_time(); calc_global_load(); } -- 1.7.0.4