Subject: Re: Lazy FP in SMP
To: Matt Thomas <matt@3am-software.com>
From: Jason R Thorpe <thorpej@zembu.com>
List: tech-smp
Date: 11/21/2000 08:01:59
On Tue, Nov 21, 2000 at 10:51:50AM -0500, Allen Briggs wrote:

 > On Mon, Nov 20, 2000 at 11:19:36PM -0800, Matt Thomas wrote:
 > > Either way, a process get screwed.  This also mean that more bookkeeping
 > > needs to added such that you know what CPU has this processors FP state.
 > 
 > The only other clean-ish solution that I can think of is to have
 > semi-lazy FP and only do lazy FP state restores.  If FP is used,
 > always save it on the context switch.  Of course, this is probably
 > a net loss since you pay part of the penalty every time you context
 > switch an FP-using process.

Nonono.

Look at both the i386 and Alpha ports for how this is done.

The basic idea is: track which CPU has the floating point state for a
particular PCB.  When you take an FP fault, if the fpcpu is not curcpu,
send an interprocessor interrupt to fpcpu to synchronize the FP state
back to the PCB, and wait for that to complete.

It's actually not that hard.

-- 
        -- Jason R. Thorpe <thorpej@zembu.com>