Re: kvm guest loops_per_jiffy miscalibration under host load

David S. Ahern
2008-07-23T02:57:24Z

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();
>> }
>> }
>> }
>>