From patchwork Thu Oct 8 19:22:23 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marcelo Tosatti X-Patchwork-Id: 52586 Received: from vger.kernel.org (vger.kernel.org [209.132.176.167]) by demeter.kernel.org (8.14.2/8.14.2) with ESMTP id n98JTLlb021354 for ; Thu, 8 Oct 2009 19:29:21 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932894AbZJHTXr (ORCPT ); Thu, 8 Oct 2009 15:23:47 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S932829AbZJHTXr (ORCPT ); Thu, 8 Oct 2009 15:23:47 -0400 Received: from mx1.redhat.com ([209.132.183.28]:41414 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932823AbZJHTXq (ORCPT ); Thu, 8 Oct 2009 15:23:46 -0400 Received: from int-mx03.intmail.prod.int.phx2.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id n98JMoQo032531; Thu, 8 Oct 2009 15:22:50 -0400 Received: from ns3.rdu.redhat.com (ns3.rdu.redhat.com [10.11.255.199]) by int-mx03.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id n98JMndf018813; Thu, 8 Oct 2009 15:22:49 -0400 Received: from amt.cnet (vpn-10-92.str.redhat.com [10.32.10.92]) by ns3.rdu.redhat.com (8.13.8/8.13.8) with ESMTP id n98JMkxV009082; Thu, 8 Oct 2009 15:22:47 -0400 Received: from amt.cnet (amt.cnet [127.0.0.1]) by amt.cnet (Postfix) with ESMTP id CBF956814E2; Thu, 8 Oct 2009 16:22:30 -0300 (BRT) Received: (from marcelo@localhost) by amt.cnet (8.14.3/8.14.3/Submit) id n98JMOxj008267; Thu, 8 Oct 2009 16:22:24 -0300 Date: Thu, 8 Oct 2009 16:22:23 -0300 From: Marcelo Tosatti To: Thomas Gleixner Cc: Frederic Weisbecker , Michael Tokarev , kvm , Ingo Molnar Subject: Re: kvm guest: hrtimer: interrupt too slow Message-ID: <20091008192223.GA8111@amt.cnet> References: <4AC207B1.7020901@msgid.tls.msk.ru> <20091003231205.GA15015@amt.cnet> <20091007231733.GG5903@nowhere> <20091008005456.GA10032@amt.cnet> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.19 (2009-01-05) X-Scanned-By: MIMEDefang 2.67 on 10.5.11.16 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org 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; } }