Re: [RFT] mmu optimizations branch

Avi Kivity
2007-01-03T08:32:21Z

Ingo Molnar wrote:
> * Avi Kivity <avi-atKUWr5tajBWk0Htik3J/w@public.gmane.org> wrote:
>
>
>>> lat_ctx -s 0 [zero memory footprint]:
>>>
>>> -------------------------------------------------
>>> #tasks native kvm-r4204 kvm-r4232(mmu)
>>> -------------------------------------------------
>>> 2: 2.02 180.91 9.19
>>> 20: 4.04 183.21 10.01
>>> 50: 4.30 185.95 11.27
>>>
>>> so here it's a /massive/, almost 20 times speedup!
>>>
>>>
>> Excellent. 10us is approximately the vmexit overhead on intel (we
>> regularly see 100-120k exits/sec), so it means a context switch is
>> exactly one exit. Hard to beat without nested page tables.
>>
>
> actually, the VM entry+exit cost on this CPU is around 3-4 microseconds,
> so it's still 2 VM exits per context switch.
>
> I debugged this a bit, and what happens is that when Linux does a
> task-switch it does a cr3 load /and/ a write (look at __flush_tlb()) -
> and both are causing a vm exit!
>
> I have started paravirtualizing the Linux kernel for KVM. I have
> eliminated the cr3 load from the Linux kernel via paravirtualization and
> that way lat_ctx shows a ~5-6 usecs context-switch cost. That's pretty
> good i think, compared to the 2-3 usecs of native. I'll send patches for
> this tomorrow.
>

Does this really call for parvirtualization? Caching the old cr3 value
will work for native as well.