linux-mips
[Top] [All Lists]

Re: [RFC] FPU context switch

To: justinca@cs.cmu.edu
Subject: Re: [RFC] FPU context switch
From: Jun Sun <jsun@mvista.com>
Date: Tue, 17 Sep 2002 11:48:31 -0700
Cc: linux-mips@linux-mips.org, jsun@mvista.com
In-reply-to: <1032288140.28433.165.camel@gs256.sp.cs.cmu.edu>; from justinca@cs.cmu.edu on Tue, Sep 17, 2002 at 02:42:20PM -0400
Original-recipient: rfc822;linux-mips@linux-mips.org
References: <20020917110423.E17321@mvista.com> <1032288140.28433.165.camel@gs256.sp.cs.cmu.edu>
Sender: linux-mips-bounce@linux-mips.org
User-agent: Mutt/1.2.5i
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


<Prev in Thread] Current Thread [Next in Thread>