Re: kvm guest: hrtimer: interrupt too slow

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: Marcelo Tosatti
Date: Thursday, October 8, 2009 - 12:22 pm

On Thu, Oct 08, 2009 at 10:05:01AM +0200, Thomas Gleixner wrote:

OK, makes sense.

So why not program only the next tick using the heuristic, without 
touching min_delta_ns?



diff --git a/kernel/hrtimer.c b/kernel/hrtimer.c
index c03f221..4fcb670 100644
--- a/kernel/hrtimer.c
+++ b/kernel/hrtimer.c
@@ -1178,29 +1178,16 @@ 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.
+ * such as the tracing. 
  * 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.
  */
 
-static inline void
-hrtimer_interrupt_hanging(struct clock_event_device *dev,
-			ktime_t try_time)
-{
-	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);
-}
 /*
  * High resolution timer interrupt
  * Called with interrupts disabled
@@ -1219,8 +1206,16 @@ 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));
+	if (!(++nr_retries % 5)) {
+		ktime_t try_time = ktime_sub(ktime_get(), now);
+
+		do {
+			for (i = 0; i < 3; i++)
+				expires_next = ktime_add(expires_next,try_time);
+		} while (tick_program_event(expires_next, 0));
+
+		return;
+	}
 
 	now = ktime_get();
 
@@ -1286,7 +1281,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;
 	}
 }

--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
kvm guest: hrtimer: interrupt too slow, Michael Tokarev, (Tue Sep 29, 6:12 am)
Re: kvm guest: hrtimer: interrupt too slow, Avi Kivity, (Tue Sep 29, 6:47 am)
Re: kvm guest: hrtimer: interrupt too slow, Michael Tokarev, (Tue Sep 29, 6:58 am)
Re: kvm guest: hrtimer: interrupt too slow, Marcelo Tosatti, (Sat Oct 3, 4:12 pm)
Re: kvm guest: hrtimer: interrupt too slow, Michael Tokarev, (Sun Oct 4, 5:01 am)
Re: kvm guest: hrtimer: interrupt too slow, Marcelo Tosatti, (Sun Oct 4, 5:50 pm)
Re: kvm guest: hrtimer: interrupt too slow, Michael Tokarev, (Mon Oct 5, 2:31 am)
Re: kvm guest: hrtimer: interrupt too slow, Avi Kivity, (Mon Oct 5, 3:47 am)
Re: kvm guest: hrtimer: interrupt too slow, Michael Tokarev, (Tue Oct 6, 6:30 am)
Re: kvm guest: hrtimer: interrupt too slow, Frederic Weisbecker, (Wed Oct 7, 4:17 pm)
Re: kvm guest: hrtimer: interrupt too slow, Marcelo Tosatti, (Wed Oct 7, 5:54 pm)
Re: kvm guest: hrtimer: interrupt too slow, Michael Tokarev, (Thu Oct 8, 12:54 am)
Re: kvm guest: hrtimer: interrupt too slow, Thomas Gleixner, (Thu Oct 8, 1:05 am)
Re: kvm guest: hrtimer: interrupt too slow, Thomas Gleixner, (Thu Oct 8, 1:06 am)
Re: kvm guest: hrtimer: interrupt too slow, Michael Tokarev, (Thu Oct 8, 1:09 am)
Re: kvm guest: hrtimer: interrupt too slow, Michael Tokarev, (Thu Oct 8, 1:14 am)
Re: kvm guest: hrtimer: interrupt too slow, Thomas Gleixner, (Thu Oct 8, 2:29 am)
Re: kvm guest: hrtimer: interrupt too slow, Michael Tokarev, (Thu Oct 8, 7:06 am)
Re: kvm guest: hrtimer: interrupt too slow, Thomas Gleixner, (Thu Oct 8, 8:06 am)
Re: kvm guest: hrtimer: interrupt too slow, Marcelo Tosatti, (Thu Oct 8, 12:22 pm)
Re: kvm guest: hrtimer: interrupt too slow, Marcelo Tosatti, (Thu Oct 8, 12:52 pm)
Re: kvm guest: hrtimer: interrupt too slow, Thomas Gleixner, (Thu Oct 8, 1:25 pm)
Re: kvm guest: hrtimer: interrupt too slow, Michael Tokarev, (Thu Oct 8, 2:02 pm)
Re: kvm guest: hrtimer: interrupt too slow, Michael Tokarev, (Fri Oct 9, 2:22 pm)
Re: kvm guest: hrtimer: interrupt too slow, Frederic Weisbecker, (Fri Oct 9, 3:27 pm)
Re: kvm guest: hrtimer: interrupt too slow, Michael Tokarev, (Fri Oct 9, 3:34 pm)
Re: kvm guest: hrtimer: interrupt too slow, Michael Tokarev, (Sat Oct 10, 2:18 am)
Re: kvm guest: hrtimer: interrupt too slow, Frederic Weisbecker, (Sat Oct 10, 2:24 am)
[PATCH] tune hrtimer_interrupt hang logic, Marcelo Tosatti, (Sat Oct 10, 10:32 am)
Re: kvm guest: hrtimer: interrupt too slow, Marcelo Tosatti, (Sat Oct 10, 10:37 am)