netdev
[Top] [All Lists]

Re: MSEC_TO_JIFFIES is messed up...

To: Davide Libenzi <davidel@xxxxxxxxxxxxxxx>
Subject: Re: MSEC_TO_JIFFIES is messed up...
From: Ingo Molnar <mingo@xxxxxxx>
Date: Wed, 12 May 2004 22:03:05 +0200
Cc: Jeff Garzik <jgarzik@xxxxxxxxx>, Greg KH <greg@xxxxxxxxx>, Andrew Morton <akpm@xxxxxxxx>, Linux Kernel Mailing List <linux-kernel@xxxxxxxxxxxxxxx>, Netdev <netdev@xxxxxxxxxxx>
In-reply-to: <Pine.LNX.4.58.0405121247011.11950@xxxxxxxxxxxxxxxxxxxxxxx>
References: <20040512020700.6f6aa61f.akpm@xxxxxxxx> <20040512181903.GG13421@xxxxxxxxx> <40A26FFA.4030701@xxxxxxxxx> <20040512193349.GA14936@xxxxxxx> <Pine.LNX.4.58.0405121247011.11950@xxxxxxxxxxxxxxxxxxxxxxx>
Sender: netdev-bounce@xxxxxxxxxxx
User-agent: Mutt/1.4.1i
* 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

<Prev in Thread] Current Thread [Next in Thread>