Re: MSEC_TO_JIFFIES is messed up...

From: Ingo Molnar
Date: Wed May 12 2004 - 15:12:08 EST



* Davide Libenzi <davidel@xxxxxxxxxxxxxxx> wrote:

> > why is it wrong?
>
> For HZ == 1000 it's fine, even if it'd better to explicitly make it HZ
> dependent and let the compiler to discard them.

the compiler cannot discard the multiplication and the division from the
following:

x * 1000 / 1000

due to overflows. But we know that HZ is 1000 in the arch-dependent
param.h, and in sched.c we use the HZ dependent variant:

#ifndef JIFFIES_TO_MSEC
# define JIFFIES_TO_MSEC(x) ((x) * 1000 / HZ)
#endif
#ifndef MSEC_TO_JIFFIES
# define MSEC_TO_JIFFIES(x) ((x) * HZ / 1000)
#endif

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