Re: [PATCH] kvm-userspace: Make PC speaker emulation aware of in-kernel PIT

Sheng Yang
2009-04-27T13:00:54Z

On Sunday 26 April 2009 03:59:11 Anthony Liguori wrote:
> Jan Kiszka wrote:
> > Anthony Liguori wrote:
> >> Marcelo Tosatti wrote:
> >>> Jan,
> >>>
> >>> While the patch itself looks fine, IMO it would be better to move all
> >>> of the timer handling to userspace, except the performance critical
> >>> parts,
> >>> since most of it is generic. Either periodic or one-shot timer, with:
> >>
> >> The reason for having the PIT in-kernel is not performance. The PIT is
> >> not performance sensitive.
> >
> > I think that depends. Some OSes (in some configurations) use the PIT
> > counter as clock source and/or program it regularly in one-shot mode. An
> > aging use case, but still a valid one.
>
> I can't find the thread, but this has been discussed at length before.
> The justification has always been for time drift correction. If you
> crunch the numbers, even at a 1024HZ, there just aren't enough exits to
> really make a difference from a performance perspective.

I am agree too.

When I moved PIT to kernel, the direct reason is at that time, timer in KVM is
crappy, mainly due to interrupt handling stuffs. I remember the most obviously
one is userspace pit injected one interrupt after another, regardless if the
interrupt have already been delivered to the guest, so some interrupt lost,
and the timer of guest would become slower and slower. We decided to depends
on in-kernel pit to provide a stable time source, so move the whole pit to
kernel(rather than try to provide a interface to fix it as Xen did at the time
which seems much more complex).

Now KVM timer is much maturer and stable than that time, so I think it's ok to
try to separate the timer interrupt logic and IO logic now. (though I also
think it would still spend some time to get a elegant interface...)

--
regards
Yang, Sheng

>
> Just to state it more clearly, if you assume an additional 5us to drop
> to userspace (which is absurdly high, but let's stick with it), 1024
> exits per second comes out to about 5ms which is only 0.5% in terms of
> CPU consumption.
>
> The APIC is quite a bit more understandable because especially with SMP,
> you can generate a very high number of interrupts per second and taking
> a drop to userspace for every EOI can be start to matter with exit rates
> in the hundreds of thousands.
>
> >> It's because it was easier to do interrupt catch-up by pushing the PIT
> >> into the kernel which IMHO was the wrong path to go down.
> >
> > Pushing the emulation of port 0x61 into the kernel was a mistake we now
> > have to deal with. I'm not that sure about the PIT itself.
>
> I agree re: port 0x61. I'm just saying that there is no point in moving
> just the non "performance critical" components to userspace as Marcelo
> suggests because the whole thing is non "performance critical".
>
> Regards,
>
> Anthony Liguori
>
> --
> 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