Re: Interrupt doesn't make it to the 8259 on a ASUS P4PE mobo

From: Jamie Lokier (jamie@shareable.org)
Date: Tue Jul 15 2003 - 12:43:37 EST


Brian Gerst wrote:
> >>>dmatimer.expires = jiffies + 0.5*HZ;
> >>
> >>That's a serious bug. You cannot use floating point in the kernel.
> >>It will corrupt the FP state of the user process.
> >
> >HZ on the INTEL platform is 100, so this should simply add 50 to the
> >current
> >value of jiffies. Besides, assigning the value to the unsigned int field
> >(expires) will truncate it to an integer anyway.
>
> Use HZ/2 instead. GCC doesn't optimize floating point constants to the
> same degree it does integers, because it doesn't know what mode
> (rounding, precision) the FPU is in.

Optimising this to an integer add of 50 would be incorrect anyway.
Think about jiffies == 0xfffffffe.

The first statement is equivalent to:

        dmatimer.expires = (unsigned long) ((double) + 50)

and would set dmatimer.expires to 0xffffffff.

Whereas the HZ/2 form is correct!

Have a nice day,
-- Jamie
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/



This archive was generated by hypermail 2b29 : Tue Jul 15 2003 - 22:00:59 EST