Floating point in interrupt handler

M. Warner Losh imp at bsdimp.com
Wed Oct 24 14:17:57 PDT 2007


In message: <200710222211.51590.Danovitsch at vitsch.net>
            "Daan Vreeken [PA4DAN]" <Danovitsch at vitsch.net> writes:
: But what I haven't found is a description of exactly what the kernel is 
: missing to allow floating point operations to be done there.

FPU context is assumed to only change in user processes.  You'd have
to fix the FPU state saving code to cope with it changing everywhere,
or you'd have to explicitly put the goo to save/restore it around the
FP you want to do in the kernel.  You had also make sure that the
floating point exceptions never trap, since trapping inside the kernel
has very limited support.  You'll have to fix the problems that this
would cause, or force the FPU into a state where it never traps.

Sure, maybe you can make it happen.  However, you are in for much pain
and suffering.  The kernel isn't a general purpose computing
environment, and trying to pretend it is will lead to suffering.
Especially inside of an interrupt handler.  It is less bad if this is
an ithread, but could be quite painful if you want to do this inside
of a fast interrupt handler to reduce latency.

I'd recommend strongly against trying this and revaluate your true
need for FP in the kernel.  From your other mail, you don't seem open
to this answer.  If you don't take it, you are setting yourself up for
a lot of pain and suffering.  It is your choice, however.  If you do
manage to pull it of, I'd be very interested in see what things I
didn't know to warn you about...

Warner


More information about the freebsd-hackers mailing list