diff mbox

kvm guest: hrtimer: interrupt too slow

Message ID 20091003231205.GA15015@amt.cnet (mailing list archive)
State New, archived
Headers show

Commit Message

Marcelo Tosatti Oct. 3, 2009, 11:12 p.m. UTC
None
diff mbox

Patch

diff --git a/kernel/hrtimer.c b/kernel/hrtimer.c
index 49da79a..8997978 100644
--- a/kernel/hrtimer.c
+++ b/kernel/hrtimer.c
@@ -1234,28 +1234,20 @@  static void __run_hrtimer(struct hrtimer *timer)
 
 #ifdef CONFIG_HIGH_RES_TIMERS
 
-static int force_clock_reprogram;
-
 /*
  * After 5 iteration's attempts, we consider that hrtimer_interrupt()
  * is hanging, which could happen with something that slows the interrupt
- * such as the tracing. Then we force the clock reprogramming for each future
- * hrtimer interrupts to avoid infinite loops and use the min_delta_ns
- * threshold that we will overwrite.
- * The next tick event will be scheduled to 3 times we currently spend on
- * hrtimer_interrupt(). This gives a good compromise, the cpus will spend
- * 1/4 of their time to process the hrtimer interrupts. This is enough to
- * let it running without serious starvation.
+ * such as the tracing, so we increase min_delta_ns.
  */
 
 static inline void
-hrtimer_interrupt_hanging(struct clock_event_device *dev,
-			ktime_t try_time)
+hrtimer_interrupt_hanging(struct clock_event_device *dev)
 {
-	force_clock_reprogram = 1;
-	dev->min_delta_ns = (unsigned long)try_time.tv64 * 3;
-	printk(KERN_WARNING "hrtimer: interrupt too slow, "
-		"forcing clock min delta to %lu ns\n", dev->min_delta_ns);
+	dev->min_delta_ns += dev->min_delta_ns >> 1;
+	if (printk_ratelimit())
+		printk(KERN_WARNING "hrtimer: interrupt too slow, "
+			"forcing clock min delta to %lu ns\n",
+			dev->min_delta_ns);
 }
 /*
  * High resolution timer interrupt
@@ -1276,7 +1268,7 @@  void hrtimer_interrupt(struct clock_event_device *dev)
  retry:
 	/* 5 retries is enough to notice a hang */
 	if (!(++nr_retries % 5))
-		hrtimer_interrupt_hanging(dev, ktime_sub(ktime_get(), now));
+		hrtimer_interrupt_hanging(dev);
 
 	now = ktime_get();
 
@@ -1342,7 +1334,7 @@  void hrtimer_interrupt(struct clock_event_device *dev)
 
 	/* Reprogramming necessary ? */
 	if (expires_next.tv64 != KTIME_MAX) {
-		if (tick_program_event(expires_next, force_clock_reprogram))
+		if (tick_program_event(expires_next, 0))
 			goto retry;
 	}
 }