Re: [PATCH 0/4] Really lazy fpu

Avi Kivity
2010-06-16T08:02:47Z

On 06/16/2010 10:32 AM, H. Peter Anvin wrote:
> On 06/16/2010 12:24 AM, Avi Kivity wrote:
>
>> Ingo, Peter, any feedback on this?
>>
> Conceptually, this makes sense to me. However, I have a concern what
> happens when a task is scheduled on another CPU, while its FPU state is
> still in registers in the original CPU. That would seem to require
> expensive IPIs to spill the state in order for the rescheduling to
> proceed, and this could really damage performance.
>

Right, this optimization isn't free.

I think the tradeoff is favourable since task migrations are much less
frequent than context switches within the same cpu, can the scheduler
experts comment?

We can also mitigate some of the IPIs if we know that we're migrating on
the cpu we're migrating from (i.e. we're pushing tasks to another cpu,
not pulling them from their cpu). Is that a common case, and if so,
where can I hook a call to unlazy_fpu() (or its new equivalent)?

Note that kvm on intel has exactly the same issue (the VMPTR and VMCS
are on-chip registers that are expensive to load and save, so we keep
them loaded even while not scheduled, and IPI if we notice we've
migrated; note that architecturally the cpu can cache multiple VMCSs
simultaneously (though I doubt they cache multiple VMCSs
microarchitecturally at this point)).

--
error compiling committee.c: too many arguments to function