blob: b2ec3268eeb759b7f93ac77ba602adade762e03c [file] [log] [blame]
From d766bacb28e2ac29f6facd1c7995289b177b366c Mon Sep 17 00:00:00 2001
From: Ingo Molnar <mingo@elte.hu>
Date: Fri, 3 Jul 2009 08:30:20 -0500
Subject: [PATCH] timers: preempt-rt support
commit c90fc5b4462b0291bfce50ddf31e142471dc4803 in tip.
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Paul Gortmaker <paul.gortmaker@windriver.com>
diff --git a/kernel/timer.c b/kernel/timer.c
index fc3a98c..9f1a662 100644
--- a/kernel/timer.c
+++ b/kernel/timer.c
@@ -1226,6 +1226,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);
@@ -1234,7 +1246,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
@@ -1259,30 +1271,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))
@@ -1308,6 +1302,7 @@ void run_local_timers(void)
void do_timer(unsigned long ticks)
{
jiffies_64 += ticks;
+ update_wall_time();
calc_global_load();
}
--
1.7.1.1