| To: | Ingo Molnar <mingo@xxxxxxx> |
|---|---|
| Subject: | Re: MSEC_TO_JIFFIES is messed up... |
| From: | Valdis.Kletnieks@xxxxxx |
| Date: | Wed, 12 May 2004 17:03:10 -0400 |
| Cc: | linux-kernel@xxxxxxxxxxxxxxx, Netdev <netdev@xxxxxxxxxxx> |
| In-reply-to: | Your message of "Wed, 12 May 2004 22:50:28 +0200." <20040512205028.GA18806@elte.hu> |
| References: | <20040512020700.6f6aa61f.akpm@osdl.org> <20040512181903.GG13421@kroah.com> <40A26FFA.4030701@pobox.com> <20040512193349.GA14936@elte.hu> <200405121947.i4CJlJm5029666@turing-police.cc.vt.edu> <Pine.LNX.4.58.0405121255170.11950@bigblue.dev.mdolabs.com> <200405122007.i4CK7GPQ020444@turing-police.cc.vt.edu> <20040512202807.GA16849@elte.hu> <20040512203500.GA17999@elte.hu> <20040512205028.GA18806@elte.hu> |
| Sender: | netdev-bounce@xxxxxxxxxxx |
On Wed, 12 May 2004 22:50:28 +0200, Ingo Molnar said:
> Content-Disposition: attachment; filename="hz-cleanup-2.6.6-A2"
>
> --- linux/include/linux/time.h.orig
> +++ linux/include/linux/time.h
> @@ -177,6 +177,24 @@ struct timezone {
> (SH_DIV((MAX_JIFFY_OFFSET >> SEC_JIFFIE_SC) * TICK_NSEC, NSEC_PER_SEC,
1) - 1)
>
> #endif
> +
> +/*
> + * Convert jiffies to milliseconds and back.
> + *
> + * Avoid unnecessary multiplications/divisions in the
> + * two most common HZ cases:
> + */
> +#if HZ == 1000
> +# define JIFFIES_TO_MSECS(x) (x)
> +# define MSECS_TO_JIFFIES(x) (x)
> +#elif HZ == 100
> +# define JIFFIES_TO_MSECS(x) ((x) * 10)
> +# define MSECS_TO_JIFFIES(x) ((x) / 10)
> +#else
> +# define JIFFIES_TO_MSECS(x) ((x) * 1000 / HZ)
> +# define MSECS_TO_JIFFIES(x) ((x) * HZ / 1000)
> +#endif
> +
Looks good to me.. :)
|
| Previous by Date: | Re: MSEC_TO_JIFFIES is messed up..., Davide Libenzi |
|---|---|
| Next by Date: | Re: MSEC_TO_JIFFIES is messed up..., Sridhar Samudrala |
| Previous by Thread: | Re: MSEC_TO_JIFFIES is messed up..., Ingo Molnar |
| Next by Thread: | Re: MSEC_TO_JIFFIES is messed up..., Davide Libenzi |
| Indexes: | [Date] [Thread] [Top] [All Lists] |