RE: Floating point in kernel

From: Jeremy Fitzhardinge (
Date: Wed May 03 2000 - 12:31:50 EST

On 03-May-2000 B. James Phillippe wrote:
> Hello,
> I know this is not legal. However, I'm reviewing some kernel module code
> which basically does:
> unsigned long foo = some_other_ulong * 1.234;
> This code has apparently been working for some time. According to C rules
> of type promotion, "some_other_ulong" should be promoted to a double to
> store the result of the expression, before discarding the fraction and
> assigning to foo.
> My question is, what are the likely problems to expect from this when
> running in kernel-space (on x86 w/FPU)?

Some random process loses some of its FP state. If you don't have
user-processes using FP, then you could go for some time without noticing it;
it depends on how often the kernel FP code runs.

To do this properly, you have to save any FP state and make sure the user
process which owns that FP state reloads it. In other words, you have to undo
the effects of lazy FP switching. On SMP systems you may not need to do
anything; I'm not sure.


To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to
Please read the FAQ at

This archive was generated by hypermail 2b29 : Sun May 07 2000 - 21:00:12 EST