Subject: Re: Floating point calculation in the kernel
To: der Mouse <mouse@rodents.montreal.qc.ca>
From: Charles M. Hannum <abuse@spamalicious.com>
List: tech-kern
Date: 02/24/2005 23:49:42
On Thursday 24 February 2005 23:19, der Mouse wrote:
> >> Or tweak the port you're using to save/restore FPU state when your
> >> code wants to use it. (Though I suspect using the word "tweak" may
> >> underestimate the work involved in this option.)
> >
> > Actually, it would be very easy on x86. I think I did it once while
> > playing with winmodem crap...
>
> I assume that what you did was an explicit save before and restore
> after the kernel float stuff? Any thoughts on how hard it would be to
> do saves and restores as necessary to make floating point in the kernel
> Just Work? (I feel certain it's _possible_; I'm just wondering how
> hard it would be to do, and how much of a speed penalty would ensue.)
I specifically implemented the lazy save/restore because it was significantly
faster, especially on older processors. (Same reason I avoided the
save/restore of %fs/%gs -- it was *very* slow on CPUs prior to the PII.)
With the proper abstraction, the explicit save/restore around the code that
uses FP is just a couple of function calls -- no worse than, e.g., disabling
interrupts momentarily.