From mboxrd@z Thu Jan 1 00:00:00 1970 From: "David S. Ahern" Subject: Re: kvm guest loops_per_jiffy miscalibration under host load Date: Tue, 22 Jul 2008 20:57:22 -0600 Message-ID: <48869E12.40804@cisco.com> References: <20080722032510.GB1358@dmt.cnet> <48863B5C.9040203@cisco.com> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Cc: kvm-devel To: Marcelo Tosatti Return-path: Received: from sj-iport-6.cisco.com ([171.71.176.117]:6133 "EHLO sj-iport-6.cisco.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751660AbYGWC5Y (ORCPT ); Tue, 22 Jul 2008 22:57:24 -0400 In-Reply-To: <48863B5C.9040203@cisco.com> Sender: kvm-owner@vger.kernel.org List-ID: David S. Ahern wrote: >> The in-kernel PIT rearms relative to host clock, so the frequency is >> more reliable (next_expiration = prev_expiration + count). >> >> So for RHEL4, clock=pit along with the following patch seems stable for >> me, no drift either direction, even under guest/host load. Can you give >> it a try with RHEL3 ? I'll be doing that shortly. > > I'll give it a shot and let you know. After 6:46 of uptime, my RHEL4 guest is only 7 seconds ahead of the host. The RHEL3 guest is 17 seconds ahead. Both are dramatic improvements with the patch. david >> >> ---------- >> >> Set the count load time to when the count is actually "loaded", not when >> IRQ is injected. >> >> diff --git a/arch/x86/kvm/i8254.c b/arch/x86/kvm/i8254.c >> index c0f7872..b39b141 100644 >> --- a/arch/x86/kvm/i8254.c >> +++ b/arch/x86/kvm/i8254.c >> @@ -207,6 +207,7 @@ static int __pit_timer_fn(struct kvm_kpit_state *ps) >> >> pt->timer.expires = ktime_add_ns(pt->timer.expires, pt->period); >> pt->scheduled = ktime_to_ns(pt->timer.expires); >> + ps->channels[0].count_load_time = pt->timer.expires; >> >> return (pt->period == 0 ? 0 : 1); >> } >> @@ -622,7 +623,6 @@ void kvm_pit_timer_intr_post(struct kvm_vcpu *vcpu, int vec) >> arch->vioapic->redirtbl[0].fields.mask != 1))) { >> ps->inject_pending = 1; >> atomic_dec(&ps->pit_timer.pending); >> - ps->channels[0].count_load_time = ktime_get(); >> } >> } >> } >>