On Tue, Sep 17, 2002 at 02:42:20PM -0400, justinca@cs.cmu.edu wrote:
> >
> > This requires each CPU to remember the last owner of FPU.
> > In order to support possible process migration cases in a SMP
> > system, each process also needs to remember the processor
> > on which it used FPU last. A process has a valid live FPU
> > context on a CPU if those two variables match to each other.
> > Therefore we can avoid unnecessary restoring FPU context.
> >
> > Fairly complex in implementation.
> >
>
> I'd argue for something between 2 & 3. Always save FPU state, and if
> you know the state has been preserved for the next run, skip the
> restore.
>
Determining whether the current FPU context is valid for the new
process is not easy. It requires last_task_used_math like variable
for each CPU.
> I'm a bit leery of the whole "don't restore FPU state on context switch
> until you use the FPU again" idea as it's added complexity
Quite easy to implement. Just turn off ST0_CU1 bit in the status register
saved in the kernel stack when a process is switched off. Therefore
next use of FPU will cause a trap and do_cpu() does the normal thing.
> and I'm not
> at all sure you're going to see any measurable performance gain out of
> it.
I think this gives a big performance improvement because most processes
don't use FPU during their runs but they all have used_math flag set!
Jun
|