linux-mips
[Top] [All Lists]

Re: FP emulator patch

To: "Kevin D. Kissell" <kevink@mips.com>
Subject: Re: FP emulator patch
From: Jun Sun <jsun@mvista.com>
Date: Thu, 16 Aug 2001 16:14:02 -0700
Cc: "MIPS/Linux List (SGI)" <linux-mips@oss.sgi.com>, Daniel Jacobowitz <dan@debian.org>
References: <01e801c126a6$ec2a3420$0deca8c0@Ulysses>
Sender: owner-linux-mips@oss.sgi.com
"Kevin D. Kissell" wrote:
> 
> > >
> > >         if (current->used_math) {               /* Using the FPU again.
> > */
> > >                 lazy_fpu_switch(last_task_used_math);
> > >         } else {                                /* First time FPU user.
> > */
> > >                 init_fpu();
> > >                 current->used_math = 1;
> > >         }
> > >         last_task_used_math = current;
> > >
> > > Clearly the second path is logically the correct one.
> >
> > Not really.  See below.
> >
> > > BTW, do I see another bug here in do_cpu()?  It seems that before we
> call
> > > init_fpu(), we should check last_task_used_math.  If it is not NULL, we
> > should
> > > save the FP state to the last_task_used_math.  Hmm, strange ...
> >
> > Strange indeed.  And note that if the code were correct, your
> > surmise about the init_fpu() path being "logically the correct"
> > one would no longer be true - we'd be saving the FPU state of
> > the current process for no good reason.
> 
> And note further that, by forcing current->used_math to
> zero, the old code was in fact driving the signal handler
> needlessly into the broken code...
> 

By not clearing current->used_math bit, you are in fact restoring an FPU
context unnecessarily.

Jun

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