LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
* MSEC_TO_JIFFIES is messed up...
[not found] <20040512020700.6f6aa61f.akpm@osdl.org>
@ 2004-05-12 18:19 ` Greg KH
2004-05-12 18:42 ` Jeff Garzik
0 siblings, 1 reply; 54+ messages in thread
From: Greg KH @ 2004-05-12 18:19 UTC (permalink / raw)
To: Andrew Morton, mingo; +Cc: linux-kernel
On Wed, May 12, 2004 at 02:07:00AM -0700, Andrew Morton wrote:
> drivers/usb/host/ehci.h:599: warning: `MSEC_TO_JIFFIES' redefined
> include/asm/param.h:9: warning: this is the location of the previous definition
> In file included from drivers/usb/host/ohci-hcd.c:127:
> drivers/usb/host/ohci.h:400: warning: `MSEC_TO_JIFFIES' redefined
> include/asm/param.h:9: warning: this is the location of the previous definition
Woah, that's new. And wrong. The code in include/asm-i386/param.h that
says:
# define JIFFIES_TO_MSEC(x) (x)
# define MSEC_TO_JIFFIES(x) (x)
Is not correct. Look at kernel/sched.c for verification of this :)
Looks like we just messed with our carefully tuned scheduler...
We can blame the following changeset from Ingo:
ChangeSet 1.1608.6.15 2004/05/10 13:26:09 akpm@osdl.org
[PATCH] sched: trivial fixes, cleanups
From: Ingo Molnar <mingo@elte.hu>
The trivial fixes.
- added recent trivial bits from Nick's and my patches.
- hotplug CPU fix
- early init cleanup
thanks,
greg k-h
^ permalink raw reply [flat|nested] 54+ messages in thread
* Re: MSEC_TO_JIFFIES is messed up...
2004-05-12 18:19 ` MSEC_TO_JIFFIES is messed up Greg KH
@ 2004-05-12 18:42 ` Jeff Garzik
2004-05-12 19:33 ` Ingo Molnar
2004-05-12 20:54 ` Bill Rugolsky Jr.
0 siblings, 2 replies; 54+ messages in thread
From: Jeff Garzik @ 2004-05-12 18:42 UTC (permalink / raw)
To: Greg KH; +Cc: Andrew Morton, mingo, linux-kernel, Netdev
Greg KH wrote:
> On Wed, May 12, 2004 at 02:07:00AM -0700, Andrew Morton wrote:
>
>>drivers/usb/host/ehci.h:599: warning: `MSEC_TO_JIFFIES' redefined
>>include/asm/param.h:9: warning: this is the location of the previous definition
>>In file included from drivers/usb/host/ohci-hcd.c:127:
>>drivers/usb/host/ohci.h:400: warning: `MSEC_TO_JIFFIES' redefined
>>include/asm/param.h:9: warning: this is the location of the previous definition
>
>
> Woah, that's new. And wrong. The code in include/asm-i386/param.h that
> says:
> # define JIFFIES_TO_MSEC(x) (x)
> # define MSEC_TO_JIFFIES(x) (x)
>
> Is not correct. Look at kernel/sched.c for verification of this :)
Yes, that is _massively_ broken.
Tangent:
One of the SCTP folks was cleaning up all the random jif-to-msec and
msec-to-jif macros into include/linux/time.h. Need to dig that up and
merge it.
Jeff
^ permalink raw reply [flat|nested] 54+ messages in thread
* Re: MSEC_TO_JIFFIES is messed up...
2004-05-12 18:42 ` Jeff Garzik
@ 2004-05-12 19:33 ` Ingo Molnar
2004-05-12 19:47 ` Valdis.Kletnieks
` (2 more replies)
2004-05-12 20:54 ` Bill Rugolsky Jr.
1 sibling, 3 replies; 54+ messages in thread
From: Ingo Molnar @ 2004-05-12 19:33 UTC (permalink / raw)
To: Jeff Garzik; +Cc: Greg KH, Andrew Morton, linux-kernel, Netdev
* Jeff Garzik <jgarzik@pobox.com> wrote:
> >Woah, that's new. And wrong. The code in include/asm-i386/param.h that
> >says:
> > # define JIFFIES_TO_MSEC(x) (x)
> > # define MSEC_TO_JIFFIES(x) (x)
> >
> >Is not correct. Look at kernel/sched.c for verification of this :)
>
>
> Yes, that is _massively_ broken.
why is it wrong?
Ingo
^ permalink raw reply [flat|nested] 54+ messages in thread
* Re: MSEC_TO_JIFFIES is messed up...
2004-05-12 19:33 ` Ingo Molnar
@ 2004-05-12 19:47 ` Valdis.Kletnieks
2004-05-12 19:56 ` Davide Libenzi
2004-05-12 19:49 ` Davide Libenzi
2004-05-12 20:17 ` Jeff Garzik
2 siblings, 1 reply; 54+ messages in thread
From: Valdis.Kletnieks @ 2004-05-12 19:47 UTC (permalink / raw)
To: Ingo Molnar; +Cc: Jeff Garzik, Greg KH, Andrew Morton, linux-kernel, Netdev
[-- Attachment #1: Type: text/plain, Size: 1618 bytes --]
On Wed, 12 May 2004 21:33:49 +0200, Ingo Molnar said:
>
> * Jeff Garzik <jgarzik@pobox.com> wrote:
>
> > >Woah, that's new. And wrong. The code in include/asm-i386/param.h that
> > >says:
> > > # define JIFFIES_TO_MSEC(x) (x)
> > > # define MSEC_TO_JIFFIES(x) (x)
> > >
> > >Is not correct. Look at kernel/sched.c for verification of this :)
> >
> >
> > Yes, that is _massively_ broken.
>
> why is it wrong?
If the kernel jiffie is anything other than exactly 1 msec, you're screwed...
[/usr/src/linux-2.6.6-mm1]2 find include -name '*.h' | xargs egrep '#define HZ '
include/asm-ppc64/param.h:#define HZ 100
include/asm-mips/param.h:#define HZ 100
include/asm-mips/mach-dec/param.h:#define HZ (1 << LOG_2_HZ)
include/asm-x86_64/param.h:#define HZ 100
include/asm-ppc/param.h:#define HZ 100
include/asm-m68k/param.h:#define HZ 100
include/asm-m68knommu/param.h:#define HZ 1000
include/asm-m68knommu/param.h:#define HZ 100
include/asm-m68knommu/param.h:#define HZ 100
include/asm-m68knommu/param.h:#define HZ 100
include/asm-m68knommu/param.h:#define HZ 100
include/asm-m68knommu/param.h:#define HZ 100
include/asm-m68knommu/param.h:#define HZ 100
include/asm-m68knommu/param.h:#define HZ 50
include/asm-m68knommu/param.h:#define HZ 100
include/asm-parisc/param.h:#define HZ 100
include/asm-um/param.h:#define HZ 100
include/asm-sparc/param.h:#define HZ 100
include/asm-s390/param.h:#define HZ 100
include/asm-i386/param.h:#define HZ 100
include/asm-h8300/param.h:#define HZ 100
include/asm-sparc64/param.h:#define HZ 100
include/asm-cris/param.h:#define HZ 100
include/asm-sh/param.h:#define HZ 100
[-- Attachment #2: Type: application/pgp-signature, Size: 226 bytes --]
^ permalink raw reply [flat|nested] 54+ messages in thread
* Re: MSEC_TO_JIFFIES is messed up...
2004-05-12 19:33 ` Ingo Molnar
2004-05-12 19:47 ` Valdis.Kletnieks
@ 2004-05-12 19:49 ` Davide Libenzi
2004-05-12 20:03 ` Ingo Molnar
2004-05-12 20:17 ` Jeff Garzik
2 siblings, 1 reply; 54+ messages in thread
From: Davide Libenzi @ 2004-05-12 19:49 UTC (permalink / raw)
To: Ingo Molnar
Cc: Jeff Garzik, Greg KH, Andrew Morton, Linux Kernel Mailing List, Netdev
On Wed, 12 May 2004, Ingo Molnar wrote:
>
> * Jeff Garzik <jgarzik@pobox.com> wrote:
>
> > >Woah, that's new. And wrong. The code in include/asm-i386/param.h that
> > >says:
> > > # define JIFFIES_TO_MSEC(x) (x)
> > > # define MSEC_TO_JIFFIES(x) (x)
> > >
> > >Is not correct. Look at kernel/sched.c for verification of this :)
> >
> >
> > Yes, that is _massively_ broken.
>
> 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.
- Davide
^ permalink raw reply [flat|nested] 54+ messages in thread
* Re: MSEC_TO_JIFFIES is messed up...
2004-05-12 19:47 ` Valdis.Kletnieks
@ 2004-05-12 19:56 ` Davide Libenzi
2004-05-12 20:07 ` Valdis.Kletnieks
2004-05-12 23:33 ` Peter Williams
0 siblings, 2 replies; 54+ messages in thread
From: Davide Libenzi @ 2004-05-12 19:56 UTC (permalink / raw)
To: Valdis.Kletnieks
Cc: Ingo Molnar, Jeff Garzik, Greg KH, Andrew Morton, linux-kernel, Netdev
On Wed, 12 May 2004 Valdis.Kletnieks@vt.edu wrote:
> On Wed, 12 May 2004 21:33:49 +0200, Ingo Molnar said:
> >
> > * Jeff Garzik <jgarzik@pobox.com> wrote:
> >
> > > >Woah, that's new. And wrong. The code in include/asm-i386/param.h that
> > > >says:
> > > > # define JIFFIES_TO_MSEC(x) (x)
> > > > # define MSEC_TO_JIFFIES(x) (x)
> > > >
> > > >Is not correct. Look at kernel/sched.c for verification of this :)
> > >
> > >
> > > Yes, that is _massively_ broken.
> >
> > why is it wrong?
>
> If the kernel jiffie is anything other than exactly 1 msec, you're screwed...
I believe they were talking about include/asm-i386/param.h
^^^^^^^^
- Davide
^ permalink raw reply [flat|nested] 54+ messages in thread
* Re: MSEC_TO_JIFFIES is messed up...
2004-05-12 19:49 ` Davide Libenzi
@ 2004-05-12 20:03 ` Ingo Molnar
2004-05-12 20:18 ` Valdis.Kletnieks
` (2 more replies)
0 siblings, 3 replies; 54+ messages in thread
From: Ingo Molnar @ 2004-05-12 20:03 UTC (permalink / raw)
To: Davide Libenzi
Cc: Jeff Garzik, Greg KH, Andrew Morton, Linux Kernel Mailing List, Netdev
* Davide Libenzi <davidel@xmailserver.org> 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
^ permalink raw reply [flat|nested] 54+ messages in thread
* Re: MSEC_TO_JIFFIES is messed up...
2004-05-12 19:56 ` Davide Libenzi
@ 2004-05-12 20:07 ` Valdis.Kletnieks
2004-05-12 20:28 ` Ingo Molnar
2004-05-12 23:33 ` Peter Williams
1 sibling, 1 reply; 54+ messages in thread
From: Valdis.Kletnieks @ 2004-05-12 20:07 UTC (permalink / raw)
To: Davide Libenzi
Cc: Ingo Molnar, Jeff Garzik, Greg KH, Andrew Morton, linux-kernel, Netdev
[-- Attachment #1: Type: text/plain, Size: 853 bytes --]
On Wed, 12 May 2004 12:56:04 PDT, Davide Libenzi said:
> > If the kernel jiffie is anything other than exactly 1 msec, you're screwed.
..
>
> I believe they were talking about include/asm-i386/param.h
> ^^^^^^^^
True.
The problem is that even for the i386 family, there's no inherent reason why
the value of HZ is nailed to 1000 - it was changed from the default 100 in the
2.4 kernel for reasons that apply to most, but not all, machines, and there's
almost certainly people who are changing it back to 100 for good and valid
reasons.
We're still seeing the occasional code that goes gonzo because it assumed that
the default value of HZ was 100 (there's been more than a few bugs concerning
HZ/USER_HZ) - it would be foolish to go back and re-hard-code the value and
start the cycle all over again....
[-- Attachment #2: Type: application/pgp-signature, Size: 226 bytes --]
^ permalink raw reply [flat|nested] 54+ messages in thread
* Re: MSEC_TO_JIFFIES is messed up...
2004-05-12 19:33 ` Ingo Molnar
2004-05-12 19:47 ` Valdis.Kletnieks
2004-05-12 19:49 ` Davide Libenzi
@ 2004-05-12 20:17 ` Jeff Garzik
2 siblings, 0 replies; 54+ messages in thread
From: Jeff Garzik @ 2004-05-12 20:17 UTC (permalink / raw)
To: Ingo Molnar; +Cc: Greg KH, Andrew Morton, linux-kernel, Netdev
Ingo Molnar wrote:
> * Jeff Garzik <jgarzik@pobox.com> wrote:
>
>
>>>Woah, that's new. And wrong. The code in include/asm-i386/param.h that
>>>says:
>>> # define JIFFIES_TO_MSEC(x) (x)
>>> # define MSEC_TO_JIFFIES(x) (x)
>>>
>>>Is not correct. Look at kernel/sched.c for verification of this :)
>>
>>
>>Yes, that is _massively_ broken.
>
>
> why is it wrong?
Because drivers define that exact same symbol, in an arch-generic way.
Jeff
^ permalink raw reply [flat|nested] 54+ messages in thread
* Re: MSEC_TO_JIFFIES is messed up...
2004-05-12 20:03 ` Ingo Molnar
@ 2004-05-12 20:18 ` Valdis.Kletnieks
2004-05-12 20:20 ` Andrew Morton
2004-05-12 21:01 ` Davide Libenzi
2 siblings, 0 replies; 54+ messages in thread
From: Valdis.Kletnieks @ 2004-05-12 20:18 UTC (permalink / raw)
To: Ingo Molnar
Cc: Davide Libenzi, Jeff Garzik, Greg KH, Andrew Morton,
Linux Kernel Mailing List, Netdev
[-- Attachment #1: Type: text/plain, Size: 496 bytes --]
On Wed, 12 May 2004 22:03:05 +0200, Ingo Molnar said:
> 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:
That should read we "know" that HZ is 1000....
How about this instead?
#if HZ == 1000
#define JIFFIES_TO_MSEC(x) (x)
#else
#define JIFFIES_TO_MSEC(x) ((x) * 1000 / HZ)
#endif
That will DTRT if somebody changes HZ for their build, and still allow
us to avoud the *1000/1000 conversion for most builds.....
[-- Attachment #2: Type: application/pgp-signature, Size: 226 bytes --]
^ permalink raw reply [flat|nested] 54+ messages in thread
* Re: MSEC_TO_JIFFIES is messed up...
2004-05-12 20:03 ` Ingo Molnar
2004-05-12 20:18 ` Valdis.Kletnieks
@ 2004-05-12 20:20 ` Andrew Morton
2004-05-12 20:24 ` Jeff Garzik
` (3 more replies)
2004-05-12 21:01 ` Davide Libenzi
2 siblings, 4 replies; 54+ messages in thread
From: Andrew Morton @ 2004-05-12 20:20 UTC (permalink / raw)
To: Ingo Molnar; +Cc: davidel, jgarzik, greg, linux-kernel, netdev
Ingo Molnar <mingo@elte.hu> wrote:
>
>
> * Davide Libenzi <davidel@xmailserver.org> 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
>
Yes, that's a correct optimisation. This is simply a namespace clash.
How about we do:
#if HZ=1000
#define MSEC_TO_JIFFIES(msec) (msec)
#define JIFFIES_TO_MESC(jiffies) (jiffies)
#elif HZ=100
#define MSEC_TO_JIFFIES(msec) (msec * 10)
#define JIFFIES_TO_MESC(jiffies) (jiffies / 10)
#else
#define MSEC_TO_JIFFIES(msec) ((HZ * (msec) + 999) / 1000)
#define JIFFIES_TO_MSEC(jiffies) ...
#endif
in some kernel-wide header then kill off all the private implementations?
^ permalink raw reply [flat|nested] 54+ messages in thread
* Re: MSEC_TO_JIFFIES is messed up...
2004-05-12 20:20 ` Andrew Morton
@ 2004-05-12 20:24 ` Jeff Garzik
2004-05-12 20:35 ` Andrew Morton
2004-05-12 20:32 ` Greg KH
` (2 subsequent siblings)
3 siblings, 1 reply; 54+ messages in thread
From: Jeff Garzik @ 2004-05-12 20:24 UTC (permalink / raw)
To: Andrew Morton; +Cc: Ingo Molnar, davidel, greg, linux-kernel, netdev
Andrew Morton wrote:
> Yes, that's a correct optimisation. This is simply a namespace clash.
Agreed.
> How about we do:
>
> #if HZ=1000
> #define MSEC_TO_JIFFIES(msec) (msec)
> #define JIFFIES_TO_MESC(jiffies) (jiffies)
> #elif HZ=100
> #define MSEC_TO_JIFFIES(msec) (msec * 10)
> #define JIFFIES_TO_MESC(jiffies) (jiffies / 10)
> #else
> #define MSEC_TO_JIFFIES(msec) ((HZ * (msec) + 999) / 1000)
> #define JIFFIES_TO_MSEC(jiffies) ...
> #endif
>
> in some kernel-wide header then kill off all the private implementations?
include/linux/time.h. One of the SCTP people already did this, but I
suppose it's straightforward to reproduce.
Jeff
^ permalink raw reply [flat|nested] 54+ messages in thread
* Re: MSEC_TO_JIFFIES is messed up...
2004-05-12 20:07 ` Valdis.Kletnieks
@ 2004-05-12 20:28 ` Ingo Molnar
2004-05-12 20:35 ` Ingo Molnar
0 siblings, 1 reply; 54+ messages in thread
From: Ingo Molnar @ 2004-05-12 20:28 UTC (permalink / raw)
To: Valdis.Kletnieks
Cc: Davide Libenzi, Jeff Garzik, Greg KH, Andrew Morton,
linux-kernel, Netdev
[-- Attachment #1: Type: text/plain, Size: 473 bytes --]
* Valdis.Kletnieks@vt.edu <Valdis.Kletnieks@vt.edu> wrote:
> The problem is that even for the i386 family, there's no inherent
> reason why the value of HZ is nailed to 1000 [...]
The code is 100% correct, but not 100% clean, and definitely not
documented. The reason for the change was to avoid unnecessary integer
multiplications and divisions in sched.c.
the attached patch (against BK-curr) cleans this up and makes the
defines generic and arch-independent.
Ingo
[-- Attachment #2: hz-cleanup-2.6.6-A0 --]
[-- Type: text/plain, Size: 1318 bytes --]
--- linux/include/linux/time.h.orig
+++ linux/include/linux/time.h
@@ -177,6 +177,15 @@ struct timezone {
(SH_DIV((MAX_JIFFY_OFFSET >> SEC_JIFFIE_SC) * TICK_NSEC, NSEC_PER_SEC, 1) - 1)
#endif
+
+#if HZ == 1000
+# define JIFFIES_TO_MSEC(x) (x)
+# define MSEC_TO_JIFFIES(x) (x)
+#else
+# define JIFFIES_TO_MSEC(x) ((x) * 1000 / HZ)
+# define MSEC_TO_JIFFIES(x) ((x) * HZ / 1000)
+#endif
+
/*
* The TICK_NSEC - 1 rounds up the value to the next resolution. Note
* that a remainder subtract here would not do the right thing as the
--- linux/include/asm-i386/param.h.orig
+++ linux/include/asm-i386/param.h
@@ -5,8 +5,6 @@
# define HZ 1000 /* Internal kernel timer frequency */
# define USER_HZ 100 /* .. some user interfaces are in "ticks" */
# define CLOCKS_PER_SEC (USER_HZ) /* like times() */
-# define JIFFIES_TO_MSEC(x) (x)
-# define MSEC_TO_JIFFIES(x) (x)
#endif
#ifndef HZ
--- linux/kernel/sched.c.orig
+++ linux/kernel/sched.c
@@ -75,13 +75,6 @@
#define NS_TO_JIFFIES(TIME) ((TIME) / (1000000000 / HZ))
#define JIFFIES_TO_NS(TIME) ((TIME) * (1000000000 / HZ))
-#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
-
/*
* These are the 'tuning knobs' of the scheduler:
*
^ permalink raw reply [flat|nested] 54+ messages in thread
* Re: MSEC_TO_JIFFIES is messed up...
2004-05-12 20:20 ` Andrew Morton
2004-05-12 20:24 ` Jeff Garzik
@ 2004-05-12 20:32 ` Greg KH
2004-05-12 20:38 ` William Lee Irwin III
2004-05-12 20:55 ` Ingo Molnar
3 siblings, 0 replies; 54+ messages in thread
From: Greg KH @ 2004-05-12 20:32 UTC (permalink / raw)
To: Andrew Morton; +Cc: Ingo Molnar, davidel, jgarzik, linux-kernel, netdev
On Wed, May 12, 2004 at 01:20:50PM -0700, Andrew Morton wrote:
> How about we do:
>
> #if HZ=1000
> #define MSEC_TO_JIFFIES(msec) (msec)
> #define JIFFIES_TO_MESC(jiffies) (jiffies)
> #elif HZ=100
> #define MSEC_TO_JIFFIES(msec) (msec * 10)
> #define JIFFIES_TO_MESC(jiffies) (jiffies / 10)
> #else
> #define MSEC_TO_JIFFIES(msec) ((HZ * (msec) + 999) / 1000)
> #define JIFFIES_TO_MSEC(jiffies) ...
> #endif
>
> in some kernel-wide header then kill off all the private implementations?
Looks good to me.
thanks,
greg k-h
^ permalink raw reply [flat|nested] 54+ messages in thread
* Re: MSEC_TO_JIFFIES is messed up...
2004-05-12 20:28 ` Ingo Molnar
@ 2004-05-12 20:35 ` Ingo Molnar
2004-05-12 20:50 ` Ingo Molnar
0 siblings, 1 reply; 54+ messages in thread
From: Ingo Molnar @ 2004-05-12 20:35 UTC (permalink / raw)
To: Valdis.Kletnieks
Cc: Davide Libenzi, Jeff Garzik, Greg KH, Andrew Morton,
linux-kernel, Netdev
[-- Attachment #1: Type: text/plain, Size: 333 bytes --]
* Ingo Molnar <mingo@elte.hu> wrote:
> the attached patch (against BK-curr) cleans this up and makes the
> defines generic and arch-independent.
new patch attached - this adopts the overflow-safe variant from sctp.h,
removes it from sctp.h and moves it into a generic include file and also
does the HZ=1000 simplification.
Ingo
[-- Attachment #2: hz-cleanup-2.6.6-A1 --]
[-- Type: text/plain, Size: 1762 bytes --]
--- linux/include/linux/time.h.orig
+++ linux/include/linux/time.h
@@ -177,6 +177,17 @@ struct timezone {
(SH_DIV((MAX_JIFFY_OFFSET >> SEC_JIFFIE_SC) * TICK_NSEC, NSEC_PER_SEC, 1) - 1)
#endif
+
+#if HZ == 1000
+# define JIFFIES_TO_MSEC(x) (x)
+# define MSEC_TO_JIFFIES(x) (x)
+#else
+#define MSECS_TO_JIFFIES(msec) \
+ (((msec / 1000) * HZ) + ((msec % 1000) * HZ) / 1000)
+#define JIFFIES_TO_MSECS(jiff) \
+ (((jiff / HZ) * 1000) + ((jiff % HZ) * 1000) / HZ)
+#endif
+
/*
* The TICK_NSEC - 1 rounds up the value to the next resolution. Note
* that a remainder subtract here would not do the right thing as the
--- linux/include/net/sctp/sctp.h.orig
+++ linux/include/net/sctp/sctp.h
@@ -116,11 +116,6 @@
#define SCTP_STATIC static
#endif
-#define MSECS_TO_JIFFIES(msec) \
- (((msec / 1000) * HZ) + ((msec % 1000) * HZ) / 1000)
-#define JIFFIES_TO_MSECS(jiff) \
- (((jiff / HZ) * 1000) + ((jiff % HZ) * 1000) / HZ)
-
/*
* Function declarations.
*/
--- linux/include/asm-i386/param.h.orig
+++ linux/include/asm-i386/param.h
@@ -5,8 +5,6 @@
# define HZ 1000 /* Internal kernel timer frequency */
# define USER_HZ 100 /* .. some user interfaces are in "ticks" */
# define CLOCKS_PER_SEC (USER_HZ) /* like times() */
-# define JIFFIES_TO_MSEC(x) (x)
-# define MSEC_TO_JIFFIES(x) (x)
#endif
#ifndef HZ
--- linux/kernel/sched.c.orig
+++ linux/kernel/sched.c
@@ -75,13 +75,6 @@
#define NS_TO_JIFFIES(TIME) ((TIME) / (1000000000 / HZ))
#define JIFFIES_TO_NS(TIME) ((TIME) * (1000000000 / HZ))
-#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
-
/*
* These are the 'tuning knobs' of the scheduler:
*
^ permalink raw reply [flat|nested] 54+ messages in thread
* Re: MSEC_TO_JIFFIES is messed up...
2004-05-12 20:24 ` Jeff Garzik
@ 2004-05-12 20:35 ` Andrew Morton
2004-05-12 20:44 ` Jeff Garzik
2004-05-12 21:03 ` Sridhar Samudrala
0 siblings, 2 replies; 54+ messages in thread
From: Andrew Morton @ 2004-05-12 20:35 UTC (permalink / raw)
To: Jeff Garzik; +Cc: mingo, davidel, greg, linux-kernel, netdev
Jeff Garzik <jgarzik@pobox.com> wrote:
>
> > How about we do:
> >
> > #if HZ=1000
> > #define MSEC_TO_JIFFIES(msec) (msec)
> > #define JIFFIES_TO_MESC(jiffies) (jiffies)
> > #elif HZ=100
> > #define MSEC_TO_JIFFIES(msec) (msec * 10)
> > #define JIFFIES_TO_MESC(jiffies) (jiffies / 10)
> > #else
> > #define MSEC_TO_JIFFIES(msec) ((HZ * (msec) + 999) / 1000)
> > #define JIFFIES_TO_MSEC(jiffies) ...
> > #endif
> >
> > in some kernel-wide header then kill off all the private implementations?
>
>
> include/linux/time.h. One of the SCTP people already did this, but I
> suppose it's straightforward to reproduce.
OK, I'll do it.
^ permalink raw reply [flat|nested] 54+ messages in thread
* Re: MSEC_TO_JIFFIES is messed up...
2004-05-12 20:20 ` Andrew Morton
2004-05-12 20:24 ` Jeff Garzik
2004-05-12 20:32 ` Greg KH
@ 2004-05-12 20:38 ` William Lee Irwin III
2004-05-12 20:47 ` Andrew Morton
2004-05-12 20:55 ` Ingo Molnar
3 siblings, 1 reply; 54+ messages in thread
From: William Lee Irwin III @ 2004-05-12 20:38 UTC (permalink / raw)
To: Andrew Morton; +Cc: Ingo Molnar, davidel, jgarzik, greg, linux-kernel, netdev
On Wed, May 12, 2004 at 01:20:50PM -0700, Andrew Morton wrote:
> How about we do:
> #if HZ=1000
> #define MSEC_TO_JIFFIES(msec) (msec)
> #define JIFFIES_TO_MESC(jiffies) (jiffies)
> #elif HZ=100
> #define MSEC_TO_JIFFIES(msec) (msec * 10)
> #define JIFFIES_TO_MESC(jiffies) (jiffies / 10)
> #else
> #define MSEC_TO_JIFFIES(msec) ((HZ * (msec) + 999) / 1000)
> #define JIFFIES_TO_MSEC(jiffies) ...
> #endif
> in some kernel-wide header then kill off all the private implementations?
How about this?
#if HZ <= 1000 && !(1000 % HZ)
#define MSEC_TO_JIFFIES(m) ((1000/HZ)*(m))
#define JIFFIES_TO_MSEC(j) ((j)/(1000/HZ))
#elif HZ > 1000 && !(HZ % 1000)
#define MSEC_TO_JIFFIES(m) ((m)/(HZ/1000))
#define JIFFIES_TO_MSEC(j) ((HZ/1000)*(j))
#else
#define MSEC_TO_JIFFIES(m) ((HZ*(m) + 999)/1000)
#define JIFFIES_TO_MSEC(j) ((1000*(j) + HZ - 1)/HZ)
#endif
-- wli
^ permalink raw reply [flat|nested] 54+ messages in thread
* Re: MSEC_TO_JIFFIES is messed up...
2004-05-12 20:35 ` Andrew Morton
@ 2004-05-12 20:44 ` Jeff Garzik
2004-05-12 21:03 ` Sridhar Samudrala
1 sibling, 0 replies; 54+ messages in thread
From: Jeff Garzik @ 2004-05-12 20:44 UTC (permalink / raw)
To: Andrew Morton; +Cc: mingo, davidel, greg, linux-kernel, netdev
Andrew Morton wrote:
> Jeff Garzik <jgarzik@pobox.com> wrote:
>
>>>How about we do:
>>
>> >
>> > #if HZ=1000
>> > #define MSEC_TO_JIFFIES(msec) (msec)
>> > #define JIFFIES_TO_MESC(jiffies) (jiffies)
>> > #elif HZ=100
>> > #define MSEC_TO_JIFFIES(msec) (msec * 10)
>> > #define JIFFIES_TO_MESC(jiffies) (jiffies / 10)
>> > #else
>> > #define MSEC_TO_JIFFIES(msec) ((HZ * (msec) + 999) / 1000)
>> > #define JIFFIES_TO_MSEC(jiffies) ...
>> > #endif
>> >
>> > in some kernel-wide header then kill off all the private implementations?
>>
>>
>> include/linux/time.h. One of the SCTP people already did this, but I
>> suppose it's straightforward to reproduce.
>
>
> OK, I'll do it.
Thanks. 'grep -i msec.*jif' and 'grep -i jif.*msec' should catch most,
there are occurences in both upper and lower case.
Note that a few oddball drivers include an addition to the kernel-wide
'jiffies' variable, rather than just doing a calculation scaling against HZ.
Jeff
^ permalink raw reply [flat|nested] 54+ messages in thread
* Re: MSEC_TO_JIFFIES is messed up...
2004-05-12 20:38 ` William Lee Irwin III
@ 2004-05-12 20:47 ` Andrew Morton
2004-05-12 20:58 ` Jeff Garzik
2004-05-12 20:59 ` William Lee Irwin III
0 siblings, 2 replies; 54+ messages in thread
From: Andrew Morton @ 2004-05-12 20:47 UTC (permalink / raw)
To: William Lee Irwin III; +Cc: mingo, davidel, jgarzik, greg, linux-kernel, netdev
William Lee Irwin III <wli@holomorphy.com> wrote:
>
> How about this?
>
> #if HZ <= 1000 && !(1000 % HZ)
> #define MSEC_TO_JIFFIES(m) ((1000/HZ)*(m))
> #define JIFFIES_TO_MSEC(j) ((j)/(1000/HZ))
> #elif HZ > 1000 && !(HZ % 1000)
> #define MSEC_TO_JIFFIES(m) ((m)/(HZ/1000))
> #define JIFFIES_TO_MSEC(j) ((HZ/1000)*(j))
> #else
> #define MSEC_TO_JIFFIES(m) ((HZ*(m) + 999)/1000)
> #define JIFFIES_TO_MSEC(j) ((1000*(j) + HZ - 1)/HZ)
> #endif
You promise it's correct and generates good code?
---
25-akpm/drivers/net/irda/act200l-sir.c | 2 +-
25-akpm/drivers/net/irda/act200l.c | 10 +++++-----
25-akpm/drivers/net/irda/actisys.c | 2 +-
25-akpm/drivers/net/irda/girbil.c | 10 +++++-----
25-akpm/drivers/net/irda/irda-usb.c | 6 +++---
25-akpm/drivers/net/irda/irport.c | 4 ++--
25-akpm/drivers/net/irda/irtty-sir.c | 4 ++--
25-akpm/drivers/net/irda/ma600-sir.c | 8 ++++----
25-akpm/drivers/net/irda/ma600.c | 16 ++++++++--------
25-akpm/drivers/net/irda/mcp2120.c | 8 ++++----
25-akpm/drivers/net/irda/sir_dev.c | 2 +-
25-akpm/drivers/net/irda/sir_kthread.c | 2 +-
25-akpm/drivers/net/irda/stir4200.c | 6 +++---
25-akpm/drivers/net/irda/tekram-sir.c | 2 +-
25-akpm/drivers/net/irda/tekram.c | 12 ++++++------
25-akpm/include/asm-i386/param.h | 2 --
25-akpm/include/linux/time.h | 10 ++++++++++
25-akpm/include/net/irda/irda.h | 2 --
25-akpm/include/net/sctp/sctp.h | 5 -----
25-akpm/kernel/sched.c | 7 -------
25-akpm/net/irda/ircomm/ircomm_tty.c | 2 +-
25-akpm/net/irda/irlap_event.c | 6 +++---
25-akpm/net/sctp/associola.c | 10 +++++-----
25-akpm/net/sctp/chunk.c | 2 +-
25-akpm/net/sctp/endpointola.c | 4 ++--
25-akpm/net/sctp/socket.c | 24 ++++++++++++------------
26 files changed, 81 insertions(+), 87 deletions(-)
diff -puN drivers/net/irda/act200l.c~jiffies-to-msec-borkage-fix drivers/net/irda/act200l.c
--- 25/drivers/net/irda/act200l.c~jiffies-to-msec-borkage-fix 2004-05-12 13:46:41.436171144 -0700
+++ 25-akpm/drivers/net/irda/act200l.c 2004-05-12 13:46:41.482164152 -0700
@@ -148,7 +148,7 @@ static int act200l_change_speed(struct i
irda_task_next_state(task, IRDA_TASK_CHILD_WAIT);
/* Give reset 1 sec to finish */
- ret = MSECS_TO_JIFFIES(1000);
+ ret = MSEC_TO_JIFFIES(1000);
}
break;
case IRDA_TASK_CHILD_WAIT:
@@ -187,7 +187,7 @@ static int act200l_change_speed(struct i
/* Write control bytes */
self->write(self->dev, control, 3);
irda_task_next_state(task, IRDA_TASK_WAIT);
- ret = MSECS_TO_JIFFIES(5);
+ ret = MSEC_TO_JIFFIES(5);
break;
case IRDA_TASK_WAIT:
/* Go back to normal mode */
@@ -237,14 +237,14 @@ static int act200l_reset(struct irda_tas
self->set_dtr_rts(self->dev, TRUE, TRUE);
irda_task_next_state(task, IRDA_TASK_WAIT1);
- ret = MSECS_TO_JIFFIES(50);
+ ret = MSEC_TO_JIFFIES(50);
break;
case IRDA_TASK_WAIT1:
/* Reset the dongle : set RTS low for 25 ms */
self->set_dtr_rts(self->dev, TRUE, FALSE);
irda_task_next_state(task, IRDA_TASK_WAIT2);
- ret = MSECS_TO_JIFFIES(50);
+ ret = MSEC_TO_JIFFIES(50);
break;
case IRDA_TASK_WAIT2:
/* Clear DTR and set RTS to enter command mode */
@@ -253,7 +253,7 @@ static int act200l_reset(struct irda_tas
/* Write control bytes */
self->write(self->dev, control, 9);
irda_task_next_state(task, IRDA_TASK_WAIT3);
- ret = MSECS_TO_JIFFIES(15);
+ ret = MSEC_TO_JIFFIES(15);
break;
case IRDA_TASK_WAIT3:
/* Go back to normal mode */
diff -puN drivers/net/irda/act200l-sir.c~jiffies-to-msec-borkage-fix drivers/net/irda/act200l-sir.c
--- 25/drivers/net/irda/act200l-sir.c~jiffies-to-msec-borkage-fix 2004-05-12 13:46:41.437170992 -0700
+++ 25-akpm/drivers/net/irda/act200l-sir.c 2004-05-12 13:46:41.486163544 -0700
@@ -178,7 +178,7 @@ static int act200l_change_speed(struct s
/* Write control bytes */
sirdev_raw_write(dev, control, 3);
set_current_state(TASK_UNINTERRUPTIBLE);
- schedule_timeout(MSECS_TO_JIFFIES(5));
+ schedule_timeout(MSEC_TO_JIFFIES(5));
/* Go back to normal mode */
sirdev_set_dtr_rts(dev, TRUE, TRUE);
diff -puN drivers/net/irda/actisys.c~jiffies-to-msec-borkage-fix drivers/net/irda/actisys.c
--- 25/drivers/net/irda/actisys.c~jiffies-to-msec-borkage-fix 2004-05-12 13:46:41.439170688 -0700
+++ 25-akpm/drivers/net/irda/actisys.c 2004-05-12 13:46:41.486163544 -0700
@@ -238,7 +238,7 @@ static int actisys_reset(struct irda_tas
self->set_dtr_rts(self->dev, TRUE, TRUE);
/* Sleep 50 ms to make sure capacitor is charged */
- ret = MSECS_TO_JIFFIES(50);
+ ret = MSEC_TO_JIFFIES(50);
irda_task_next_state(task, IRDA_TASK_WAIT);
break;
case IRDA_TASK_WAIT:
diff -puN drivers/net/irda/girbil.c~jiffies-to-msec-borkage-fix drivers/net/irda/girbil.c
--- 25/drivers/net/irda/girbil.c~jiffies-to-msec-borkage-fix 2004-05-12 13:46:41.440170536 -0700
+++ 25-akpm/drivers/net/irda/girbil.c 2004-05-12 13:46:41.478164760 -0700
@@ -119,7 +119,7 @@ static int girbil_change_speed(struct ir
irda_task_next_state(task, IRDA_TASK_CHILD_WAIT);
/* Give reset 1 sec to finish */
- ret = MSECS_TO_JIFFIES(1000);
+ ret = MSEC_TO_JIFFIES(1000);
}
break;
case IRDA_TASK_CHILD_WAIT:
@@ -153,7 +153,7 @@ static int girbil_change_speed(struct ir
/* Write control bytes */
self->write(self->dev, control, 2);
irda_task_next_state(task, IRDA_TASK_WAIT);
- ret = MSECS_TO_JIFFIES(100);
+ ret = MSEC_TO_JIFFIES(100);
break;
case IRDA_TASK_WAIT:
/* Go back to normal mode */
@@ -194,19 +194,19 @@ static int girbil_reset(struct irda_task
self->set_dtr_rts(self->dev, TRUE, FALSE);
irda_task_next_state(task, IRDA_TASK_WAIT1);
/* Sleep at least 5 ms */
- ret = MSECS_TO_JIFFIES(20);
+ ret = MSEC_TO_JIFFIES(20);
break;
case IRDA_TASK_WAIT1:
/* Set DTR and clear RTS to enter command mode */
self->set_dtr_rts(self->dev, FALSE, TRUE);
irda_task_next_state(task, IRDA_TASK_WAIT2);
- ret = MSECS_TO_JIFFIES(20);
+ ret = MSEC_TO_JIFFIES(20);
break;
case IRDA_TASK_WAIT2:
/* Write control byte */
self->write(self->dev, &control, 1);
irda_task_next_state(task, IRDA_TASK_WAIT3);
- ret = MSECS_TO_JIFFIES(20);
+ ret = MSEC_TO_JIFFIES(20);
break;
case IRDA_TASK_WAIT3:
/* Go back to normal mode */
diff -puN drivers/net/irda/irda-usb.c~jiffies-to-msec-borkage-fix drivers/net/irda/irda-usb.c
--- 25/drivers/net/irda/irda-usb.c~jiffies-to-msec-borkage-fix 2004-05-12 13:46:41.442170232 -0700
+++ 25-akpm/drivers/net/irda/irda-usb.c 2004-05-12 13:46:41.481164304 -0700
@@ -268,7 +268,7 @@ static void irda_usb_change_speed_xbofs(
speed_bulk_callback, self);
urb->transfer_buffer_length = USB_IRDA_HEADER;
urb->transfer_flags = URB_ASYNC_UNLINK;
- urb->timeout = MSECS_TO_JIFFIES(100);
+ urb->timeout = MSEC_TO_JIFFIES(100);
/* Irq disabled -> GFP_ATOMIC */
if ((ret = usb_submit_urb(urb, GFP_ATOMIC))) {
@@ -412,7 +412,7 @@ static int irda_usb_hard_xmit(struct sk_
* This is how the dongle will detect the end of packet - Jean II */
urb->transfer_flags |= URB_ZERO_PACKET;
/* Timeout need to be shorter than NET watchdog timer */
- urb->timeout = MSECS_TO_JIFFIES(200);
+ urb->timeout = MSEC_TO_JIFFIES(200);
/* Generate min turn time. FIXME: can we do better than this? */
/* Trying to a turnaround time at this level is trying to measure
@@ -1311,7 +1311,7 @@ static inline struct irda_class_desc *ir
IU_REQ_GET_CLASS_DESC,
USB_DIR_IN | USB_TYPE_CLASS | USB_RECIP_INTERFACE,
0, intf->altsetting->desc.bInterfaceNumber, desc,
- sizeof(*desc), MSECS_TO_JIFFIES(500));
+ sizeof(*desc), MSEC_TO_JIFFIES(500));
IRDA_DEBUG(1, "%s(), ret=%d\n", __FUNCTION__, ret);
if (ret < sizeof(*desc)) {
diff -puN drivers/net/irda/irport.c~jiffies-to-msec-borkage-fix drivers/net/irda/irport.c
--- 25/drivers/net/irda/irport.c~jiffies-to-msec-borkage-fix 2004-05-12 13:46:41.443170080 -0700
+++ 25-akpm/drivers/net/irda/irport.c 2004-05-12 13:46:41.484163848 -0700
@@ -452,7 +452,7 @@ int __irport_change_speed(struct irda_ta
task->state = IRDA_TASK_WAIT;
/* Try again later */
- ret = MSECS_TO_JIFFIES(20);
+ ret = MSEC_TO_JIFFIES(20);
break;
}
@@ -474,7 +474,7 @@ int __irport_change_speed(struct irda_ta
irda_task_next_state(task, IRDA_TASK_CHILD_WAIT);
/* Give dongle 1 sec to finish */
- ret = MSECS_TO_JIFFIES(1000);
+ ret = MSEC_TO_JIFFIES(1000);
} else
/* Child finished immediately */
irda_task_next_state(task, IRDA_TASK_CHILD_DONE);
diff -puN drivers/net/irda/irtty-sir.c~jiffies-to-msec-borkage-fix drivers/net/irda/irtty-sir.c
--- 25/drivers/net/irda/irtty-sir.c~jiffies-to-msec-borkage-fix 2004-05-12 13:46:41.444169928 -0700
+++ 25-akpm/drivers/net/irda/irtty-sir.c 2004-05-12 13:46:41.478164760 -0700
@@ -93,12 +93,12 @@ static void irtty_wait_until_sent(struct
tty = priv->tty;
if (tty->driver->wait_until_sent) {
lock_kernel();
- tty->driver->wait_until_sent(tty, MSECS_TO_JIFFIES(100));
+ tty->driver->wait_until_sent(tty, MSEC_TO_JIFFIES(100));
unlock_kernel();
}
else {
set_task_state(current, TASK_UNINTERRUPTIBLE);
- schedule_timeout(MSECS_TO_JIFFIES(USBSERIAL_TX_DONE_DELAY));
+ schedule_timeout(MSEC_TO_JIFFIES(USBSERIAL_TX_DONE_DELAY));
}
}
diff -puN drivers/net/irda/ma600.c~jiffies-to-msec-borkage-fix drivers/net/irda/ma600.c
--- 25/drivers/net/irda/ma600.c~jiffies-to-msec-borkage-fix 2004-05-12 13:46:41.446169624 -0700
+++ 25-akpm/drivers/net/irda/ma600.c 2004-05-12 13:46:41.480164456 -0700
@@ -184,7 +184,7 @@ static int ma600_change_speed(struct ird
if (self->speed_task && self->speed_task != task) {
IRDA_DEBUG(0, "%s(), busy!\n", __FUNCTION__);
- return MSECS_TO_JIFFIES(10);
+ return MSEC_TO_JIFFIES(10);
} else {
self->speed_task = task;
}
@@ -202,7 +202,7 @@ static int ma600_change_speed(struct ird
irda_task_next_state(task, IRDA_TASK_CHILD_WAIT);
/* give 1 second to finish */
- ret = MSECS_TO_JIFFIES(1000);
+ ret = MSEC_TO_JIFFIES(1000);
} else {
irda_task_next_state(task, IRDA_TASK_CHILD_DONE);
}
@@ -217,7 +217,7 @@ static int ma600_change_speed(struct ird
/* Set DTR, Clear RTS */
self->set_dtr_rts(self->dev, TRUE, FALSE);
- ret = MSECS_TO_JIFFIES(1); /* Sleep 1 ms */
+ ret = MSEC_TO_JIFFIES(1); /* Sleep 1 ms */
irda_task_next_state(task, IRDA_TASK_WAIT);
break;
@@ -231,7 +231,7 @@ static int ma600_change_speed(struct ird
irda_task_next_state(task, IRDA_TASK_WAIT1);
/* Wait at least 10 ms */
- ret = MSECS_TO_JIFFIES(15);
+ ret = MSEC_TO_JIFFIES(15);
break;
case IRDA_TASK_WAIT1:
@@ -258,7 +258,7 @@ static int ma600_change_speed(struct ird
irda_task_next_state(task, IRDA_TASK_WAIT2);
/* Wait at least 10 ms */
- ret = MSECS_TO_JIFFIES(10);
+ ret = MSEC_TO_JIFFIES(10);
break;
case IRDA_TASK_WAIT2:
@@ -298,7 +298,7 @@ int ma600_reset(struct irda_task *task)
if (self->reset_task && self->reset_task != task) {
IRDA_DEBUG(0, "%s(), busy!\n", __FUNCTION__);
- return MSECS_TO_JIFFIES(10);
+ return MSEC_TO_JIFFIES(10);
} else
self->reset_task = task;
@@ -307,13 +307,13 @@ int ma600_reset(struct irda_task *task)
/* Clear DTR and Set RTS */
self->set_dtr_rts(self->dev, FALSE, TRUE);
irda_task_next_state(task, IRDA_TASK_WAIT1);
- ret = MSECS_TO_JIFFIES(10); /* Sleep 10 ms */
+ ret = MSEC_TO_JIFFIES(10); /* Sleep 10 ms */
break;
case IRDA_TASK_WAIT1:
/* Set DTR and RTS */
self->set_dtr_rts(self->dev, TRUE, TRUE);
irda_task_next_state(task, IRDA_TASK_WAIT2);
- ret = MSECS_TO_JIFFIES(10); /* Sleep 10 ms */
+ ret = MSEC_TO_JIFFIES(10); /* Sleep 10 ms */
break;
case IRDA_TASK_WAIT2:
irda_task_next_state(task, IRDA_TASK_DONE);
diff -puN drivers/net/irda/ma600-sir.c~jiffies-to-msec-borkage-fix drivers/net/irda/ma600-sir.c
--- 25/drivers/net/irda/ma600-sir.c~jiffies-to-msec-borkage-fix 2004-05-12 13:46:41.447169472 -0700
+++ 25-akpm/drivers/net/irda/ma600-sir.c 2004-05-12 13:46:41.487163392 -0700
@@ -192,7 +192,7 @@ static int ma600_change_speed(struct sir
/* Wait at least 10ms: fake wait_until_sent - 10 bits at 9600 baud*/
set_current_state(TASK_UNINTERRUPTIBLE);
- schedule_timeout(MSECS_TO_JIFFIES(15)); /* old ma600 uses 15ms */
+ schedule_timeout(MSEC_TO_JIFFIES(15)); /* old ma600 uses 15ms */
#if 1
/* read-back of the control byte. ma600 is the first dongle driver
@@ -216,7 +216,7 @@ static int ma600_change_speed(struct sir
/* Wait at least 10ms */
set_current_state(TASK_UNINTERRUPTIBLE);
- schedule_timeout(MSECS_TO_JIFFIES(10));
+ schedule_timeout(MSEC_TO_JIFFIES(10));
/* dongle is now switched to the new speed */
dev->speed = speed;
@@ -246,12 +246,12 @@ int ma600_reset(struct sir_dev *dev)
/* Reset the dongle : set DTR low for 10 ms */
sirdev_set_dtr_rts(dev, FALSE, TRUE);
set_current_state(TASK_UNINTERRUPTIBLE);
- schedule_timeout(MSECS_TO_JIFFIES(10));
+ schedule_timeout(MSEC_TO_JIFFIES(10));
/* Go back to normal mode */
sirdev_set_dtr_rts(dev, TRUE, TRUE);
set_current_state(TASK_UNINTERRUPTIBLE);
- schedule_timeout(MSECS_TO_JIFFIES(10));
+ schedule_timeout(MSEC_TO_JIFFIES(10));
dev->speed = 9600; /* That's the dongle-default */
diff -puN drivers/net/irda/mcp2120.c~jiffies-to-msec-borkage-fix drivers/net/irda/mcp2120.c
--- 25/drivers/net/irda/mcp2120.c~jiffies-to-msec-borkage-fix 2004-05-12 13:46:41.448169320 -0700
+++ 25-akpm/drivers/net/irda/mcp2120.c 2004-05-12 13:46:41.485163696 -0700
@@ -99,7 +99,7 @@ static int mcp2120_change_speed(struct i
irda_task_next_state(task, IRDA_TASK_CHILD_WAIT);
/* Give reset 1 sec to finish */
- ret = MSECS_TO_JIFFIES(1000);
+ ret = MSEC_TO_JIFFIES(1000);
}
break;
case IRDA_TASK_CHILD_WAIT:
@@ -140,7 +140,7 @@ static int mcp2120_change_speed(struct i
self->write(self->dev, control, 2);
irda_task_next_state(task, IRDA_TASK_WAIT);
- ret = MSECS_TO_JIFFIES(100);
+ ret = MSEC_TO_JIFFIES(100);
//printk("mcp2120_change_speed irda_child_done\n");
break;
case IRDA_TASK_WAIT:
@@ -189,14 +189,14 @@ static int mcp2120_reset(struct irda_tas
/* Reset dongle by setting RTS*/
self->set_dtr_rts(self->dev, TRUE, TRUE);
irda_task_next_state(task, IRDA_TASK_WAIT1);
- ret = MSECS_TO_JIFFIES(50);
+ ret = MSEC_TO_JIFFIES(50);
break;
case IRDA_TASK_WAIT1:
//printk("mcp2120_reset irda_task_wait1\n");
/* clear RTS and wait for at least 30 ms. */
self->set_dtr_rts(self->dev, FALSE, FALSE);
irda_task_next_state(task, IRDA_TASK_WAIT2);
- ret = MSECS_TO_JIFFIES(50);
+ ret = MSEC_TO_JIFFIES(50);
break;
case IRDA_TASK_WAIT2:
//printk("mcp2120_reset irda_task_wait2\n");
diff -puN drivers/net/irda/sir_dev.c~jiffies-to-msec-borkage-fix drivers/net/irda/sir_dev.c
--- 25/drivers/net/irda/sir_dev.c~jiffies-to-msec-borkage-fix 2004-05-12 13:46:41.450169016 -0700
+++ 25-akpm/drivers/net/irda/sir_dev.c 2004-05-12 13:46:41.483164000 -0700
@@ -74,7 +74,7 @@ int sirdev_raw_write(struct sir_dev *dev
while (dev->tx_buff.len > 0) { /* wait until tx idle */
spin_unlock_irqrestore(&dev->tx_lock, flags);
set_current_state(TASK_UNINTERRUPTIBLE);
- schedule_timeout(MSECS_TO_JIFFIES(10));
+ schedule_timeout(MSEC_TO_JIFFIES(10));
spin_lock_irqsave(&dev->tx_lock, flags);
}
diff -puN drivers/net/irda/sir_kthread.c~jiffies-to-msec-borkage-fix drivers/net/irda/sir_kthread.c
--- 25/drivers/net/irda/sir_kthread.c~jiffies-to-msec-borkage-fix 2004-05-12 13:46:41.451168864 -0700
+++ 25-akpm/drivers/net/irda/sir_kthread.c 2004-05-12 13:46:41.485163696 -0700
@@ -415,7 +415,7 @@ static void irda_config_fsm(void *data)
fsm->state = next_state;
} while(!delay);
- irda_queue_delayed_request(&fsm->rq, MSECS_TO_JIFFIES(delay));
+ irda_queue_delayed_request(&fsm->rq, MSEC_TO_JIFFIES(delay));
}
/* schedule some device configuration task for execution by kIrDAd
diff -puN drivers/net/irda/stir4200.c~jiffies-to-msec-borkage-fix drivers/net/irda/stir4200.c
--- 25/drivers/net/irda/stir4200.c~jiffies-to-msec-borkage-fix 2004-05-12 13:46:41.453168560 -0700
+++ 25-akpm/drivers/net/irda/stir4200.c 2004-05-12 13:46:41.488163240 -0700
@@ -208,7 +208,7 @@ static int write_reg(struct stir_cb *sti
REQ_WRITE_SINGLE,
USB_DIR_OUT|USB_TYPE_VENDOR|USB_RECIP_DEVICE,
value, reg, NULL, 0,
- MSECS_TO_JIFFIES(CTRL_TIMEOUT));
+ MSEC_TO_JIFFIES(CTRL_TIMEOUT));
}
/* Send control message to read multiple registers */
@@ -221,7 +221,7 @@ static inline int read_reg(struct stir_c
REQ_READ_REG,
USB_DIR_IN | USB_TYPE_VENDOR | USB_RECIP_DEVICE,
0, reg, data, count,
- MSECS_TO_JIFFIES(CTRL_TIMEOUT));
+ MSEC_TO_JIFFIES(CTRL_TIMEOUT));
}
static inline int isfir(u32 speed)
@@ -745,7 +745,7 @@ static void stir_send(struct stir_cb *st
if (usb_bulk_msg(stir->usbdev, usb_sndbulkpipe(stir->usbdev, 1),
stir->io_buf, wraplen,
- NULL, MSECS_TO_JIFFIES(TRANSMIT_TIMEOUT)))
+ NULL, MSEC_TO_JIFFIES(TRANSMIT_TIMEOUT)))
stir->stats.tx_errors++;
}
diff -puN drivers/net/irda/tekram.c~jiffies-to-msec-borkage-fix drivers/net/irda/tekram.c
--- 25/drivers/net/irda/tekram.c~jiffies-to-msec-borkage-fix 2004-05-12 13:46:41.454168408 -0700
+++ 25-akpm/drivers/net/irda/tekram.c 2004-05-12 13:46:41.482164152 -0700
@@ -113,7 +113,7 @@ static int tekram_change_speed(struct ir
if (self->speed_task && self->speed_task != task) {
IRDA_DEBUG(0, "%s(), busy!\n", __FUNCTION__ );
- return MSECS_TO_JIFFIES(10);
+ return MSEC_TO_JIFFIES(10);
} else
self->speed_task = task;
@@ -150,7 +150,7 @@ static int tekram_change_speed(struct ir
irda_task_next_state(task, IRDA_TASK_CHILD_WAIT);
/* Give reset 1 sec to finish */
- ret = MSECS_TO_JIFFIES(1000);
+ ret = MSEC_TO_JIFFIES(1000);
} else
irda_task_next_state(task, IRDA_TASK_CHILD_DONE);
break;
@@ -171,7 +171,7 @@ static int tekram_change_speed(struct ir
irda_task_next_state(task, IRDA_TASK_WAIT);
/* Wait at least 100 ms */
- ret = MSECS_TO_JIFFIES(150);
+ ret = MSEC_TO_JIFFIES(150);
break;
case IRDA_TASK_WAIT:
/* Set DTR, Set RTS */
@@ -214,7 +214,7 @@ int tekram_reset(struct irda_task *task)
if (self->reset_task && self->reset_task != task) {
IRDA_DEBUG(0, "%s(), busy!\n", __FUNCTION__ );
- return MSECS_TO_JIFFIES(10);
+ return MSEC_TO_JIFFIES(10);
} else
self->reset_task = task;
@@ -227,7 +227,7 @@ int tekram_reset(struct irda_task *task)
irda_task_next_state(task, IRDA_TASK_WAIT1);
/* Sleep 50 ms */
- ret = MSECS_TO_JIFFIES(50);
+ ret = MSEC_TO_JIFFIES(50);
break;
case IRDA_TASK_WAIT1:
/* Clear DTR, Set RTS */
@@ -236,7 +236,7 @@ int tekram_reset(struct irda_task *task)
irda_task_next_state(task, IRDA_TASK_WAIT2);
/* Should sleep 1 ms */
- ret = MSECS_TO_JIFFIES(1);
+ ret = MSEC_TO_JIFFIES(1);
break;
case IRDA_TASK_WAIT2:
/* Set DTR, Set RTS */
diff -puN drivers/net/irda/tekram-sir.c~jiffies-to-msec-borkage-fix drivers/net/irda/tekram-sir.c
--- 25/drivers/net/irda/tekram-sir.c~jiffies-to-msec-borkage-fix 2004-05-12 13:46:41.455168256 -0700
+++ 25-akpm/drivers/net/irda/tekram-sir.c 2004-05-12 13:46:41.479164608 -0700
@@ -211,7 +211,7 @@ static int tekram_reset(struct sir_dev *
/* Should sleep 1 ms */
set_current_state(TASK_UNINTERRUPTIBLE);
- schedule_timeout(MSECS_TO_JIFFIES(1));
+ schedule_timeout(MSEC_TO_JIFFIES(1));
/* Set DTR, Set RTS */
sirdev_set_dtr_rts(dev, TRUE, TRUE);
diff -puN include/asm-i386/param.h~jiffies-to-msec-borkage-fix include/asm-i386/param.h
--- 25/include/asm-i386/param.h~jiffies-to-msec-borkage-fix 2004-05-12 13:46:41.456168104 -0700
+++ 25-akpm/include/asm-i386/param.h 2004-05-12 13:46:41.497161872 -0700
@@ -5,8 +5,6 @@
# define HZ 1000 /* Internal kernel timer frequency */
# define USER_HZ 100 /* .. some user interfaces are in "ticks" */
# define CLOCKS_PER_SEC (USER_HZ) /* like times() */
-# define JIFFIES_TO_MSEC(x) (x)
-# define MSEC_TO_JIFFIES(x) (x)
#endif
#ifndef HZ
diff -puN include/linux/time.h~jiffies-to-msec-borkage-fix include/linux/time.h
--- 25/include/linux/time.h~jiffies-to-msec-borkage-fix 2004-05-12 13:46:41.457167952 -0700
+++ 25-akpm/include/linux/time.h 2004-05-12 13:46:41.496162024 -0700
@@ -383,5 +383,15 @@ struct itimerval {
#define TIMER_ABSTIME 0x01
+#if HZ <= 1000 && !(1000 % HZ)
+#define MSEC_TO_JIFFIES(m) ((1000/HZ)*(m))
+#define JIFFIES_TO_MSEC(j) ((j)/(1000/HZ))
+#elif HZ > 1000 && !(HZ % 1000)
+#define MSEC_TO_JIFFIES(m) ((m)/(HZ/1000))
+#define JIFFIES_TO_MSEC(j) ((HZ/1000)*(j))
+#else
+#define MSEC_TO_JIFFIES(m) ((HZ*(m) + 999)/1000)
+#define JIFFIES_TO_MSEC(j) ((1000*(j) + HZ - 1)/HZ)
+#endif
#endif
diff -puN include/net/irda/irda.h~jiffies-to-msec-borkage-fix include/net/irda/irda.h
--- 25/include/net/irda/irda.h~jiffies-to-msec-borkage-fix 2004-05-12 13:46:41.459167648 -0700
+++ 25-akpm/include/net/irda/irda.h 2004-05-12 13:46:41.488163240 -0700
@@ -83,8 +83,6 @@ if(!(expr)) do { \
#define MESSAGE(args...) printk(KERN_INFO args)
#define ERROR(args...) printk(KERN_ERR args)
-#define MSECS_TO_JIFFIES(ms) (((ms)*HZ+999)/1000)
-
/*
* Magic numbers used by Linux-IrDA. Random numbers which must be unique to
* give the best protection
diff -puN include/net/sctp/sctp.h~jiffies-to-msec-borkage-fix include/net/sctp/sctp.h
--- 25/include/net/sctp/sctp.h~jiffies-to-msec-borkage-fix 2004-05-12 13:46:41.460167496 -0700
+++ 25-akpm/include/net/sctp/sctp.h 2004-05-12 13:46:41.473165520 -0700
@@ -116,11 +116,6 @@
#define SCTP_STATIC static
#endif
-#define MSECS_TO_JIFFIES(msec) \
- (((msec / 1000) * HZ) + ((msec % 1000) * HZ) / 1000)
-#define JIFFIES_TO_MSECS(jiff) \
- (((jiff / HZ) * 1000) + ((jiff % HZ) * 1000) / HZ)
-
/*
* Function declarations.
*/
diff -puN kernel/sched.c~jiffies-to-msec-borkage-fix kernel/sched.c
--- 25/kernel/sched.c~jiffies-to-msec-borkage-fix 2004-05-12 13:46:41.461167344 -0700
+++ 25-akpm/kernel/sched.c 2004-05-12 13:46:41.496162024 -0700
@@ -75,13 +75,6 @@
#define NS_TO_JIFFIES(TIME) ((TIME) / (1000000000 / HZ))
#define JIFFIES_TO_NS(TIME) ((TIME) * (1000000000 / HZ))
-#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
-
/*
* These are the 'tuning knobs' of the scheduler:
*
diff -puN net/irda/ircomm/ircomm_tty.c~jiffies-to-msec-borkage-fix net/irda/ircomm/ircomm_tty.c
--- 25/net/irda/ircomm/ircomm_tty.c~jiffies-to-msec-borkage-fix 2004-05-12 13:46:41.463167040 -0700
+++ 25-akpm/net/irda/ircomm/ircomm_tty.c 2004-05-12 13:46:41.489163088 -0700
@@ -873,7 +873,7 @@ static void ircomm_tty_wait_until_sent(s
orig_jiffies = jiffies;
/* Set poll time to 200 ms */
- poll_time = IRDA_MIN(timeout, MSECS_TO_JIFFIES(200));
+ poll_time = IRDA_MIN(timeout, MSEC_TO_JIFFIES(200));
spin_lock_irqsave(&self->spinlock, flags);
while (self->tx_skb && self->tx_skb->len) {
diff -puN net/irda/irlap_event.c~jiffies-to-msec-borkage-fix net/irda/irlap_event.c
--- 25/net/irda/irlap_event.c~jiffies-to-msec-borkage-fix 2004-05-12 13:46:41.464166888 -0700
+++ 25-akpm/net/irda/irlap_event.c 2004-05-12 13:46:41.491162784 -0700
@@ -627,7 +627,7 @@ static int irlap_state_query(struct irla
if (irda_device_is_receiving(self->netdev) && !self->add_wait) {
IRDA_DEBUG(2, "%s(), device is slow to answer, "
"waiting some more!\n", __FUNCTION__);
- irlap_start_slot_timer(self, MSECS_TO_JIFFIES(10));
+ irlap_start_slot_timer(self, MSEC_TO_JIFFIES(10));
self->add_wait = TRUE;
return ret;
}
@@ -849,7 +849,7 @@ static int irlap_state_setup(struct irla
* 1.5 times the time taken to transmit a SNRM frame. So this time should
* between 15 msecs and 45 msecs.
*/
- irlap_start_backoff_timer(self, MSECS_TO_JIFFIES(20 +
+ irlap_start_backoff_timer(self, MSEC_TO_JIFFIES(20 +
(jiffies % 30)));
} else {
/* Always switch state before calling upper layers */
@@ -1506,7 +1506,7 @@ static int irlap_state_nrm_p(struct irla
if (irda_device_is_receiving(self->netdev) && !self->add_wait) {
IRDA_DEBUG(1, "FINAL_TIMER_EXPIRED when receiving a "
"frame! Waiting a little bit more!\n");
- irlap_start_final_timer(self, MSECS_TO_JIFFIES(300));
+ irlap_start_final_timer(self, MSEC_TO_JIFFIES(300));
/*
* Don't allow this to happen one more time in a row,
diff -puN net/sctp/associola.c~jiffies-to-msec-borkage-fix net/sctp/associola.c
--- 25/net/sctp/associola.c~jiffies-to-msec-borkage-fix 2004-05-12 13:46:41.466166584 -0700
+++ 25-akpm/net/sctp/associola.c 2004-05-12 13:46:41.492162632 -0700
@@ -142,9 +142,9 @@ struct sctp_association *sctp_associatio
* socket values.
*/
asoc->max_retrans = sp->assocparams.sasoc_asocmaxrxt;
- asoc->rto_initial = MSECS_TO_JIFFIES(sp->rtoinfo.srto_initial);
- asoc->rto_max = MSECS_TO_JIFFIES(sp->rtoinfo.srto_max);
- asoc->rto_min = MSECS_TO_JIFFIES(sp->rtoinfo.srto_min);
+ asoc->rto_initial = MSEC_TO_JIFFIES(sp->rtoinfo.srto_initial);
+ asoc->rto_max = MSEC_TO_JIFFIES(sp->rtoinfo.srto_max);
+ asoc->rto_min = MSEC_TO_JIFFIES(sp->rtoinfo.srto_min);
asoc->overall_error_count = 0;
@@ -170,7 +170,7 @@ struct sctp_association *sctp_associatio
asoc->max_init_attempts = sp->initmsg.sinit_max_attempts;
asoc->max_init_timeo =
- MSECS_TO_JIFFIES(sp->initmsg.sinit_max_init_timeo);
+ MSEC_TO_JIFFIES(sp->initmsg.sinit_max_init_timeo);
/* Allocate storage for the ssnmap after the inbound and outbound
* streams have been negotiated during Init.
@@ -507,7 +507,7 @@ struct sctp_transport *sctp_assoc_add_pe
/* Initialize the peer's heartbeat interval based on the
* sock configured value.
*/
- peer->hb_interval = MSECS_TO_JIFFIES(sp->paddrparam.spp_hbinterval);
+ peer->hb_interval = MSEC_TO_JIFFIES(sp->paddrparam.spp_hbinterval);
/* Set the path max_retrans. */
peer->max_retrans = asoc->max_retrans;
diff -puN net/sctp/chunk.c~jiffies-to-msec-borkage-fix net/sctp/chunk.c
--- 25/net/sctp/chunk.c~jiffies-to-msec-borkage-fix 2004-05-12 13:46:41.467166432 -0700
+++ 25-akpm/net/sctp/chunk.c 2004-05-12 13:46:41.493162480 -0700
@@ -186,7 +186,7 @@ struct sctp_datamsg *sctp_datamsg_from_u
if (sinfo->sinfo_timetolive) {
/* sinfo_timetolive is in milliseconds */
msg->expires_at = jiffies +
- MSECS_TO_JIFFIES(sinfo->sinfo_timetolive);
+ MSEC_TO_JIFFIES(sinfo->sinfo_timetolive);
msg->can_abandon = 1;
SCTP_DEBUG_PRINTK("%s: msg:%p expires_at: %ld jiffies:%ld\n",
__FUNCTION__, msg, msg->expires_at, jiffies);
diff -puN net/sctp/endpointola.c~jiffies-to-msec-borkage-fix net/sctp/endpointola.c
--- 25/net/sctp/endpointola.c~jiffies-to-msec-borkage-fix 2004-05-12 13:46:41.468166280 -0700
+++ 25-akpm/net/sctp/endpointola.c 2004-05-12 13:46:41.493162480 -0700
@@ -129,7 +129,7 @@ struct sctp_endpoint *sctp_endpoint_init
ep->timeouts[SCTP_EVENT_TIMEOUT_T1_INIT] =
SCTP_DEFAULT_TIMEOUT_T1_INIT;
ep->timeouts[SCTP_EVENT_TIMEOUT_T2_SHUTDOWN] =
- MSECS_TO_JIFFIES(sp->rtoinfo.srto_initial);
+ MSEC_TO_JIFFIES(sp->rtoinfo.srto_initial);
ep->timeouts[SCTP_EVENT_TIMEOUT_T3_RTX] = 0;
ep->timeouts[SCTP_EVENT_TIMEOUT_T4_RTO] = 0;
@@ -138,7 +138,7 @@ struct sctp_endpoint *sctp_endpoint_init
* recommended value of 5 times 'RTO.Max'.
*/
ep->timeouts[SCTP_EVENT_TIMEOUT_T5_SHUTDOWN_GUARD]
- = 5 * MSECS_TO_JIFFIES(sp->rtoinfo.srto_max);
+ = 5 * MSEC_TO_JIFFIES(sp->rtoinfo.srto_max);
ep->timeouts[SCTP_EVENT_TIMEOUT_HEARTBEAT] =
SCTP_DEFAULT_TIMEOUT_HEARTBEAT;
diff -puN net/sctp/socket.c~jiffies-to-msec-borkage-fix net/sctp/socket.c
--- 25/net/sctp/socket.c~jiffies-to-msec-borkage-fix 2004-05-12 13:46:41.470165976 -0700
+++ 25-akpm/net/sctp/socket.c 2004-05-12 13:46:41.477164912 -0700
@@ -2379,14 +2379,14 @@ SCTP_STATIC int sctp_init_sock(struct so
sp->initmsg.sinit_num_ostreams = sctp_max_outstreams;
sp->initmsg.sinit_max_instreams = sctp_max_instreams;
sp->initmsg.sinit_max_attempts = sctp_max_retrans_init;
- sp->initmsg.sinit_max_init_timeo = JIFFIES_TO_MSECS(sctp_rto_max);
+ sp->initmsg.sinit_max_init_timeo = JIFFIES_TO_MSEC(sctp_rto_max);
/* Initialize default RTO related parameters. These parameters can
* be modified for with the SCTP_RTOINFO socket option.
*/
- sp->rtoinfo.srto_initial = JIFFIES_TO_MSECS(sctp_rto_initial);
- sp->rtoinfo.srto_max = JIFFIES_TO_MSECS(sctp_rto_max);
- sp->rtoinfo.srto_min = JIFFIES_TO_MSECS(sctp_rto_min);
+ sp->rtoinfo.srto_initial = JIFFIES_TO_MSEC(sctp_rto_initial);
+ sp->rtoinfo.srto_max = JIFFIES_TO_MSEC(sctp_rto_max);
+ sp->rtoinfo.srto_min = JIFFIES_TO_MSEC(sctp_rto_min);
/* Initialize default association related parameters. These parameters
* can be modified with the SCTP_ASSOCINFO socket option.
@@ -2396,7 +2396,7 @@ SCTP_STATIC int sctp_init_sock(struct so
sp->assocparams.sasoc_peer_rwnd = 0;
sp->assocparams.sasoc_local_rwnd = 0;
sp->assocparams.sasoc_cookie_life =
- JIFFIES_TO_MSECS(sctp_valid_cookie_life);
+ JIFFIES_TO_MSEC(sctp_valid_cookie_life);
/* Initialize default event subscriptions. By default, all the
* options are off.
@@ -2406,7 +2406,7 @@ SCTP_STATIC int sctp_init_sock(struct so
/* Default Peer Address Parameters. These defaults can
* be modified via SCTP_PEER_ADDR_PARAMS
*/
- sp->paddrparam.spp_hbinterval = JIFFIES_TO_MSECS(sctp_hb_interval);
+ sp->paddrparam.spp_hbinterval = JIFFIES_TO_MSEC(sctp_hb_interval);
sp->paddrparam.spp_pathmaxrxt = sctp_max_retrans_path;
/* If enabled no SCTP message fragmentation will be performed.
@@ -2552,7 +2552,7 @@ static int sctp_getsockopt_sctp_status(s
status.sstat_primary.spinfo_state = transport->active;
status.sstat_primary.spinfo_cwnd = transport->cwnd;
status.sstat_primary.spinfo_srtt = transport->srtt;
- status.sstat_primary.spinfo_rto = JIFFIES_TO_MSECS(transport->rto);
+ status.sstat_primary.spinfo_rto = JIFFIES_TO_MSEC(transport->rto);
status.sstat_primary.spinfo_mtu = transport->pmtu;
if (put_user(len, optlen)) {
@@ -2607,7 +2607,7 @@ static int sctp_getsockopt_peer_addr_inf
pinfo.spinfo_state = transport->active;
pinfo.spinfo_cwnd = transport->cwnd;
pinfo.spinfo_srtt = transport->srtt;
- pinfo.spinfo_rto = JIFFIES_TO_MSECS(transport->rto);
+ pinfo.spinfo_rto = JIFFIES_TO_MSEC(transport->rto);
pinfo.spinfo_mtu = transport->pmtu;
if (put_user(len, optlen)) {
@@ -2811,7 +2811,7 @@ static int sctp_getsockopt_peer_addr_par
if (!trans->hb_allowed)
params.spp_hbinterval = 0;
else
- params.spp_hbinterval = JIFFIES_TO_MSECS(trans->hb_interval);
+ params.spp_hbinterval = JIFFIES_TO_MSEC(trans->hb_interval);
/* spp_pathmaxrxt contains the maximum number of retransmissions
* before this address shall be considered unreachable.
@@ -3168,9 +3168,9 @@ static int sctp_getsockopt_rtoinfo(struc
/* Values corresponding to the specific association. */
if (asoc) {
- rtoinfo.srto_initial = JIFFIES_TO_MSECS(asoc->rto_initial);
- rtoinfo.srto_max = JIFFIES_TO_MSECS(asoc->rto_max);
- rtoinfo.srto_min = JIFFIES_TO_MSECS(asoc->rto_min);
+ rtoinfo.srto_initial = JIFFIES_TO_MSEC(asoc->rto_initial);
+ rtoinfo.srto_max = JIFFIES_TO_MSEC(asoc->rto_max);
+ rtoinfo.srto_min = JIFFIES_TO_MSEC(asoc->rto_min);
} else {
/* Values corresponding to the endpoint. */
struct sctp_opt *sp = sctp_sk(sk);
_
^ permalink raw reply [flat|nested] 54+ messages in thread
* Re: MSEC_TO_JIFFIES is messed up...
2004-05-12 20:35 ` Ingo Molnar
@ 2004-05-12 20:50 ` Ingo Molnar
2004-05-12 21:03 ` Valdis.Kletnieks
2004-05-12 21:07 ` Andrew Morton
0 siblings, 2 replies; 54+ messages in thread
From: Ingo Molnar @ 2004-05-12 20:50 UTC (permalink / raw)
To: Valdis.Kletnieks
Cc: Davide Libenzi, Jeff Garzik, Greg KH, Andrew Morton,
linux-kernel, Netdev
[-- Attachment #1: Type: text/plain, Size: 380 bytes --]
* Ingo Molnar <mingo@elte.hu> wrote:
> new patch attached - this adopts the overflow-safe variant from
> sctp.h, removes it from sctp.h and moves it into a generic include
> file and also does the HZ=1000 simplification.
yet another patch - this time it's: complete, covers irda, accelerates
HZ=100, unifies the slightly differing namespaces and compiles/boots as
well.
Ingo
[-- Attachment #2: hz-cleanup-2.6.6-A2 --]
[-- Type: text/plain, Size: 2548 bytes --]
--- 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
+
/*
* The TICK_NSEC - 1 rounds up the value to the next resolution. Note
* that a remainder subtract here would not do the right thing as the
--- linux/include/net/irda/irda.h.orig
+++ linux/include/net/irda/irda.h
@@ -83,8 +83,6 @@ if(!(expr)) do { \
#define MESSAGE(args...) printk(KERN_INFO args)
#define ERROR(args...) printk(KERN_ERR args)
-#define MSECS_TO_JIFFIES(ms) (((ms)*HZ+999)/1000)
-
/*
* Magic numbers used by Linux-IrDA. Random numbers which must be unique to
* give the best protection
--- linux/include/net/sctp/sctp.h.orig
+++ linux/include/net/sctp/sctp.h
@@ -116,11 +116,6 @@
#define SCTP_STATIC static
#endif
-#define MSECS_TO_JIFFIES(msec) \
- (((msec / 1000) * HZ) + ((msec % 1000) * HZ) / 1000)
-#define JIFFIES_TO_MSECS(jiff) \
- (((jiff / HZ) * 1000) + ((jiff % HZ) * 1000) / HZ)
-
/*
* Function declarations.
*/
--- linux/include/asm-i386/param.h.orig
+++ linux/include/asm-i386/param.h
@@ -5,8 +5,6 @@
# define HZ 1000 /* Internal kernel timer frequency */
# define USER_HZ 100 /* .. some user interfaces are in "ticks" */
# define CLOCKS_PER_SEC (USER_HZ) /* like times() */
-# define JIFFIES_TO_MSEC(x) (x)
-# define MSEC_TO_JIFFIES(x) (x)
#endif
#ifndef HZ
--- linux/kernel/sched.c.orig
+++ linux/kernel/sched.c
@@ -75,13 +75,6 @@
#define NS_TO_JIFFIES(TIME) ((TIME) / (1000000000 / HZ))
#define JIFFIES_TO_NS(TIME) ((TIME) * (1000000000 / HZ))
-#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
-
/*
* These are the 'tuning knobs' of the scheduler:
*
@@ -1880,7 +1873,7 @@ static void rebalance_tick(int this_cpu,
interval *= sd->busy_factor;
/* scale ms to jiffies */
- interval = MSEC_TO_JIFFIES(interval);
+ interval = MSECS_TO_JIFFIES(interval);
if (unlikely(!interval))
interval = 1;
^ permalink raw reply [flat|nested] 54+ messages in thread
* Re: MSEC_TO_JIFFIES is messed up...
2004-05-12 18:42 ` Jeff Garzik
2004-05-12 19:33 ` Ingo Molnar
@ 2004-05-12 20:54 ` Bill Rugolsky Jr.
2004-05-12 22:44 ` Bill Rugolsky Jr.
1 sibling, 1 reply; 54+ messages in thread
From: Bill Rugolsky Jr. @ 2004-05-12 20:54 UTC (permalink / raw)
To: Jeff Garzik
Cc: Greg KH, Andrew Morton, mingo, linux-kernel, Netdev,
Sridhar Samudrala, davem, George Anzinger
[-- Attachment #1: Type: text/plain, Size: 3496 bytes --]
On Wed, May 12, 2004 at 02:42:02PM -0400, Jeff Garzik wrote:
> One of the SCTP folks was cleaning up all the random jif-to-msec and
> msec-to-jif macros into include/linux/time.h. Need to dig that up and
> merge it.
Yes, that was Sridhar Samudrala <sri@us.ibm.com>. I've done some work
to create an accurate implementation of msecs_to_jiffies() and jiffies_to_msecs(),
which I was going to submit later this week after clearing it with George Anziger.
[I have a follow-on patch that reworks the select/poll/epoll timeout fixes
to use timeval_to_jiffies() and msecs_to_jiffies().]
The attached patch combines Sridhar's consolidation patch with my
more accurate routines in the spirit of the rest of time.h. It is against
2.6.6-rc3-bk3. Feedback welcome. I'm happy to rediff against latest kernel,
I just haven't had time the last few days.
George's userland test harness was used to test this on x86 and x86_64.
Below are excerpts from my test output for powers of 2.
The kernel patch compiles and boots on x86, but hasn't been tested extensively.
On x86:
HZ=1535
00: jiffies_to_msecs(1): 1
00: msecs_to_jiffies(1): 2
01: jiffies_to_msecs(2): 2
01: msecs_to_jiffies(2): 4
...
30: jiffies_to_msecs(1073741824): 699221750
30: msecs_to_jiffies(1073741824): 1648863906
31: jiffies_to_msecs(2147483648): 1398443499
31: msecs_to_jiffies(2147483648): 2147483646
HZ=100
00: jiffies_to_msecs(1): 10
00: msecs_to_jiffies(1): 1
01: jiffies_to_msecs(2): 20
01: msecs_to_jiffies(2): 1
...
30: jiffies_to_msecs(1073741824): 2147483640
30: msecs_to_jiffies(1073741824): 107374183
31: jiffies_to_msecs(2147483648): 2147483640
31: msecs_to_jiffies(2147483648): 214748365
HZ=12
00: jiffies_to_msecs(1): 84
00: msecs_to_jiffies(1): 1
01: jiffies_to_msecs(2): 167
01: msecs_to_jiffies(2): 1
...
30: jiffies_to_msecs(1073741824): 2147483576
30: msecs_to_jiffies(1073741824): 12884902
31: jiffies_to_msecs(2147483648): 2147483576
31: msecs_to_jiffies(2147483648): 25769804
On x86_64:
HZ=1535
00: jiffies_to_msecs(1): 1
00: msecs_to_jiffies(1): 2
01: jiffies_to_msecs(2): 2
01: msecs_to_jiffies(2): 4
...
61: jiffies_to_msecs(2305843009213693952): 1501567273914073088
61: msecs_to_jiffies(2305843009213693952): 3540908275912409088
62: jiffies_to_msecs(4611686018427387904): 3003134547828146176
62: msecs_to_jiffies(4611686018427387904): 7081816551824818176
63: jiffies_to_msecs(9223372036854775808): 6006269095656292351
63: msecs_to_jiffies(9223372036854775808): 9223372024794783097
HZ=100
00: jiffies_to_msecs(1): 10
00: msecs_to_jiffies(1): 1
01: jiffies_to_msecs(2): 20
01: msecs_to_jiffies(2): 1
...
61: jiffies_to_msecs(2305843009213693952): 9223372033096679414
61: msecs_to_jiffies(2305843009213693952): 230584301001900032
62: jiffies_to_msecs(4611686018427387904): 9223372033096679414
62: msecs_to_jiffies(4611686018427387904): 461168602003800064
63: jiffies_to_msecs(9223372036854775808): 9223372033096679414
63: msecs_to_jiffies(9223372036854775808): 922337202396987392
HZ=12
00: jiffies_to_msecs(1): 84
00: msecs_to_jiffies(1): 1
01: jiffies_to_msecs(2): 167
01: msecs_to_jiffies(2): 1
...
61: jiffies_to_msecs(2305843009213693952): 9223371701044963021
61: msecs_to_jiffies(2305843009213693952): 27670116233641984
62: jiffies_to_msecs(4611686018427387904): 9223371701044963021
62: msecs_to_jiffies(4611686018427387904): 55340232467283968
63: jiffies_to_msecs(9223372036854775808): 9223371701044963021
63: msecs_to_jiffies(9223372036854775808): 110680463286911100
Regards,
Bill Rugolsky
[-- Attachment #2: linux-2.6.6-rc3-bk3-msecs-to-jiffies.patch --]
[-- Type: text/plain, Size: 35977 bytes --]
--- linux/include/linux/time.h.msecs-to-jiffies 2004-04-03 22:37:36.000000000 -0500
+++ linux/include/linux/time.h 2004-05-07 15:33:49.000000000 -0400
@@ -66,6 +66,10 @@
#define NSEC_PER_SEC (1000000000L)
#endif
+#ifndef NSEC_PER_MSEC
+#define NSEC_PER_MSEC (1000000L)
+#endif
+
#ifndef NSEC_PER_USEC
#define NSEC_PER_USEC (1000L)
#endif
@@ -148,6 +152,18 @@
#endif
#define NSEC_JIFFIE_SC (SEC_JIFFIE_SC + 29)
#define USEC_JIFFIE_SC (SEC_JIFFIE_SC + 19)
+#define MSEC_JIFFIE_SC (SEC_JIFFIE_SC + 9)
+
+/*
+ * As above, test the sign bit for the jiffie to msec conversion, and if it
+ * is not set, bump the shift count to gain an extra bit of precision.
+ */
+#define JIFFIE_MSEC_SC (31 + SHIFT_HZ - 10)
+#if !((((TICK_NSEC << 2) / NSEC_PER_MSEC) << (JIFFIE_MSEC_SC - 2)) & 0x80000000)
+#undef JIFFIE_MSEC_SC
+#define JIFFIE_MSEC_SC (32 + SHIFT_HZ - 10)
+#endif
+
#define SEC_CONVERSION ((unsigned long)((((u64)NSEC_PER_SEC << SEC_JIFFIE_SC) +\
TICK_NSEC -1) / (u64)TICK_NSEC))
@@ -156,14 +172,24 @@
#define USEC_CONVERSION \
((unsigned long)((((u64)NSEC_PER_USEC << USEC_JIFFIE_SC) +\
TICK_NSEC -1) / (u64)TICK_NSEC))
+#define MSEC_CONVERSION \
+ ((unsigned long)((((u64)NSEC_PER_MSEC << MSEC_JIFFIE_SC) +\
+ TICK_NSEC -1) / (u64)TICK_NSEC))
+#define JIFFIE_MSEC_CONVERSION \
+ ((unsigned long)((((u64)TICK_NSEC << JIFFIE_MSEC_SC) +\
+ NSEC_PER_MSEC -1) / (u64)NSEC_PER_MSEC))
/*
* USEC_ROUND is used in the timeval to jiffie conversion. See there
* for more details. It is the scaled resolution rounding value. Note
* that it is a 64-bit value. Since, when it is applied, we are already
- * in jiffies (albit scaled), it is nothing but the bits we will shift
- * off.
+ * in jiffies (albeit scaled), it is nothing but the bits we will shift
+ * off. Similarly for MSEC_ROUND and JIFFIE_MSEC_ROUND.
*/
+
#define USEC_ROUND (u64)(((u64)1 << USEC_JIFFIE_SC) - 1)
+#define MSEC_ROUND (((u64)1 << MSEC_JIFFIE_SC) - 1)
+#define JIFFIE_MSEC_ROUND (((u64)1 << JIFFIE_MSEC_SC) - 1)
+
/*
* The maximum jiffie value is (MAX_INT >> 1). Here we translate that
* into seconds. The 64-bit case will overflow if we are not careful,
@@ -175,8 +201,39 @@
#else /* take care of overflow on 64 bits machines */
# define MAX_SEC_IN_JIFFIES \
(SH_DIV((MAX_JIFFY_OFFSET >> SEC_JIFFIE_SC) * TICK_NSEC, NSEC_PER_SEC, 1) - 1)
+#endif
+
+/*
+ * Since a tick can be longer or shorter than a millisecond, we need
+ * to cap one of the MAX_ values at MAX_JIFFY_OFFSET when translating
+ * between jiffies and milliseconds.
+ */
+#if TICK_NSEC < NSEC_PER_MSEC
+# define MAX_JIFFIE_IN_MSECS MAX_JIFFY_OFFSET
+#if BITS_PER_LONG < 64
+# define MAX_MSEC_IN_JIFFIES \
+ (long)((u64)((u64)MAX_JIFFY_OFFSET * TICK_NSEC) / NSEC_PER_MSEC)
+#else
+# define MAX_MSEC_IN_JIFFIES \
+ ((((MAX_JIFFY_OFFSET & ~(~0UL >> MSEC_JIFFIE_SC)) / \
+ MSEC_CONVERSION) << MSEC_JIFFIE_SC) -1)
+#endif
+#elif TICK_NSEC > NSEC_PER_MSEC
+# define MAX_MSEC_IN_JIFFIES MAX_JIFFY_OFFSET
+#if BITS_PER_LONG < 64
+# define MAX_JIFFIE_IN_MSECS \
+ (long)((u64)((u64)MAX_JIFFY_OFFSET * NSEC_PER_MSEC) / TICK_NSEC)
+#else
+# define MAX_JIFFIE_IN_MSECS \
+ ((((MAX_JIFFY_OFFSET & ~(~0UL >> JIFFIE_MSEC_SC)) / \
+ JIFFIE_MSEC_CONVERSION) << JIFFIE_MSEC_SC) -1)
#endif
+#else
+# define MAX_JIFFIE_IN_MSECS MAX_JIFFY_OFFSET
+# define MAX_MSEC_IN_JIFFIES MAX_JIFFY_OFFSET
+#endif
+
/*
* The TICK_NSEC - 1 rounds up the value to the next resolution. Note
* that a remainder subtract here would not do the right thing as the
@@ -254,6 +311,37 @@
value->tv_usec /= NSEC_PER_USEC;
}
+static __inline__ unsigned long
+msecs_to_jiffies(unsigned long msec)
+{
+ if (msec >= MAX_MSEC_IN_JIFFIES)
+ msec = MAX_MSEC_IN_JIFFIES;
+
+#if BITS_PER_LONG < 64
+ return ((u64)msec * MSEC_CONVERSION + MSEC_ROUND) >> MSEC_JIFFIE_SC;
+#else
+ return (msec >> MSEC_JIFFIE_SC) * MSEC_CONVERSION +
+ (((msec & (~0UL >> MSEC_JIFFIE_SC)) * MSEC_CONVERSION +
+ MSEC_ROUND) >> MSEC_JIFFIE_SC);
+#endif
+}
+
+static __inline__ unsigned long
+jiffies_to_msecs(unsigned long jiffies)
+{
+ if (jiffies >= MAX_JIFFIE_IN_MSECS)
+ jiffies = MAX_JIFFIE_IN_MSECS;
+
+#if BITS_PER_LONG < 64
+ return ((u64)jiffies * JIFFIE_MSEC_CONVERSION +
+ JIFFIE_MSEC_ROUND) >> JIFFIE_MSEC_SC;
+#else
+ return (jiffies >> JIFFIE_MSEC_SC) * JIFFIE_MSEC_CONVERSION +
+ (((jiffies & (~0UL >> JIFFIE_MSEC_SC)) * JIFFIE_MSEC_CONVERSION +
+ JIFFIE_MSEC_ROUND) >> JIFFIE_MSEC_SC);
+#endif
+}
+
static __inline__ int timespec_equal(struct timespec *a, struct timespec *b)
{
return (a->tv_sec == b->tv_sec) && (a->tv_nsec == b->tv_nsec);
--- linux/drivers/net/tulip/de2104x.c.msecs-to-jiffies 2004-05-07 15:28:53.000000000 -0400
+++ linux/drivers/net/tulip/de2104x.c 2004-05-07 15:30:19.000000000 -0400
@@ -357,13 +357,6 @@
static u16 t21041_csr15[] = { 0x0008, 0x0006, 0x000E, 0x0008, 0x0008, };
-static inline unsigned long
-msec_to_jiffies(unsigned long ms)
-{
- return (((ms)*HZ+999)/1000);
-}
-
-
#define dr32(reg) readl(de->regs + (reg))
#define dw32(reg,val) writel((val), de->regs + (reg))
@@ -1216,7 +1209,7 @@
/* de4x5.c delays, so we do too */
current->state = TASK_UNINTERRUPTIBLE;
- schedule_timeout(msec_to_jiffies(10));
+ schedule_timeout(msecs_to_jiffies(10));
}
}
--- linux/drivers/net/irda/act200l-sir.c.msecs-to-jiffies 2004-04-03 22:36:55.000000000 -0500
+++ linux/drivers/net/irda/act200l-sir.c 2004-05-07 15:30:19.000000000 -0400
@@ -178,7 +178,7 @@
/* Write control bytes */
sirdev_raw_write(dev, control, 3);
set_current_state(TASK_UNINTERRUPTIBLE);
- schedule_timeout(MSECS_TO_JIFFIES(5));
+ schedule_timeout(msecs_to_jiffies(5));
/* Go back to normal mode */
sirdev_set_dtr_rts(dev, TRUE, TRUE);
--- linux/drivers/net/irda/act200l.c.msecs-to-jiffies 2004-04-03 22:37:07.000000000 -0500
+++ linux/drivers/net/irda/act200l.c 2004-05-07 15:30:19.000000000 -0400
@@ -148,7 +148,7 @@
irda_task_next_state(task, IRDA_TASK_CHILD_WAIT);
/* Give reset 1 sec to finish */
- ret = MSECS_TO_JIFFIES(1000);
+ ret = msecs_to_jiffies(1000);
}
break;
case IRDA_TASK_CHILD_WAIT:
@@ -187,7 +187,7 @@
/* Write control bytes */
self->write(self->dev, control, 3);
irda_task_next_state(task, IRDA_TASK_WAIT);
- ret = MSECS_TO_JIFFIES(5);
+ ret = msecs_to_jiffies(5);
break;
case IRDA_TASK_WAIT:
/* Go back to normal mode */
@@ -237,14 +237,14 @@
self->set_dtr_rts(self->dev, TRUE, TRUE);
irda_task_next_state(task, IRDA_TASK_WAIT1);
- ret = MSECS_TO_JIFFIES(50);
+ ret = msecs_to_jiffies(50);
break;
case IRDA_TASK_WAIT1:
/* Reset the dongle : set RTS low for 25 ms */
self->set_dtr_rts(self->dev, TRUE, FALSE);
irda_task_next_state(task, IRDA_TASK_WAIT2);
- ret = MSECS_TO_JIFFIES(50);
+ ret = msecs_to_jiffies(50);
break;
case IRDA_TASK_WAIT2:
/* Clear DTR and set RTS to enter command mode */
@@ -253,7 +253,7 @@
/* Write control bytes */
self->write(self->dev, control, 9);
irda_task_next_state(task, IRDA_TASK_WAIT3);
- ret = MSECS_TO_JIFFIES(15);
+ ret = msecs_to_jiffies(15);
break;
case IRDA_TASK_WAIT3:
/* Go back to normal mode */
--- linux/drivers/net/irda/actisys.c.msecs-to-jiffies 2004-04-03 22:38:28.000000000 -0500
+++ linux/drivers/net/irda/actisys.c 2004-05-07 15:30:19.000000000 -0400
@@ -238,7 +238,7 @@
self->set_dtr_rts(self->dev, TRUE, TRUE);
/* Sleep 50 ms to make sure capacitor is charged */
- ret = MSECS_TO_JIFFIES(50);
+ ret = msecs_to_jiffies(50);
irda_task_next_state(task, IRDA_TASK_WAIT);
break;
case IRDA_TASK_WAIT:
--- linux/drivers/net/irda/girbil.c.msecs-to-jiffies 2004-04-03 22:36:12.000000000 -0500
+++ linux/drivers/net/irda/girbil.c 2004-05-07 15:30:19.000000000 -0400
@@ -119,7 +119,7 @@
irda_task_next_state(task, IRDA_TASK_CHILD_WAIT);
/* Give reset 1 sec to finish */
- ret = MSECS_TO_JIFFIES(1000);
+ ret = msecs_to_jiffies(1000);
}
break;
case IRDA_TASK_CHILD_WAIT:
@@ -153,7 +153,7 @@
/* Write control bytes */
self->write(self->dev, control, 2);
irda_task_next_state(task, IRDA_TASK_WAIT);
- ret = MSECS_TO_JIFFIES(100);
+ ret = msecs_to_jiffies(100);
break;
case IRDA_TASK_WAIT:
/* Go back to normal mode */
@@ -194,19 +194,19 @@
self->set_dtr_rts(self->dev, TRUE, FALSE);
irda_task_next_state(task, IRDA_TASK_WAIT1);
/* Sleep at least 5 ms */
- ret = MSECS_TO_JIFFIES(20);
+ ret = msecs_to_jiffies(20);
break;
case IRDA_TASK_WAIT1:
/* Set DTR and clear RTS to enter command mode */
self->set_dtr_rts(self->dev, FALSE, TRUE);
irda_task_next_state(task, IRDA_TASK_WAIT2);
- ret = MSECS_TO_JIFFIES(20);
+ ret = msecs_to_jiffies(20);
break;
case IRDA_TASK_WAIT2:
/* Write control byte */
self->write(self->dev, &control, 1);
irda_task_next_state(task, IRDA_TASK_WAIT3);
- ret = MSECS_TO_JIFFIES(20);
+ ret = msecs_to_jiffies(20);
break;
case IRDA_TASK_WAIT3:
/* Go back to normal mode */
--- linux/drivers/net/irda/irda-usb.c.msecs-to-jiffies 2004-05-07 15:28:53.000000000 -0400
+++ linux/drivers/net/irda/irda-usb.c 2004-05-07 15:30:19.000000000 -0400
@@ -268,7 +268,7 @@
speed_bulk_callback, self);
urb->transfer_buffer_length = USB_IRDA_HEADER;
urb->transfer_flags = URB_ASYNC_UNLINK;
- urb->timeout = MSECS_TO_JIFFIES(100);
+ urb->timeout = msecs_to_jiffies(100);
/* Irq disabled -> GFP_ATOMIC */
if ((ret = usb_submit_urb(urb, GFP_ATOMIC))) {
@@ -412,7 +412,7 @@
* This is how the dongle will detect the end of packet - Jean II */
urb->transfer_flags |= URB_ZERO_PACKET;
/* Timeout need to be shorter than NET watchdog timer */
- urb->timeout = MSECS_TO_JIFFIES(200);
+ urb->timeout = msecs_to_jiffies(200);
/* Generate min turn time. FIXME: can we do better than this? */
/* Trying to a turnaround time at this level is trying to measure
@@ -1311,7 +1311,7 @@
IU_REQ_GET_CLASS_DESC,
USB_DIR_IN | USB_TYPE_CLASS | USB_RECIP_INTERFACE,
0, intf->altsetting->desc.bInterfaceNumber, desc,
- sizeof(*desc), MSECS_TO_JIFFIES(500));
+ sizeof(*desc), msecs_to_jiffies(500));
IRDA_DEBUG(1, "%s(), ret=%d\n", __FUNCTION__, ret);
if (ret < sizeof(*desc)) {
--- linux/drivers/net/irda/irport.c.msecs-to-jiffies 2004-05-07 15:28:53.000000000 -0400
+++ linux/drivers/net/irda/irport.c 2004-05-07 15:30:19.000000000 -0400
@@ -452,7 +452,7 @@
task->state = IRDA_TASK_WAIT;
/* Try again later */
- ret = MSECS_TO_JIFFIES(20);
+ ret = msecs_to_jiffies(20);
break;
}
@@ -474,7 +474,7 @@
irda_task_next_state(task, IRDA_TASK_CHILD_WAIT);
/* Give dongle 1 sec to finish */
- ret = MSECS_TO_JIFFIES(1000);
+ ret = msecs_to_jiffies(1000);
} else
/* Child finished immediately */
irda_task_next_state(task, IRDA_TASK_CHILD_DONE);
--- linux/drivers/net/irda/irtty-sir.c.msecs-to-jiffies 2004-04-03 22:36:11.000000000 -0500
+++ linux/drivers/net/irda/irtty-sir.c 2004-05-07 15:30:19.000000000 -0400
@@ -93,12 +93,12 @@
tty = priv->tty;
if (tty->driver->wait_until_sent) {
lock_kernel();
- tty->driver->wait_until_sent(tty, MSECS_TO_JIFFIES(100));
+ tty->driver->wait_until_sent(tty, msecs_to_jiffies(100));
unlock_kernel();
}
else {
set_task_state(current, TASK_UNINTERRUPTIBLE);
- schedule_timeout(MSECS_TO_JIFFIES(USBSERIAL_TX_DONE_DELAY));
+ schedule_timeout(msecs_to_jiffies(USBSERIAL_TX_DONE_DELAY));
}
}
--- linux/drivers/net/irda/ma600-sir.c.msecs-to-jiffies 2004-04-03 22:37:36.000000000 -0500
+++ linux/drivers/net/irda/ma600-sir.c 2004-05-07 15:30:19.000000000 -0400
@@ -192,7 +192,7 @@
/* Wait at least 10ms: fake wait_until_sent - 10 bits at 9600 baud*/
set_current_state(TASK_UNINTERRUPTIBLE);
- schedule_timeout(MSECS_TO_JIFFIES(15)); /* old ma600 uses 15ms */
+ schedule_timeout(msecs_to_jiffies(15)); /* old ma600 uses 15ms */
#if 1
/* read-back of the control byte. ma600 is the first dongle driver
@@ -216,7 +216,7 @@
/* Wait at least 10ms */
set_current_state(TASK_UNINTERRUPTIBLE);
- schedule_timeout(MSECS_TO_JIFFIES(10));
+ schedule_timeout(msecs_to_jiffies(10));
/* dongle is now switched to the new speed */
dev->speed = speed;
@@ -246,12 +246,12 @@
/* Reset the dongle : set DTR low for 10 ms */
sirdev_set_dtr_rts(dev, FALSE, TRUE);
set_current_state(TASK_UNINTERRUPTIBLE);
- schedule_timeout(MSECS_TO_JIFFIES(10));
+ schedule_timeout(msecs_to_jiffies(10));
/* Go back to normal mode */
sirdev_set_dtr_rts(dev, TRUE, TRUE);
set_current_state(TASK_UNINTERRUPTIBLE);
- schedule_timeout(MSECS_TO_JIFFIES(10));
+ schedule_timeout(msecs_to_jiffies(10));
dev->speed = 9600; /* That's the dongle-default */
--- linux/drivers/net/irda/ma600.c.msecs-to-jiffies 2004-04-03 22:37:06.000000000 -0500
+++ linux/drivers/net/irda/ma600.c 2004-05-07 15:30:19.000000000 -0400
@@ -184,7 +184,7 @@
if (self->speed_task && self->speed_task != task) {
IRDA_DEBUG(0, "%s(), busy!\n", __FUNCTION__);
- return MSECS_TO_JIFFIES(10);
+ return msecs_to_jiffies(10);
} else {
self->speed_task = task;
}
@@ -202,7 +202,7 @@
irda_task_next_state(task, IRDA_TASK_CHILD_WAIT);
/* give 1 second to finish */
- ret = MSECS_TO_JIFFIES(1000);
+ ret = msecs_to_jiffies(1000);
} else {
irda_task_next_state(task, IRDA_TASK_CHILD_DONE);
}
@@ -217,7 +217,7 @@
/* Set DTR, Clear RTS */
self->set_dtr_rts(self->dev, TRUE, FALSE);
- ret = MSECS_TO_JIFFIES(1); /* Sleep 1 ms */
+ ret = msecs_to_jiffies(1); /* Sleep 1 ms */
irda_task_next_state(task, IRDA_TASK_WAIT);
break;
@@ -231,7 +231,7 @@
irda_task_next_state(task, IRDA_TASK_WAIT1);
/* Wait at least 10 ms */
- ret = MSECS_TO_JIFFIES(15);
+ ret = msecs_to_jiffies(15);
break;
case IRDA_TASK_WAIT1:
@@ -258,7 +258,7 @@
irda_task_next_state(task, IRDA_TASK_WAIT2);
/* Wait at least 10 ms */
- ret = MSECS_TO_JIFFIES(10);
+ ret = msecs_to_jiffies(10);
break;
case IRDA_TASK_WAIT2:
@@ -298,7 +298,7 @@
if (self->reset_task && self->reset_task != task) {
IRDA_DEBUG(0, "%s(), busy!\n", __FUNCTION__);
- return MSECS_TO_JIFFIES(10);
+ return msecs_to_jiffies(10);
} else
self->reset_task = task;
@@ -307,13 +307,13 @@
/* Clear DTR and Set RTS */
self->set_dtr_rts(self->dev, FALSE, TRUE);
irda_task_next_state(task, IRDA_TASK_WAIT1);
- ret = MSECS_TO_JIFFIES(10); /* Sleep 10 ms */
+ ret = msecs_to_jiffies(10); /* Sleep 10 ms */
break;
case IRDA_TASK_WAIT1:
/* Set DTR and RTS */
self->set_dtr_rts(self->dev, TRUE, TRUE);
irda_task_next_state(task, IRDA_TASK_WAIT2);
- ret = MSECS_TO_JIFFIES(10); /* Sleep 10 ms */
+ ret = msecs_to_jiffies(10); /* Sleep 10 ms */
break;
case IRDA_TASK_WAIT2:
irda_task_next_state(task, IRDA_TASK_DONE);
--- linux/drivers/net/irda/mcp2120.c.msecs-to-jiffies 2004-04-03 22:38:20.000000000 -0500
+++ linux/drivers/net/irda/mcp2120.c 2004-05-07 15:30:19.000000000 -0400
@@ -99,7 +99,7 @@
irda_task_next_state(task, IRDA_TASK_CHILD_WAIT);
/* Give reset 1 sec to finish */
- ret = MSECS_TO_JIFFIES(1000);
+ ret = msecs_to_jiffies(1000);
}
break;
case IRDA_TASK_CHILD_WAIT:
@@ -140,7 +140,7 @@
self->write(self->dev, control, 2);
irda_task_next_state(task, IRDA_TASK_WAIT);
- ret = MSECS_TO_JIFFIES(100);
+ ret = msecs_to_jiffies(100);
//printk("mcp2120_change_speed irda_child_done\n");
break;
case IRDA_TASK_WAIT:
@@ -189,14 +189,14 @@
/* Reset dongle by setting RTS*/
self->set_dtr_rts(self->dev, TRUE, TRUE);
irda_task_next_state(task, IRDA_TASK_WAIT1);
- ret = MSECS_TO_JIFFIES(50);
+ ret = msecs_to_jiffies(50);
break;
case IRDA_TASK_WAIT1:
//printk("mcp2120_reset irda_task_wait1\n");
/* clear RTS and wait for at least 30 ms. */
self->set_dtr_rts(self->dev, FALSE, FALSE);
irda_task_next_state(task, IRDA_TASK_WAIT2);
- ret = MSECS_TO_JIFFIES(50);
+ ret = msecs_to_jiffies(50);
break;
case IRDA_TASK_WAIT2:
//printk("mcp2120_reset irda_task_wait2\n");
--- linux/drivers/net/irda/sir_dev.c.msecs-to-jiffies 2004-05-07 15:28:53.000000000 -0400
+++ linux/drivers/net/irda/sir_dev.c 2004-05-07 15:30:19.000000000 -0400
@@ -74,7 +74,7 @@
while (dev->tx_buff.len > 0) { /* wait until tx idle */
spin_unlock_irqrestore(&dev->tx_lock, flags);
set_current_state(TASK_UNINTERRUPTIBLE);
- schedule_timeout(MSECS_TO_JIFFIES(10));
+ schedule_timeout(msecs_to_jiffies(10));
spin_lock_irqsave(&dev->tx_lock, flags);
}
--- linux/drivers/net/irda/sir_kthread.c.msecs-to-jiffies 2004-05-07 15:28:53.000000000 -0400
+++ linux/drivers/net/irda/sir_kthread.c 2004-05-07 15:30:19.000000000 -0400
@@ -415,7 +415,7 @@
fsm->state = next_state;
} while(!delay);
- irda_queue_delayed_request(&fsm->rq, MSECS_TO_JIFFIES(delay));
+ irda_queue_delayed_request(&fsm->rq, msecs_to_jiffies(delay));
}
/* schedule some device configuration task for execution by kIrDAd
--- linux/drivers/net/irda/stir4200.c.msecs-to-jiffies 2004-05-07 15:28:53.000000000 -0400
+++ linux/drivers/net/irda/stir4200.c 2004-05-07 15:30:19.000000000 -0400
@@ -208,7 +208,7 @@
REQ_WRITE_SINGLE,
USB_DIR_OUT|USB_TYPE_VENDOR|USB_RECIP_DEVICE,
value, reg, NULL, 0,
- MSECS_TO_JIFFIES(CTRL_TIMEOUT));
+ msecs_to_jiffies(CTRL_TIMEOUT));
}
/* Send control message to read multiple registers */
@@ -221,7 +221,7 @@
REQ_READ_REG,
USB_DIR_IN | USB_TYPE_VENDOR | USB_RECIP_DEVICE,
0, reg, data, count,
- MSECS_TO_JIFFIES(CTRL_TIMEOUT));
+ msecs_to_jiffies(CTRL_TIMEOUT));
}
static inline int isfir(u32 speed)
@@ -745,7 +745,7 @@
if (usb_bulk_msg(stir->usbdev, usb_sndbulkpipe(stir->usbdev, 1),
stir->io_buf, wraplen,
- NULL, MSECS_TO_JIFFIES(TRANSMIT_TIMEOUT)))
+ NULL, msecs_to_jiffies(TRANSMIT_TIMEOUT)))
stir->stats.tx_errors++;
}
--- linux/drivers/net/irda/tekram-sir.c.msecs-to-jiffies 2004-04-03 22:36:52.000000000 -0500
+++ linux/drivers/net/irda/tekram-sir.c 2004-05-07 15:30:19.000000000 -0400
@@ -211,7 +211,7 @@
/* Should sleep 1 ms */
set_current_state(TASK_UNINTERRUPTIBLE);
- schedule_timeout(MSECS_TO_JIFFIES(1));
+ schedule_timeout(msecs_to_jiffies(1));
/* Set DTR, Set RTS */
sirdev_set_dtr_rts(dev, TRUE, TRUE);
--- linux/drivers/net/irda/tekram.c.msecs-to-jiffies 2004-04-03 22:37:23.000000000 -0500
+++ linux/drivers/net/irda/tekram.c 2004-05-07 15:30:19.000000000 -0400
@@ -113,7 +113,7 @@
if (self->speed_task && self->speed_task != task) {
IRDA_DEBUG(0, "%s(), busy!\n", __FUNCTION__ );
- return MSECS_TO_JIFFIES(10);
+ return msecs_to_jiffies(10);
} else
self->speed_task = task;
@@ -150,7 +150,7 @@
irda_task_next_state(task, IRDA_TASK_CHILD_WAIT);
/* Give reset 1 sec to finish */
- ret = MSECS_TO_JIFFIES(1000);
+ ret = msecs_to_jiffies(1000);
} else
irda_task_next_state(task, IRDA_TASK_CHILD_DONE);
break;
@@ -171,7 +171,7 @@
irda_task_next_state(task, IRDA_TASK_WAIT);
/* Wait at least 100 ms */
- ret = MSECS_TO_JIFFIES(150);
+ ret = msecs_to_jiffies(150);
break;
case IRDA_TASK_WAIT:
/* Set DTR, Set RTS */
@@ -214,7 +214,7 @@
if (self->reset_task && self->reset_task != task) {
IRDA_DEBUG(0, "%s(), busy!\n", __FUNCTION__ );
- return MSECS_TO_JIFFIES(10);
+ return msecs_to_jiffies(10);
} else
self->reset_task = task;
@@ -227,7 +227,7 @@
irda_task_next_state(task, IRDA_TASK_WAIT1);
/* Sleep 50 ms */
- ret = MSECS_TO_JIFFIES(50);
+ ret = msecs_to_jiffies(50);
break;
case IRDA_TASK_WAIT1:
/* Clear DTR, Set RTS */
@@ -236,7 +236,7 @@
irda_task_next_state(task, IRDA_TASK_WAIT2);
/* Should sleep 1 ms */
- ret = MSECS_TO_JIFFIES(1);
+ ret = msecs_to_jiffies(1);
break;
case IRDA_TASK_WAIT2:
/* Set DTR, Set RTS */
--- linux/drivers/char/watchdog/shwdt.c.msecs-to-jiffies 2004-04-03 22:36:54.000000000 -0500
+++ linux/drivers/char/watchdog/shwdt.c 2004-05-07 15:30:19.000000000 -0400
@@ -64,8 +64,7 @@
*/
static int clock_division_ratio = WTCSR_CKS_4096;
-#define msecs_to_jiffies(msecs) (jiffies + (HZ * msecs + 9999) / 10000)
-#define next_ping_period(cks) msecs_to_jiffies(cks - 4)
+#define next_ping_period(cks) (jiffies + msecs_to_jiffies(cks - 4))
static unsigned long shwdt_is_open;
static struct watchdog_info sh_wdt_info;
--- linux/drivers/block/carmel.c.msecs-to-jiffies 2004-04-03 22:37:38.000000000 -0500
+++ linux/drivers/block/carmel.c 2004-05-07 15:30:19.000000000 -0400
@@ -438,11 +438,6 @@
return -EOPNOTSUPP;
}
-static inline unsigned long msecs_to_jiffies(unsigned long msecs)
-{
- return ((HZ * msecs + 999) / 1000);
-}
-
static void msleep(unsigned long msecs)
{
set_current_state(TASK_UNINTERRUPTIBLE);
--- linux/drivers/block/genhd.c.msecs-to-jiffies 2004-04-03 22:37:06.000000000 -0500
+++ linux/drivers/block/genhd.c 2004-05-07 15:30:19.000000000 -0400
@@ -357,34 +357,24 @@
return sprintf(page, "%llu\n", (unsigned long long)get_capacity(disk));
}
-static inline unsigned jiffies_to_msec(unsigned jif)
-{
-#if 1000 % HZ == 0
- return jif * (1000 / HZ);
-#elif HZ % 1000 == 0
- return jif / (HZ / 1000);
-#else
- return (jif / HZ) * 1000 + (jif % HZ) * 1000 / HZ;
-#endif
-}
static ssize_t disk_stats_read(struct gendisk * disk, char *page)
{
disk_round_stats(disk);
return sprintf(page,
- "%8u %8u %8llu %8u "
- "%8u %8u %8llu %8u "
- "%8u %8u %8u"
+ "%8u %8u %8llu %8lu "
+ "%8u %8u %8llu %8lu "
+ "%8u %8lu %8lu"
"\n",
disk_stat_read(disk, reads), disk_stat_read(disk, read_merges),
(unsigned long long)disk_stat_read(disk, read_sectors),
- jiffies_to_msec(disk_stat_read(disk, read_ticks)),
+ jiffies_to_msecs(disk_stat_read(disk, read_ticks)),
disk_stat_read(disk, writes),
disk_stat_read(disk, write_merges),
(unsigned long long)disk_stat_read(disk, write_sectors),
- jiffies_to_msec(disk_stat_read(disk, write_ticks)),
+ jiffies_to_msecs(disk_stat_read(disk, write_ticks)),
disk->in_flight,
- jiffies_to_msec(disk_stat_read(disk, io_ticks)),
- jiffies_to_msec(disk_stat_read(disk, time_in_queue)));
+ jiffies_to_msecs(disk_stat_read(disk, io_ticks)),
+ jiffies_to_msecs(disk_stat_read(disk, time_in_queue)));
}
static struct disk_attribute disk_attr_dev = {
.attr = {.name = "dev", .mode = S_IRUGO },
@@ -494,17 +484,17 @@
*/
disk_round_stats(gp);
- seq_printf(s, "%4d %4d %s %u %u %llu %u %u %u %llu %u %u %u %u\n",
+ seq_printf(s, "%4d %4d %s %u %u %llu %lu %u %u %llu %lu %u %lu %lu\n",
gp->major, n + gp->first_minor, disk_name(gp, n, buf),
disk_stat_read(gp, reads), disk_stat_read(gp, read_merges),
(unsigned long long)disk_stat_read(gp, read_sectors),
- jiffies_to_msec(disk_stat_read(gp, read_ticks)),
+ jiffies_to_msecs(disk_stat_read(gp, read_ticks)),
disk_stat_read(gp, writes), disk_stat_read(gp, write_merges),
(unsigned long long)disk_stat_read(gp, write_sectors),
- jiffies_to_msec(disk_stat_read(gp, write_ticks)),
+ jiffies_to_msecs(disk_stat_read(gp, write_ticks)),
gp->in_flight,
- jiffies_to_msec(disk_stat_read(gp, io_ticks)),
- jiffies_to_msec(disk_stat_read(gp, time_in_queue)));
+ jiffies_to_msecs(disk_stat_read(gp, io_ticks)),
+ jiffies_to_msecs(disk_stat_read(gp, time_in_queue)));
/* now show all non-0 size partitions of it */
for (n = 0; n < gp->minors - 1; n++) {
--- linux/drivers/input/joydev.c.msecs-to-jiffies 2004-04-03 22:37:06.000000000 -0500
+++ linux/drivers/input/joydev.c 2004-05-07 15:30:19.000000000 -0400
@@ -37,8 +37,6 @@
#define JOYDEV_MINORS 16
#define JOYDEV_BUFFER_SIZE 64
-#define MSECS(t) (1000 * ((t) / HZ) + 1000 * ((t) % HZ) / HZ)
-
struct joydev {
int exist;
int open;
@@ -117,7 +115,7 @@
return;
}
- event.time = MSECS(jiffies);
+ event.time = jiffies_to_msecs(jiffies);
list_for_each_entry(list, &joydev->list, node) {
@@ -245,7 +243,7 @@
struct js_event event;
- event.time = MSECS(jiffies);
+ event.time = jiffies_to_msecs(jiffies);
if (list->startup < joydev->nkey) {
event.type = JS_EVENT_BUTTON | JS_EVENT_INIT;
--- linux/drivers/atm/fore200e.c.msecs-to-jiffies 2004-05-07 15:28:52.000000000 -0400
+++ linux/drivers/atm/fore200e.c 2004-05-07 15:30:19.000000000 -0400
@@ -95,9 +95,6 @@
#define FORE200E_NEXT_ENTRY(index, modulo) (index = ++(index) % (modulo))
-#define MSECS(ms) (((ms)*HZ/1000)+1)
-
-
#if 1
#define ASSERT(expr) if (!(expr)) { \
printk(FORE200E "assertion failed! %s[%d]: %s\n", \
@@ -244,7 +241,7 @@
static void
fore200e_spin(int msecs)
{
- unsigned long timeout = jiffies + MSECS(msecs);
+ unsigned long timeout = jiffies + msecs_to_jiffies(msecs);
while (time_before(jiffies, timeout));
}
@@ -252,7 +249,7 @@
static int
fore200e_poll(struct fore200e* fore200e, volatile u32* addr, u32 val, int msecs)
{
- unsigned long timeout = jiffies + MSECS(msecs);
+ unsigned long timeout = jiffies + msecs_to_jiffies(msecs);
int ok;
mb();
@@ -276,7 +273,7 @@
static int
fore200e_io_poll(struct fore200e* fore200e, volatile u32* addr, u32 val, int msecs)
{
- unsigned long timeout = jiffies + MSECS(msecs);
+ unsigned long timeout = jiffies + msecs_to_jiffies(msecs);
int ok;
do {
@@ -2597,7 +2594,7 @@
fore200e_monitor_getc(struct fore200e* fore200e)
{
struct cp_monitor* monitor = fore200e->cp_monitor;
- unsigned long timeout = jiffies + MSECS(50);
+ unsigned long timeout = jiffies + msecs_to_jiffies(50);
int c;
while (time_before(jiffies, timeout)) {
--- linux/include/linux/libata.h.msecs-to-jiffies 2004-05-07 15:28:55.000000000 -0400
+++ linux/include/linux/libata.h 2004-05-07 15:30:19.000000000 -0400
@@ -411,11 +411,6 @@
extern int ata_scsi_slave_config(struct scsi_device *sdev);
-static inline unsigned long msecs_to_jiffies(unsigned long msecs)
-{
- return ((HZ * msecs + 999) / 1000);
-}
-
static inline unsigned int ata_tag_valid(unsigned int tag)
{
return (tag < ATA_MAX_QUEUE) ? 1 : 0;
--- linux/include/net/irda/irda.h.msecs-to-jiffies 2004-04-03 22:36:55.000000000 -0500
+++ linux/include/net/irda/irda.h 2004-05-07 15:30:19.000000000 -0400
@@ -83,8 +83,6 @@
#define MESSAGE(args...) printk(KERN_INFO args)
#define ERROR(args...) printk(KERN_ERR args)
-#define MSECS_TO_JIFFIES(ms) (((ms)*HZ+999)/1000)
-
/*
* Magic numbers used by Linux-IrDA. Random numbers which must be unique to
* give the best protection
--- linux/include/net/sctp/sctp.h.msecs-to-jiffies 2004-05-07 15:28:55.000000000 -0400
+++ linux/include/net/sctp/sctp.h 2004-05-07 15:30:19.000000000 -0400
@@ -116,10 +116,6 @@
#define SCTP_STATIC static
#endif
-#define MSECS_TO_JIFFIES(msec) \
- (((msec / 1000) * HZ) + ((msec % 1000) * HZ) / 1000)
-#define JIFFIES_TO_MSECS(jiff) \
- (((jiff / HZ) * 1000) + ((jiff % HZ) * 1000) / HZ)
/*
* Function declarations.
--- linux/net/irda/ircomm/ircomm_tty.c.msecs-to-jiffies 2004-04-03 22:36:55.000000000 -0500
+++ linux/net/irda/ircomm/ircomm_tty.c 2004-05-07 15:30:19.000000000 -0400
@@ -873,7 +873,7 @@
orig_jiffies = jiffies;
/* Set poll time to 200 ms */
- poll_time = IRDA_MIN(timeout, MSECS_TO_JIFFIES(200));
+ poll_time = IRDA_MIN(timeout, msecs_to_jiffies(200));
spin_lock_irqsave(&self->spinlock, flags);
while (self->tx_skb && self->tx_skb->len) {
--- linux/net/irda/irlap_event.c.msecs-to-jiffies 2004-05-07 15:28:55.000000000 -0400
+++ linux/net/irda/irlap_event.c 2004-05-07 15:30:19.000000000 -0400
@@ -627,7 +627,7 @@
if (irda_device_is_receiving(self->netdev) && !self->add_wait) {
IRDA_DEBUG(2, "%s(), device is slow to answer, "
"waiting some more!\n", __FUNCTION__);
- irlap_start_slot_timer(self, MSECS_TO_JIFFIES(10));
+ irlap_start_slot_timer(self, msecs_to_jiffies(10));
self->add_wait = TRUE;
return ret;
}
@@ -849,7 +849,7 @@
* 1.5 times the time taken to transmit a SNRM frame. So this time should
* between 15 msecs and 45 msecs.
*/
- irlap_start_backoff_timer(self, MSECS_TO_JIFFIES(20 +
+ irlap_start_backoff_timer(self, msecs_to_jiffies(20 +
(jiffies % 30)));
} else {
/* Always switch state before calling upper layers */
@@ -1506,7 +1506,7 @@
if (irda_device_is_receiving(self->netdev) && !self->add_wait) {
IRDA_DEBUG(1, "FINAL_TIMER_EXPIRED when receiving a "
"frame! Waiting a little bit more!\n");
- irlap_start_final_timer(self, MSECS_TO_JIFFIES(300));
+ irlap_start_final_timer(self, msecs_to_jiffies(300));
/*
* Don't allow this to happen one more time in a row,
--- linux/net/sctp/associola.c.msecs-to-jiffies 2004-05-07 15:28:55.000000000 -0400
+++ linux/net/sctp/associola.c 2004-05-07 15:30:19.000000000 -0400
@@ -142,9 +142,9 @@
* socket values.
*/
asoc->max_retrans = sp->assocparams.sasoc_asocmaxrxt;
- asoc->rto_initial = MSECS_TO_JIFFIES(sp->rtoinfo.srto_initial);
- asoc->rto_max = MSECS_TO_JIFFIES(sp->rtoinfo.srto_max);
- asoc->rto_min = MSECS_TO_JIFFIES(sp->rtoinfo.srto_min);
+ asoc->rto_initial = msecs_to_jiffies(sp->rtoinfo.srto_initial);
+ asoc->rto_max = msecs_to_jiffies(sp->rtoinfo.srto_max);
+ asoc->rto_min = msecs_to_jiffies(sp->rtoinfo.srto_min);
asoc->overall_error_count = 0;
@@ -170,7 +170,7 @@
asoc->max_init_attempts = sp->initmsg.sinit_max_attempts;
asoc->max_init_timeo =
- MSECS_TO_JIFFIES(sp->initmsg.sinit_max_init_timeo);
+ msecs_to_jiffies(sp->initmsg.sinit_max_init_timeo);
/* Allocate storage for the ssnmap after the inbound and outbound
* streams have been negotiated during Init.
@@ -507,7 +507,7 @@
/* Initialize the peer's heartbeat interval based on the
* sock configured value.
*/
- peer->hb_interval = MSECS_TO_JIFFIES(sp->paddrparam.spp_hbinterval);
+ peer->hb_interval = msecs_to_jiffies(sp->paddrparam.spp_hbinterval);
/* Set the path max_retrans. */
peer->max_retrans = asoc->max_retrans;
--- linux/net/sctp/endpointola.c.msecs-to-jiffies 2004-04-03 22:36:24.000000000 -0500
+++ linux/net/sctp/endpointola.c 2004-05-07 15:30:19.000000000 -0400
@@ -129,7 +129,7 @@
ep->timeouts[SCTP_EVENT_TIMEOUT_T1_INIT] =
SCTP_DEFAULT_TIMEOUT_T1_INIT;
ep->timeouts[SCTP_EVENT_TIMEOUT_T2_SHUTDOWN] =
- MSECS_TO_JIFFIES(sp->rtoinfo.srto_initial);
+ msecs_to_jiffies(sp->rtoinfo.srto_initial);
ep->timeouts[SCTP_EVENT_TIMEOUT_T3_RTX] = 0;
ep->timeouts[SCTP_EVENT_TIMEOUT_T4_RTO] = 0;
@@ -138,7 +138,7 @@
* recommended value of 5 times 'RTO.Max'.
*/
ep->timeouts[SCTP_EVENT_TIMEOUT_T5_SHUTDOWN_GUARD]
- = 5 * MSECS_TO_JIFFIES(sp->rtoinfo.srto_max);
+ = 5 * msecs_to_jiffies(sp->rtoinfo.srto_max);
ep->timeouts[SCTP_EVENT_TIMEOUT_HEARTBEAT] =
SCTP_DEFAULT_TIMEOUT_HEARTBEAT;
--- linux/net/sctp/socket.c.msecs-to-jiffies 2004-05-07 15:28:55.000000000 -0400
+++ linux/net/sctp/socket.c 2004-05-07 15:30:19.000000000 -0400
@@ -1224,7 +1224,7 @@
}
if (sinit->sinit_max_init_timeo) {
asoc->max_init_timeo =
- MSECS_TO_JIFFIES(sinit->sinit_max_init_timeo);
+ msecs_to_jiffies(sinit->sinit_max_init_timeo);
}
}
@@ -1662,7 +1662,7 @@
if (params.spp_hbinterval) {
trans->hb_allowed = 1;
trans->hb_interval =
- MSECS_TO_JIFFIES(params.spp_hbinterval);
+ msecs_to_jiffies(params.spp_hbinterval);
} else
trans->hb_allowed = 0;
}
@@ -1835,11 +1835,11 @@
if (asoc) {
if (rtoinfo.srto_initial != 0)
asoc->rto_initial =
- MSECS_TO_JIFFIES(rtoinfo.srto_initial);
+ msecs_to_jiffies(rtoinfo.srto_initial);
if (rtoinfo.srto_max != 0)
- asoc->rto_max = MSECS_TO_JIFFIES(rtoinfo.srto_max);
+ asoc->rto_max = msecs_to_jiffies(rtoinfo.srto_max);
if (rtoinfo.srto_min != 0)
- asoc->rto_min = MSECS_TO_JIFFIES(rtoinfo.srto_min);
+ asoc->rto_min = msecs_to_jiffies(rtoinfo.srto_min);
} else {
/* If there is no association or the association-id = 0
* set the values to the endpoint.
@@ -2379,14 +2379,14 @@
sp->initmsg.sinit_num_ostreams = sctp_max_outstreams;
sp->initmsg.sinit_max_instreams = sctp_max_instreams;
sp->initmsg.sinit_max_attempts = sctp_max_retrans_init;
- sp->initmsg.sinit_max_init_timeo = JIFFIES_TO_MSECS(sctp_rto_max);
+ sp->initmsg.sinit_max_init_timeo = jiffies_to_msecs(sctp_rto_max);
/* Initialize default RTO related parameters. These parameters can
* be modified for with the SCTP_RTOINFO socket option.
*/
- sp->rtoinfo.srto_initial = JIFFIES_TO_MSECS(sctp_rto_initial);
- sp->rtoinfo.srto_max = JIFFIES_TO_MSECS(sctp_rto_max);
- sp->rtoinfo.srto_min = JIFFIES_TO_MSECS(sctp_rto_min);
+ sp->rtoinfo.srto_initial = jiffies_to_msecs(sctp_rto_initial);
+ sp->rtoinfo.srto_max = jiffies_to_msecs(sctp_rto_max);
+ sp->rtoinfo.srto_min = jiffies_to_msecs(sctp_rto_min);
/* Initialize default association related parameters. These parameters
* can be modified with the SCTP_ASSOCINFO socket option.
@@ -2396,7 +2396,7 @@
sp->assocparams.sasoc_peer_rwnd = 0;
sp->assocparams.sasoc_local_rwnd = 0;
sp->assocparams.sasoc_cookie_life =
- JIFFIES_TO_MSECS(sctp_valid_cookie_life);
+ jiffies_to_msecs(sctp_valid_cookie_life);
/* Initialize default event subscriptions. By default, all the
* options are off.
@@ -2406,7 +2406,7 @@
/* Default Peer Address Parameters. These defaults can
* be modified via SCTP_PEER_ADDR_PARAMS
*/
- sp->paddrparam.spp_hbinterval = JIFFIES_TO_MSECS(sctp_hb_interval);
+ sp->paddrparam.spp_hbinterval = jiffies_to_msecs(sctp_hb_interval);
sp->paddrparam.spp_pathmaxrxt = sctp_max_retrans_path;
/* If enabled no SCTP message fragmentation will be performed.
@@ -2552,7 +2552,7 @@
status.sstat_primary.spinfo_state = transport->active;
status.sstat_primary.spinfo_cwnd = transport->cwnd;
status.sstat_primary.spinfo_srtt = transport->srtt;
- status.sstat_primary.spinfo_rto = JIFFIES_TO_MSECS(transport->rto);
+ status.sstat_primary.spinfo_rto = jiffies_to_msecs(transport->rto);
status.sstat_primary.spinfo_mtu = transport->pmtu;
if (put_user(len, optlen)) {
@@ -2607,7 +2607,7 @@
pinfo.spinfo_state = transport->active;
pinfo.spinfo_cwnd = transport->cwnd;
pinfo.spinfo_srtt = transport->srtt;
- pinfo.spinfo_rto = JIFFIES_TO_MSECS(transport->rto);
+ pinfo.spinfo_rto = jiffies_to_msecs(transport->rto);
pinfo.spinfo_mtu = transport->pmtu;
if (put_user(len, optlen)) {
@@ -2811,7 +2811,7 @@
if (!trans->hb_allowed)
params.spp_hbinterval = 0;
else
- params.spp_hbinterval = JIFFIES_TO_MSECS(trans->hb_interval);
+ params.spp_hbinterval = jiffies_to_msecs(trans->hb_interval);
/* spp_pathmaxrxt contains the maximum number of retransmissions
* before this address shall be considered unreachable.
@@ -3168,9 +3168,9 @@
/* Values corresponding to the specific association. */
if (asoc) {
- rtoinfo.srto_initial = JIFFIES_TO_MSECS(asoc->rto_initial);
- rtoinfo.srto_max = JIFFIES_TO_MSECS(asoc->rto_max);
- rtoinfo.srto_min = JIFFIES_TO_MSECS(asoc->rto_min);
+ rtoinfo.srto_initial = jiffies_to_msecs(asoc->rto_initial);
+ rtoinfo.srto_max = jiffies_to_msecs(asoc->rto_max);
+ rtoinfo.srto_min = jiffies_to_msecs(asoc->rto_min);
} else {
/* Values corresponding to the endpoint. */
struct sctp_opt *sp = sctp_sk(sk);
--- linux/net/sctp/chunk.c.msecs-to-jiffies 2004-05-07 15:28:55.000000000 -0400
+++ linux/net/sctp/chunk.c 2004-05-07 15:31:51.000000000 -0400
@@ -186,7 +186,7 @@
if (sinfo->sinfo_timetolive) {
/* sinfo_timetolive is in milliseconds */
msg->expires_at = jiffies +
- MSECS_TO_JIFFIES(sinfo->sinfo_timetolive);
+ msecs_to_jiffies(sinfo->sinfo_timetolive);
msg->can_abandon = 1;
SCTP_DEBUG_PRINTK("%s: msg:%p expires_at: %ld jiffies:%ld\n",
__FUNCTION__, msg, msg->expires_at, jiffies);
^ permalink raw reply [flat|nested] 54+ messages in thread
* Re: MSEC_TO_JIFFIES is messed up...
2004-05-12 20:20 ` Andrew Morton
` (2 preceding siblings ...)
2004-05-12 20:38 ` William Lee Irwin III
@ 2004-05-12 20:55 ` Ingo Molnar
3 siblings, 0 replies; 54+ messages in thread
From: Ingo Molnar @ 2004-05-12 20:55 UTC (permalink / raw)
To: Andrew Morton; +Cc: davidel, jgarzik, greg, linux-kernel, netdev
* Andrew Morton <akpm@osdl.org> wrote:
> #if HZ=1000
> #define MSEC_TO_JIFFIES(msec) (msec)
> #define JIFFIES_TO_MESC(jiffies) (jiffies)
> #elif HZ=100
> #define MSEC_TO_JIFFIES(msec) (msec * 10)
> #define JIFFIES_TO_MESC(jiffies) (jiffies / 10)
> #else
> #define MSEC_TO_JIFFIES(msec) ((HZ * (msec) + 999) / 1000)
> #define JIFFIES_TO_MSEC(jiffies) ...
> #endif
the HZ=100 define is broken. (it's correct in the -A2 patch i just
sent.)
why the +999 rounding up in the generic case?
Ingo
^ permalink raw reply [flat|nested] 54+ messages in thread
* Re: MSEC_TO_JIFFIES is messed up...
2004-05-12 20:47 ` Andrew Morton
@ 2004-05-12 20:58 ` Jeff Garzik
2004-05-12 20:59 ` William Lee Irwin III
1 sibling, 0 replies; 54+ messages in thread
From: Jeff Garzik @ 2004-05-12 20:58 UTC (permalink / raw)
To: Andrew Morton
Cc: William Lee Irwin III, mingo, davidel, greg, linux-kernel, netdev
Andrew Morton wrote:
> @@ -187,7 +187,7 @@ static int act200l_change_speed(struct i
> /* Write control bytes */
> self->write(self->dev, control, 3);
> irda_task_next_state(task, IRDA_TASK_WAIT);
> - ret = MSECS_TO_JIFFIES(5);
> + ret = MSEC_TO_JIFFIES(5);
Ewww.
Just pluralize the macro, and this patch gets 75% lighter.
Jeff
^ permalink raw reply [flat|nested] 54+ messages in thread
* Re: MSEC_TO_JIFFIES is messed up...
2004-05-12 20:47 ` Andrew Morton
2004-05-12 20:58 ` Jeff Garzik
@ 2004-05-12 20:59 ` William Lee Irwin III
1 sibling, 0 replies; 54+ messages in thread
From: William Lee Irwin III @ 2004-05-12 20:59 UTC (permalink / raw)
To: Andrew Morton; +Cc: mingo, davidel, jgarzik, greg, linux-kernel, netdev
William Lee Irwin III <wli@holomorphy.com> wrote:
>> How about this?
>> #if HZ <= 1000 && !(1000 % HZ)
>> #define MSEC_TO_JIFFIES(m) ((1000/HZ)*(m))
>> #define JIFFIES_TO_MSEC(j) ((j)/(1000/HZ))
>> #elif HZ > 1000 && !(HZ % 1000)
>> #define MSEC_TO_JIFFIES(m) ((m)/(HZ/1000))
>> #define JIFFIES_TO_MSEC(j) ((HZ/1000)*(j))
>> #else
>> #define MSEC_TO_JIFFIES(m) ((HZ*(m) + 999)/1000)
>> #define JIFFIES_TO_MSEC(j) ((1000*(j) + HZ - 1)/HZ)
>> #endif
On Wed, May 12, 2004 at 01:47:18PM -0700, Andrew Morton wrote:
> You promise it's correct and generates good code?
Yes. Changelog:
Optimize the cases where HZ is a divisor of 1000 or vice-versa in
JIFFIES_TO_MSEC() and MSEC_TO_JIFFIES() by allowing the nonvanishing(!)
integral ratios to appear as a parenthesized expressions eligible for
constant folding optimizations.
I'll resend the #ifdef logic against Ingo's latest, which is orthogonal.
-- wli
^ permalink raw reply [flat|nested] 54+ messages in thread
* Re: MSEC_TO_JIFFIES is messed up...
2004-05-12 20:03 ` Ingo Molnar
2004-05-12 20:18 ` Valdis.Kletnieks
2004-05-12 20:20 ` Andrew Morton
@ 2004-05-12 21:01 ` Davide Libenzi
2004-05-12 21:12 ` Ingo Molnar
2004-05-12 21:39 ` J. Bruce Fields
2 siblings, 2 replies; 54+ messages in thread
From: Davide Libenzi @ 2004-05-12 21:01 UTC (permalink / raw)
To: Ingo Molnar
Cc: Davide Libenzi, Jeff Garzik, Greg KH, Andrew Morton,
Linux Kernel Mailing List, Netdev
On Wed, 12 May 2004, Ingo Molnar wrote:
>
> * Davide Libenzi <davidel@xmailserver.org> 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.
$ cat foo.c
int foo(int i) {
return i * 1000 / 1000;
}
$ gcc -S -c foo.c
$ cat foo.s
.file "foo.c"
.text
.globl foo
.type foo, @function
foo:
pushl %ebp
movl %esp, %ebp
movl 8(%ebp), %eax
leave
ret
.size foo, .-foo
.section .note.GNU-stack,"",@progbits
.ident "GCC: (GNU) 3.3.2 20031022 (Red Hat Linux 3.3.2-1)"
$ gcc -v
Reading specs from /usr/lib/gcc-lib/i386-redhat-linux/3.3.2/specs
Configured with: ../configure --prefix=/usr --mandir=/usr/share/man
--infodir=/usr/share/info --enable-shared --enable-threads=posix
--disable-checking --with-system-zlib --enable-__cxa_atexit
--host=i386-redhat-linux
Thread model: posix
gcc version 3.3.2 20031022 (Red Hat Linux 3.3.2-1)
- Davide
^ permalink raw reply [flat|nested] 54+ messages in thread
* Re: MSEC_TO_JIFFIES is messed up...
2004-05-12 20:50 ` Ingo Molnar
@ 2004-05-12 21:03 ` Valdis.Kletnieks
2004-05-12 21:33 ` Davide Libenzi
2004-05-12 21:07 ` Andrew Morton
1 sibling, 1 reply; 54+ messages in thread
From: Valdis.Kletnieks @ 2004-05-12 21:03 UTC (permalink / raw)
To: Ingo Molnar; +Cc: linux-kernel, Netdev
[-- Attachment #1: Type: text/plain, Size: 837 bytes --]
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.. :)
[-- Attachment #2: Type: application/pgp-signature, Size: 226 bytes --]
^ permalink raw reply [flat|nested] 54+ messages in thread
* Re: MSEC_TO_JIFFIES is messed up...
2004-05-12 20:35 ` Andrew Morton
2004-05-12 20:44 ` Jeff Garzik
@ 2004-05-12 21:03 ` Sridhar Samudrala
1 sibling, 0 replies; 54+ messages in thread
From: Sridhar Samudrala @ 2004-05-12 21:03 UTC (permalink / raw)
To: Andrew Morton; +Cc: Jeff Garzik, mingo, davidel, greg, linux-kernel, netdev
I have submitted a patch just to do this some time back on netdev mailing
list. You can find it at
http://marc.theaimsgroup.com/?l=linux-netdev&m=108024598716537&w=2
static inline unsigned long msecs_to_jiffies(unsigned long msecs)
{
#if 1000 % HZ == 0
return msecs / (1000 / HZ);
#elif HZ % 1000 == 0
return msecs * (HZ / 1000);
#else
return (msecs / 1000) * HZ + (msecs % 1000) * HZ / 1000;
#endif
}
static inline unsigned long jiffies_to_msecs(unsigned long jiffs)
{
#if 1000 % HZ == 0
return jiffs * (1000 / HZ);
#elif HZ % 1000 == 0
return jiffs / (HZ / 1000);
#else
return (jiffs / HZ) * 1000 + (jiffs % HZ) * 1000 / HZ;
#endif
}
I was told that some users of these routines need an explicit roundup of
delays.
For ex: when HZ=100 and msecs is less than 10, the above msecs_to_jiffies()
returns 0 jiffies, whereas some users expect 1 jiffy.
So i modified msecs_to_jiffies() as follows which should do proper rounding
when HZ=100. But didn't get back any response.
static inline unsigned long msecs_to_jiffies(unsigned long msecs)
{
#if 1000 % HZ == 0
return (msecs + ((1000 / HZ) - 1)) / (1000 / HZ);
#elif HZ % 1000 == 0
return msecs * (HZ / 1000);
#else
return (msecs / 1000) * HZ + (msecs % 1000) * HZ / 1000;
#endif
}
Thanks
Sridhar
On Wed, 12 May 2004, Andrew Morton wrote:
> Jeff Garzik <jgarzik@pobox.com> wrote:
> >
> > > How about we do:
> > >
> > > #if HZ=1000
> > > #define MSEC_TO_JIFFIES(msec) (msec)
> > > #define JIFFIES_TO_MESC(jiffies) (jiffies)
> > > #elif HZ=100
> > > #define MSEC_TO_JIFFIES(msec) (msec * 10)
> > > #define JIFFIES_TO_MESC(jiffies) (jiffies / 10)
> > > #else
> > > #define MSEC_TO_JIFFIES(msec) ((HZ * (msec) + 999) / 1000)
> > > #define JIFFIES_TO_MSEC(jiffies) ...
> > > #endif
> > >
> > > in some kernel-wide header then kill off all the private implementations?
> >
> >
> > include/linux/time.h. One of the SCTP people already did this, but I
> > suppose it's straightforward to reproduce.
>
> OK, I'll do it.
>
>
^ permalink raw reply [flat|nested] 54+ messages in thread
* Re: MSEC_TO_JIFFIES is messed up...
2004-05-12 20:50 ` Ingo Molnar
2004-05-12 21:03 ` Valdis.Kletnieks
@ 2004-05-12 21:07 ` Andrew Morton
2004-05-12 21:17 ` Ingo Molnar
1 sibling, 1 reply; 54+ messages in thread
From: Andrew Morton @ 2004-05-12 21:07 UTC (permalink / raw)
To: Ingo Molnar
Cc: Valdis.Kletnieks, davidel, jgarzik, greg, linux-kernel, netdev
Ingo Molnar <mingo@elte.hu> wrote:
>
> yet another patch - this time it's: complete, covers irda, accelerates
> HZ=100, unifies the slightly differing namespaces and compiles/boots as
> well.
>
> ...
>
> [hz-cleanup-2.6.6-A2 text/plain (2657 bytes)]
This doesn't have the little round up which some implementations had, so
someone who tries to sleep for 9 millisscondes on a 100HZ box may end up in
a busywait. Looks risky.
The SCTP version looks like it'll generate awful code, so let's not use
that.
^ permalink raw reply [flat|nested] 54+ messages in thread
* Re: MSEC_TO_JIFFIES is messed up...
2004-05-12 21:01 ` Davide Libenzi
@ 2004-05-12 21:12 ` Ingo Molnar
2004-05-12 21:40 ` Davide Libenzi
` (2 more replies)
2004-05-12 21:39 ` J. Bruce Fields
1 sibling, 3 replies; 54+ messages in thread
From: Ingo Molnar @ 2004-05-12 21:12 UTC (permalink / raw)
To: Davide Libenzi
Cc: Jeff Garzik, Greg KH, Andrew Morton, Linux Kernel Mailing List, Netdev
* Davide Libenzi <davidel@xmailserver.org> wrote:
> int foo(int i) {
>
>
> return i * 1000 / 1000;
> }
try unsigned and you'll see:
pushl %ebp
movl %esp, %ebp
movl 8(%ebp), %edx
movl %edx, %eax
sall $2, %eax
addl %edx, %eax
leal 0(,%eax,4), %edx
addl %edx, %eax
leal 0(,%eax,4), %edx
addl %edx, %eax
leal 0(,%eax,8), %edx
movl $274877907, %eax
mull %edx
movl %edx, %eax
shrl $6, %eax
leave
ret
Ingo
^ permalink raw reply [flat|nested] 54+ messages in thread
* Re: MSEC_TO_JIFFIES is messed up...
2004-05-12 21:07 ` Andrew Morton
@ 2004-05-12 21:17 ` Ingo Molnar
2004-05-12 22:18 ` William Lee Irwin III
0 siblings, 1 reply; 54+ messages in thread
From: Ingo Molnar @ 2004-05-12 21:17 UTC (permalink / raw)
To: Andrew Morton
Cc: Valdis.Kletnieks, davidel, jgarzik, greg, linux-kernel, netdev
[-- Attachment #1: Type: text/plain, Size: 629 bytes --]
* Andrew Morton <akpm@osdl.org> wrote:
> Ingo Molnar <mingo@elte.hu> wrote:
> >
> > yet another patch - this time it's: complete, covers irda, accelerates
> > HZ=100, unifies the slightly differing namespaces and compiles/boots as
> > well.
> >
> > ...
> >
> > [hz-cleanup-2.6.6-A2 text/plain (2657 bytes)]
>
> This doesn't have the little round up which some implementations had,
> so someone who tries to sleep for 9 millisscondes on a 100HZ box may
> end up in a busywait. Looks risky.
ok. -A3 attached, it does the roundup in the msec->jiffies conversion.
(not the other way around though, and that's fine.)
Ingo
[-- Attachment #2: hz-cleanup-2.6.6-A3 --]
[-- Type: text/plain, Size: 2564 bytes --]
--- 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) + 9) / 10)
+#else
+# define JIFFIES_TO_MSECS(x) (((x) * 1000) / HZ)
+# define MSECS_TO_JIFFIES(x) (((x) * HZ + 999) / 1000)
+#endif
+
/*
* The TICK_NSEC - 1 rounds up the value to the next resolution. Note
* that a remainder subtract here would not do the right thing as the
--- linux/include/net/irda/irda.h.orig
+++ linux/include/net/irda/irda.h
@@ -83,8 +83,6 @@ if(!(expr)) do { \
#define MESSAGE(args...) printk(KERN_INFO args)
#define ERROR(args...) printk(KERN_ERR args)
-#define MSECS_TO_JIFFIES(ms) (((ms)*HZ+999)/1000)
-
/*
* Magic numbers used by Linux-IrDA. Random numbers which must be unique to
* give the best protection
--- linux/include/net/sctp/sctp.h.orig
+++ linux/include/net/sctp/sctp.h
@@ -116,11 +116,6 @@
#define SCTP_STATIC static
#endif
-#define MSECS_TO_JIFFIES(msec) \
- (((msec / 1000) * HZ) + ((msec % 1000) * HZ) / 1000)
-#define JIFFIES_TO_MSECS(jiff) \
- (((jiff / HZ) * 1000) + ((jiff % HZ) * 1000) / HZ)
-
/*
* Function declarations.
*/
--- linux/include/asm-i386/param.h.orig
+++ linux/include/asm-i386/param.h
@@ -5,8 +5,6 @@
# define HZ 1000 /* Internal kernel timer frequency */
# define USER_HZ 100 /* .. some user interfaces are in "ticks" */
# define CLOCKS_PER_SEC (USER_HZ) /* like times() */
-# define JIFFIES_TO_MSEC(x) (x)
-# define MSEC_TO_JIFFIES(x) (x)
#endif
#ifndef HZ
--- linux/kernel/sched.c.orig
+++ linux/kernel/sched.c
@@ -75,13 +75,6 @@
#define NS_TO_JIFFIES(TIME) ((TIME) / (1000000000 / HZ))
#define JIFFIES_TO_NS(TIME) ((TIME) * (1000000000 / HZ))
-#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
-
/*
* These are the 'tuning knobs' of the scheduler:
*
@@ -1880,7 +1873,7 @@ static void rebalance_tick(int this_cpu,
interval *= sd->busy_factor;
/* scale ms to jiffies */
- interval = MSEC_TO_JIFFIES(interval);
+ interval = MSECS_TO_JIFFIES(interval);
if (unlikely(!interval))
interval = 1;
^ permalink raw reply [flat|nested] 54+ messages in thread
* Re: MSEC_TO_JIFFIES is messed up...
2004-05-12 21:03 ` Valdis.Kletnieks
@ 2004-05-12 21:33 ` Davide Libenzi
0 siblings, 0 replies; 54+ messages in thread
From: Davide Libenzi @ 2004-05-12 21:33 UTC (permalink / raw)
To: Valdis.Kletnieks; +Cc: Ingo Molnar, Linux Kernel Mailing List, Netdev
On Wed, 12 May 2004 Valdis.Kletnieks@vt.edu wrote:
> 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.. :)
Guys, why don't you leave the compiler to do its job?
- Davide
^ permalink raw reply [flat|nested] 54+ messages in thread
* Re: MSEC_TO_JIFFIES is messed up...
2004-05-12 21:01 ` Davide Libenzi
2004-05-12 21:12 ` Ingo Molnar
@ 2004-05-12 21:39 ` J. Bruce Fields
2004-05-12 21:55 ` Andreas Schwab
1 sibling, 1 reply; 54+ messages in thread
From: J. Bruce Fields @ 2004-05-12 21:39 UTC (permalink / raw)
To: Davide Libenzi
Cc: Ingo Molnar, Jeff Garzik, Greg KH, Andrew Morton,
Linux Kernel Mailing List, Netdev
On Wed, May 12, 2004 at 02:01:58PM -0700, Davide Libenzi wrote:
> On Wed, 12 May 2004, Ingo Molnar wrote:
> > the compiler cannot discard the multiplication and the division from the
> > following:
> >
> > x * 1000 / 1000
> >
> > due to overflows.
>
> $ cat foo.c
>
> int foo(int i) {
>
>
> return i * 1000 / 1000;
> }
If gcc really optimizes that to just the identity function, then surely
that's a gcc bug? Multiplication is left-associative, so i * 1000 /
1000 = (i * 1000) / 1000, but (i * 1000) should be zero for any i
divisible by i^(sizeof(int) - 12).
It shouldn't be able to optimize out the 1000 here for exactly the same
reason it shouldn't be able to optimize out the shifts in, e.g.,
i << 12 >> 12
--Bruce Fields
^ permalink raw reply [flat|nested] 54+ messages in thread
* Re: MSEC_TO_JIFFIES is messed up...
2004-05-12 21:12 ` Ingo Molnar
@ 2004-05-12 21:40 ` Davide Libenzi
2004-05-12 21:49 ` Zan Lynx
2004-05-12 21:56 ` Zan Lynx
2 siblings, 0 replies; 54+ messages in thread
From: Davide Libenzi @ 2004-05-12 21:40 UTC (permalink / raw)
To: Ingo Molnar
Cc: Jeff Garzik, Greg KH, Andrew Morton, Linux Kernel Mailing List, Netdev
On Wed, 12 May 2004, Ingo Molnar wrote:
>
> * Davide Libenzi <davidel@xmailserver.org> wrote:
>
> > int foo(int i) {
> >
> >
> > return i * 1000 / 1000;
> > }
>
> try unsigned and you'll see:
>
> pushl %ebp
> movl %esp, %ebp
> movl 8(%ebp), %edx
> movl %edx, %eax
> sall $2, %eax
> addl %edx, %eax
> leal 0(,%eax,4), %edx
> addl %edx, %eax
> leal 0(,%eax,4), %edx
> addl %edx, %eax
> leal 0(,%eax,8), %edx
> movl $274877907, %eax
> mull %edx
> movl %edx, %eax
> shrl $6, %eax
> leave
> ret
Yeah, I see.
- Davide
^ permalink raw reply [flat|nested] 54+ messages in thread
* Re: MSEC_TO_JIFFIES is messed up...
2004-05-12 21:12 ` Ingo Molnar
2004-05-12 21:40 ` Davide Libenzi
@ 2004-05-12 21:49 ` Zan Lynx
2004-05-12 22:05 ` Roland Dreier
2004-05-12 21:56 ` Zan Lynx
2 siblings, 1 reply; 54+ messages in thread
From: Zan Lynx @ 2004-05-12 21:49 UTC (permalink / raw)
To: Ingo Molnar
Cc: Davide Libenzi, Jeff Garzik, Greg KH, Andrew Morton,
Linux Kernel Mailing List, Netdev
[-- Attachment #1: Type: text/plain, Size: 1177 bytes --]
On Wed, 2004-05-12 at 15:12, Ingo Molnar wrote:
> * Davide Libenzi <davidel@xmailserver.org> wrote:
>
> > int foo(int i) {
> >
> >
> > return i * 1000 / 1000;
> > }
>
> try unsigned and you'll see:
>
> pushl %ebp
> movl %esp, %ebp
> movl 8(%ebp), %edx
> movl %edx, %eax
> sall $2, %eax
> addl %edx, %eax
> leal 0(,%eax,4), %edx
> addl %edx, %eax
> leal 0(,%eax,4), %edx
> addl %edx, %eax
> leal 0(,%eax,8), %edx
> movl $274877907, %eax
> mull %edx
> movl %edx, %eax
> shrl $6, %eax
> leave
> ret
>
> Ingo
Being curious, I tried that and got the same results. But this:
int f(unsigned int x)
{
return x * (1000 / 1000);
}
creates this:
f:
pushl %ebp
movl %esp, %ebp
movl 8(%ebp), %eax
leave
ret
.size f, .-f
.section .note.GNU-stack,"",@progbits
.ident "GCC: (GNU) 3.3.2 20031022 (Red Hat Linux 3.3.2-1)"
--
Zan Lynx <zlynx@acm.org>
[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 189 bytes --]
^ permalink raw reply [flat|nested] 54+ messages in thread
* Re: MSEC_TO_JIFFIES is messed up...
2004-05-12 21:39 ` J. Bruce Fields
@ 2004-05-12 21:55 ` Andreas Schwab
2004-05-12 22:07 ` J. Bruce Fields
2004-05-16 3:48 ` Chris Wedgwood
0 siblings, 2 replies; 54+ messages in thread
From: Andreas Schwab @ 2004-05-12 21:55 UTC (permalink / raw)
To: J. Bruce Fields
Cc: Davide Libenzi, Ingo Molnar, Jeff Garzik, Greg KH, Andrew Morton,
Linux Kernel Mailing List, Netdev
"J. Bruce Fields" <bfields@fieldses.org> writes:
> If gcc really optimizes that to just the identity function, then surely
> that's a gcc bug? Multiplication is left-associative, so i * 1000 /
> 1000 = (i * 1000) / 1000, but (i * 1000) should be zero for any i
> divisible by i^(sizeof(int) - 12).
Signed integer overflow is undefined in C, so the compiler is allowed to
assume it does not happen.
Andreas.
--
Andreas Schwab, SuSE Labs, schwab@suse.de
SuSE Linux AG, Maxfeldstraße 5, 90409 Nürnberg, Germany
Key fingerprint = 58CA 54C7 6D53 942B 1756 01D3 44D5 214B 8276 4ED5
"And now for something completely different."
^ permalink raw reply [flat|nested] 54+ messages in thread
* Re: MSEC_TO_JIFFIES is messed up...
2004-05-12 21:12 ` Ingo Molnar
2004-05-12 21:40 ` Davide Libenzi
2004-05-12 21:49 ` Zan Lynx
@ 2004-05-12 21:56 ` Zan Lynx
2 siblings, 0 replies; 54+ messages in thread
From: Zan Lynx @ 2004-05-12 21:56 UTC (permalink / raw)
To: Ingo Molnar
Cc: Davide Libenzi, Jeff Garzik, Greg KH, Andrew Morton,
Linux Kernel Mailing List, Netdev
[-- Attachment #1: Type: text/plain, Size: 380 bytes --]
On Wed, 2004-05-12 at 15:12, Ingo Molnar wrote:
> * Davide Libenzi <davidel@xmailserver.org> wrote:
>
> > int foo(int i) {
> >
> >
> > return i * 1000 / 1000;
> > }
>
> try unsigned and you'll see:
[snip]
I forgot to add that yes I know i * (x / 1000) is different than i * x /
1000 in integer math. Please don't hit me.
--
Zan Lynx <zlynx@acm.org>
[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 189 bytes --]
^ permalink raw reply [flat|nested] 54+ messages in thread
* Re: MSEC_TO_JIFFIES is messed up...
2004-05-12 21:49 ` Zan Lynx
@ 2004-05-12 22:05 ` Roland Dreier
0 siblings, 0 replies; 54+ messages in thread
From: Roland Dreier @ 2004-05-12 22:05 UTC (permalink / raw)
To: Zan Lynx
Cc: Ingo Molnar, Davide Libenzi, Jeff Garzik, Greg KH, Andrew Morton,
Linux Kernel Mailing List, Netdev
> Being curious, I tried that and got the same results. But this:
>
> int f(unsigned int x)
> {
> return x * (1000 / 1000);
> }
>
> creates this:
> f:
> pushl %ebp
> movl %esp, %ebp
> movl 8(%ebp), %eax
> leave
> ret
Of course the compiler can optimize (1000 / 1000) into 1 at compile
time. However, the original code was doing something like
x * HZ / 1000
if you change that to
x * (HZ / 1000)
then obviously that breaks if HZ is not a multiple of 1000.
- Roland
^ permalink raw reply [flat|nested] 54+ messages in thread
* Re: MSEC_TO_JIFFIES is messed up...
2004-05-12 21:55 ` Andreas Schwab
@ 2004-05-12 22:07 ` J. Bruce Fields
2004-05-16 3:48 ` Chris Wedgwood
1 sibling, 0 replies; 54+ messages in thread
From: J. Bruce Fields @ 2004-05-12 22:07 UTC (permalink / raw)
To: Andreas Schwab
Cc: Davide Libenzi, Ingo Molnar, Jeff Garzik, Greg KH, Andrew Morton,
Linux Kernel Mailing List, Netdev
On Wed, May 12, 2004 at 11:55:18PM +0200, Andreas Schwab wrote:
> "J. Bruce Fields" <bfields@fieldses.org> writes:
>
> > If gcc really optimizes that to just the identity function, then surely
> > that's a gcc bug? Multiplication is left-associative, so i * 1000 /
> > 1000 = (i * 1000) / 1000, but (i * 1000) should be zero for any i
> > divisible by i^(sizeof(int) - 12).
>
> Signed integer overflow is undefined in C, so the compiler is allowed to
> assume it does not happen.
Ugh, right, got it.--b.
^ permalink raw reply [flat|nested] 54+ messages in thread
* Re: MSEC_TO_JIFFIES is messed up...
2004-05-12 21:17 ` Ingo Molnar
@ 2004-05-12 22:18 ` William Lee Irwin III
2004-05-13 17:38 ` Paul Wagland
0 siblings, 1 reply; 54+ messages in thread
From: William Lee Irwin III @ 2004-05-12 22:18 UTC (permalink / raw)
To: Ingo Molnar
Cc: Andrew Morton, Valdis.Kletnieks, davidel, jgarzik, greg,
linux-kernel, netdev
On Wed, May 12, 2004 at 11:17:48PM +0200, Ingo Molnar wrote:
> ok. -A3 attached, it does the roundup in the msec->jiffies conversion.
> (not the other way around though, and that's fine.)
I'm assuming -A3 is current, then:
Optimize the cases where HZ is a divisor of 1000 or vice-versa in
JIFFIES_TO_MSECS() and MSECS_TO_JIFFIES() by allowing the nonvanishing(!)
integral ratios to appear as a parenthesized expressions eligible for
constant folding optimizations.
-- wli
Index: linux-2.5/include/linux/time.h
===================================================================
--- linux-2.5.orig/include/linux/time.h 2004-05-12 15:04:10.000000000 -0700
+++ linux-2.5/include/linux/time.h 2004-05-12 15:12:49.000000000 -0700
@@ -184,12 +184,12 @@
* 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) + 9) / 10)
+#if HZ <= 1000 && !(1000 % HZ)
+# define JIFFIES_TO_MSECS(j) ((1000/HZ)*(j))
+# define MSECS_TO_JIFFIES(m) (((m) + (1000/HZ) - 1)/(1000/HZ))
+#elif HZ > 1000 && !(HZ % 1000)
+# define JIFFIES_TO_MSECS(j) (((j) + (HZ/1000) - 1)/(HZ/1000))
+# define MSECS_TO_JIFFIES(m) ((m)*(HZ/1000))
#else
# define JIFFIES_TO_MSECS(x) (((x) * 1000) / HZ)
# define MSECS_TO_JIFFIES(x) (((x) * HZ + 999) / 1000)
^ permalink raw reply [flat|nested] 54+ messages in thread
* Re: MSEC_TO_JIFFIES is messed up...
2004-05-12 20:54 ` Bill Rugolsky Jr.
@ 2004-05-12 22:44 ` Bill Rugolsky Jr.
0 siblings, 0 replies; 54+ messages in thread
From: Bill Rugolsky Jr. @ 2004-05-12 22:44 UTC (permalink / raw)
To: Jeff Garzik
Cc: Greg KH, Andrew Morton, mingo, linux-kernel, Netdev,
Sridhar Samudrala, davem, George Anzinger
On Wed, May 12, 2004 at 04:54:07PM -0400, Bill Rugolsky Jr. wrote:
> The attached patch combines Sridhar's consolidation patch with my
> more accurate routines in the spirit of the rest of time.h. It is against
> 2.6.6-rc3-bk3. Feedback welcome. I'm happy to rediff against latest kernel,
> I just haven't had time the last few days.
Sorry to reply to myself, but please ignore the patch that I sent;
upon reflection, the 64-bit logic is (still) wrong.
Bill Rugolsky
^ permalink raw reply [flat|nested] 54+ messages in thread
* Re: MSEC_TO_JIFFIES is messed up...
2004-05-12 19:56 ` Davide Libenzi
2004-05-12 20:07 ` Valdis.Kletnieks
@ 2004-05-12 23:33 ` Peter Williams
1 sibling, 0 replies; 54+ messages in thread
From: Peter Williams @ 2004-05-12 23:33 UTC (permalink / raw)
To: Davide Libenzi
Cc: Valdis.Kletnieks, Andrew Morton, Netdev, Greg KH, Ingo Molnar,
Jeff Garzik, linux-kernel
Davide Libenzi wrote:
> On Wed, 12 May 2004 Valdis.Kletnieks@vt.edu wrote:
>
>
>>On Wed, 12 May 2004 21:33:49 +0200, Ingo Molnar said:
>>
>>>* Jeff Garzik <jgarzik@pobox.com> wrote:
>>>
>>>
>>>>>Woah, that's new. And wrong. The code in include/asm-i386/param.h that
>>>>>says:
>>>>> # define JIFFIES_TO_MSEC(x) (x)
>>>>> # define MSEC_TO_JIFFIES(x) (x)
>>>>>
>>>>>Is not correct. Look at kernel/sched.c for verification of this :)
>>>>
>>>>
>>>>Yes, that is _massively_ broken.
>>>
>>>why is it wrong?
>>
>>If the kernel jiffie is anything other than exactly 1 msec, you're screwed...
>
>
> I believe they were talking about include/asm-i386/param.h
> ^^^^^^^^
There's sometimes a need to change HZ on i386 systems. Specifically,
some IDE drives are unable to safely use DMA (this is documented in one
of the Kconfig files). Without DMA for the IDE drives many systems
experience (a lot of) missed interrupts which can lead to (among other
things) lost ticks and very erratic and unpredictable behaviour from
input devices such as the mouse.
Also, if defined in terms of HZ only one definition of these macros
would be required rather than one for each architecture.
Peter
--
Dr Peter Williams, Chief Scientist peterw@aurema.com
Aurema Pty Limited Tel:+61 2 9698 2322
PO Box 305, Strawberry Hills NSW 2012, Australia Fax:+61 2 9699 9174
79 Myrtle Street, Chippendale NSW 2008, Australia http://www.aurema.com
^ permalink raw reply [flat|nested] 54+ messages in thread
* Re: MSEC_TO_JIFFIES is messed up...
2004-05-12 22:18 ` William Lee Irwin III
@ 2004-05-13 17:38 ` Paul Wagland
2004-05-13 19:11 ` Andrew Morton
0 siblings, 1 reply; 54+ messages in thread
From: Paul Wagland @ 2004-05-13 17:38 UTC (permalink / raw)
To: William Lee Irwin III
Cc: greg, linux-kernel, jgarzik, Ingo Molnar, netdev, davidel,
Valdis.Kletnieks, Andrew Morton
[-- Attachment #1: Type: text/plain, Size: 1851 bytes --]
Nit pick I'm sure... but....
On May 13, 2004, at 0:18, William Lee Irwin III wrote:
> Optimize the cases where HZ is a divisor of 1000 or vice-versa in
> JIFFIES_TO_MSECS() and MSECS_TO_JIFFIES() by allowing the
> nonvanishing(!)
> integral ratios to appear as a parenthesized expressions eligible for
> constant folding optimizations.
>
>
> -- wli
>
>
> Index: linux-2.5/include/linux/time.h
> ===================================================================
> --- linux-2.5.orig/include/linux/time.h 2004-05-12 15:04:10.000000000
> -0700
> +++ linux-2.5/include/linux/time.h 2004-05-12 15:12:49.000000000 -0700
> @@ -184,12 +184,12 @@
> * 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) + 9) / 10)
> +#if HZ <= 1000 && !(1000 % HZ)
> +# define JIFFIES_TO_MSECS(j) ((1000/HZ)*(j))
> +# define MSECS_TO_JIFFIES(m) (((m) + (1000/HZ) - 1)/(1000/HZ))
> +#elif HZ > 1000 && !(HZ % 1000)
> +# define JIFFIES_TO_MSECS(j) (((j) + (HZ/1000) - 1)/(HZ/1000))
> +# define MSECS_TO_JIFFIES(m) ((m)*(HZ/1000))
> #else
> # define JIFFIES_TO_MSECS(x) (((x) * 1000) / HZ)
> # define MSECS_TO_JIFFIES(x) (((x) * HZ + 999) / 1000)
Also, can we keep the same parameter name across all of the macros?
This changes behaviour when HZ==(z)000
JIFFIES_TO_MSECS goes from
((x) * 1000) / (z)000 to (((x) + (z) - 1)/(z))
i.e. for x=1, z=2 this goes from ((1)*1000)/2000)=0 to (((1)+(2)-1)/2)=1
However, MSECS_TO_JIFFIES remains the same going from
(((x) * (z)000 + 999) / 1000) to ((x)*(z))
I.e. they basically reduce down to the same thing (modulo overflows)
All of the other permuations look correct to me...
Cheers,
Paul
[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 186 bytes --]
^ permalink raw reply [flat|nested] 54+ messages in thread
* Re: MSEC_TO_JIFFIES is messed up...
2004-05-13 17:38 ` Paul Wagland
@ 2004-05-13 19:11 ` Andrew Morton
2004-05-13 19:19 ` Jeff Garzik
2004-05-13 19:50 ` Paul Wagland
0 siblings, 2 replies; 54+ messages in thread
From: Andrew Morton @ 2004-05-13 19:11 UTC (permalink / raw)
To: Paul Wagland
Cc: wli, greg, linux-kernel, jgarzik, mingo, netdev, davidel,
Valdis.Kletnieks
Paul Wagland <paul@wagland.net> wrote:
>
> > -#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) + 9) / 10)
> > +#if HZ <= 1000 && !(1000 % HZ)
> > +# define JIFFIES_TO_MSECS(j) ((1000/HZ)*(j))
> > +# define MSECS_TO_JIFFIES(m) (((m) + (1000/HZ) - 1)/(1000/HZ))
> > +#elif HZ > 1000 && !(HZ % 1000)
> > +# define JIFFIES_TO_MSECS(j) (((j) + (HZ/1000) - 1)/(HZ/1000))
> > +# define MSECS_TO_JIFFIES(m) ((m)*(HZ/1000))
> > #else
> > # define JIFFIES_TO_MSECS(x) (((x) * 1000) / HZ)
> > # define MSECS_TO_JIFFIES(x) (((x) * HZ + 999) / 1000)
>
> Also, can we keep the same parameter name across all of the macros?
Fair enough.
--- 25/include/linux/time.h~MSEC_TO_JIFFIES-fixups-tidy 2004-05-13 12:09:27.463273344 -0700
+++ 25-akpm/include/linux/time.h 2004-05-13 12:09:41.300169816 -0700
@@ -191,8 +191,8 @@ struct timezone {
# define JIFFIES_TO_MSECS(j) (((j) + (HZ/1000) - 1)/(HZ/1000))
# define MSECS_TO_JIFFIES(m) ((m)*(HZ/1000))
#else
-# define JIFFIES_TO_MSECS(x) (((x) * 1000) / HZ)
-# define MSECS_TO_JIFFIES(x) (((x) * HZ + 999) / 1000)
+# define JIFFIES_TO_MSECS(j) (((j) * 1000) / HZ)
+# define MSECS_TO_JIFFIES(m) (((m) * HZ + 999) / 1000)
#endif
/*
> This changes behaviour when HZ==(z)000
>
> JIFFIES_TO_MSECS goes from
> ((x) * 1000) / (z)000 to (((x) + (z) - 1)/(z))
>
> i.e. for x=1, z=2 this goes from ((1)*1000)/2000)=0 to (((1)+(2)-1)/2)=1
hm, so you're saying that we now round 0.5 up to 1 rather than down to zero?
> However, MSECS_TO_JIFFIES remains the same going from
> (((x) * (z)000 + 999) / 1000) to ((x)*(z))
>
> I.e. they basically reduce down to the same thing (modulo overflows)
>
> All of the other permuations look correct to me...
^ permalink raw reply [flat|nested] 54+ messages in thread
* Re: MSEC_TO_JIFFIES is messed up...
2004-05-13 19:11 ` Andrew Morton
@ 2004-05-13 19:19 ` Jeff Garzik
2004-05-13 22:40 ` Andrew Morton
2004-05-13 19:50 ` Paul Wagland
1 sibling, 1 reply; 54+ messages in thread
From: Jeff Garzik @ 2004-05-13 19:19 UTC (permalink / raw)
To: Andrew Morton, Paul Wagland, mingo
Cc: wli, greg, linux-kernel, netdev, davidel, Valdis.Kletnieks
For whomever winds up doing this work, I have two requests:
* use a type-safe inline rather than purely a macro, as some drivers do
* replace msecs_to_jiffies() occurrences as well as MSECS_TO_JIFFIES()
(and ditto for jiffies_to_msecs)
^ permalink raw reply [flat|nested] 54+ messages in thread
* Re: MSEC_TO_JIFFIES is messed up...
2004-05-13 19:11 ` Andrew Morton
2004-05-13 19:19 ` Jeff Garzik
@ 2004-05-13 19:50 ` Paul Wagland
1 sibling, 0 replies; 54+ messages in thread
From: Paul Wagland @ 2004-05-13 19:50 UTC (permalink / raw)
To: Andrew Morton
Cc: greg, linux-kernel, mingo, jgarzik, netdev, wli, davidel,
Valdis.Kletnieks
[-- Attachment #1: Type: text/plain, Size: 818 bytes --]
On May 13, 2004, at 21:11, Andrew Morton wrote:
> Paul Wagland <paul@wagland.net> wrote:
>> This changes behaviour when HZ==(z)000
>>
>> JIFFIES_TO_MSECS goes from
>> ((x) * 1000) / (z)000 to (((x) + (z) - 1)/(z))
>>
>> i.e. for x=1, z=2 this goes from ((1)*1000)/2000)=0 to
>> (((1)+(2)-1)/2)=1
>
> hm, so you're saying that we now round 0.5 up to 1 rather than down to
> zero?
More precisely, we round .x up, where before it was rounded down, but
yeah, _and_ only when HZ is a multiple of 1000, and greater than 1000.
This is also only the case for the patch as proposed by wli, currently
I don't know of any architectures that have a HZ of 2000 or more... but
I just note that it _is_ a behaviour change in those cases, whether or
not it is important is for other people to decide :-)
Cheers,
Paul
[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 186 bytes --]
^ permalink raw reply [flat|nested] 54+ messages in thread
* Re: MSEC_TO_JIFFIES is messed up...
2004-05-13 19:19 ` Jeff Garzik
@ 2004-05-13 22:40 ` Andrew Morton
2004-05-13 22:40 ` Andrew Morton
0 siblings, 1 reply; 54+ messages in thread
From: Andrew Morton @ 2004-05-13 22:40 UTC (permalink / raw)
To: Jeff Garzik
Cc: paul, mingo, wli, greg, linux-kernel, netdev, davidel, Valdis.Kletnieks
Jeff Garzik <jgarzik@pobox.com> wrote:
>
> For whomever winds up doing this work, I have two requests:
>
> * use a type-safe inline rather than purely a macro, as some drivers do
> * replace msecs_to_jiffies() occurrences as well as MSECS_TO_JIFFIES()
> (and ditto for jiffies_to_msecs)
Use typesafe inlines for the jiffies-to-millisecond conversion functions.
This means that milliseconds officially takes the type `unsigned int'. All
current callers seem to be OK with that.
Drivers need to be fixed up to use this instead of their private versions.
---
25-akpm/include/linux/time.h | 25 +++++++++++++++++++------
1 files changed, 19 insertions(+), 6 deletions(-)
diff -puN include/linux/time.h~MSEC_TO_JIFFIES-inline include/linux/time.h
--- 25/include/linux/time.h~MSEC_TO_JIFFIES-inline Thu May 13 15:13:19 2004
+++ 25-akpm/include/linux/time.h Thu May 13 15:23:58 2004
@@ -184,16 +184,29 @@ struct timezone {
* Avoid unnecessary multiplications/divisions in the
* two most common HZ cases:
*/
+static inline unsigned int jiffies_to_msecs(unsigned long j)
+{
#if HZ <= 1000 && !(1000 % HZ)
-# define JIFFIES_TO_MSECS(j) ((1000/HZ)*(j))
-# define MSECS_TO_JIFFIES(m) (((m) + (1000/HZ) - 1)/(1000/HZ))
+ return (1000 / HZ) * j;
#elif HZ > 1000 && !(HZ % 1000)
-# define JIFFIES_TO_MSECS(j) (((j) + (HZ/1000) - 1)/(HZ/1000))
-# define MSECS_TO_JIFFIES(m) ((m)*(HZ/1000))
+ return (j + (HZ / 1000) - 1)/(HZ / 1000);
#else
-# define JIFFIES_TO_MSECS(j) (((j) * 1000) / HZ)
-# define MSECS_TO_JIFFIES(m) (((m) * HZ + 999) / 1000)
+ return (j * 1000) / HZ;
#endif
+}
+static inline unsigned long msecs_to_jiffies(unsigned int m)
+{
+#if HZ <= 1000 && !(1000 % HZ)
+ return (m + (1000 / HZ) - 1) / (1000 / HZ);
+#elif HZ > 1000 && !(HZ % 1000)
+ return m * (HZ / 1000);
+#else
+ return (m * HZ + 999) / 1000;
+#endif
+}
+
+#define JIFFIES_TO_MSECS(j) jiffies_to_msecs(j)
+#define MSECS_TO_JIFFIES(m) msecs_to_jiffies(m)
/*
* The TICK_NSEC - 1 rounds up the value to the next resolution. Note
_
^ permalink raw reply [flat|nested] 54+ messages in thread
* Re: MSEC_TO_JIFFIES is messed up...
2004-05-13 22:40 ` Andrew Morton
@ 2004-05-13 22:40 ` Andrew Morton
2004-05-13 22:41 ` Andrew Morton
0 siblings, 1 reply; 54+ messages in thread
From: Andrew Morton @ 2004-05-13 22:40 UTC (permalink / raw)
To: jgarzik, paul, mingo, wli, greg, linux-kernel, netdev, davidel,
Valdis.Kletnieks
Andrew Morton <akpm@osdl.org> wrote:
>
> Jeff Garzik <jgarzik@pobox.com> wrote:
> >
> > For whomever winds up doing this work, I have two requests:
> >
> > * use a type-safe inline rather than purely a macro, as some drivers do
> > * replace msecs_to_jiffies() occurrences as well as MSECS_TO_JIFFIES()
> > (and ditto for jiffies_to_msecs)
>
> ...
> Drivers need to be fixed up to use this instead of their private versions.
Remove various private implementations of msecs_to_jiffies() and
jiffies_to_msecs().
There are various uppercase versions which should be consolidated.
---
25-akpm/drivers/block/carmel.c | 5 -----
25-akpm/drivers/block/genhd.c | 26 ++++++++------------------
25-akpm/drivers/char/watchdog/shwdt.c | 1 -
25-akpm/drivers/net/tulip/de2104x.c | 9 +--------
25-akpm/include/linux/libata.h | 5 -----
drivers/scsi/libata-core.c | 0
drivers/scsi/sata_promise.c | 0
7 files changed, 9 insertions(+), 37 deletions(-)
diff -puN drivers/block/genhd.c~msec_to_jiffies-drivers drivers/block/genhd.c
--- 25/drivers/block/genhd.c~msec_to_jiffies-drivers Thu May 13 15:26:38 2004
+++ 25-akpm/drivers/block/genhd.c Thu May 13 15:26:38 2004
@@ -357,16 +357,6 @@ static ssize_t disk_size_read(struct gen
return sprintf(page, "%llu\n", (unsigned long long)get_capacity(disk));
}
-static inline unsigned jiffies_to_msec(unsigned jif)
-{
-#if 1000 % HZ == 0
- return jif * (1000 / HZ);
-#elif HZ % 1000 == 0
- return jif / (HZ / 1000);
-#else
- return (jif / HZ) * 1000 + (jif % HZ) * 1000 / HZ;
-#endif
-}
static ssize_t disk_stats_read(struct gendisk * disk, char *page)
{
disk_round_stats(disk);
@@ -377,14 +367,14 @@ static ssize_t disk_stats_read(struct ge
"\n",
disk_stat_read(disk, reads), disk_stat_read(disk, read_merges),
(unsigned long long)disk_stat_read(disk, read_sectors),
- jiffies_to_msec(disk_stat_read(disk, read_ticks)),
+ jiffies_to_msecs(disk_stat_read(disk, read_ticks)),
disk_stat_read(disk, writes),
disk_stat_read(disk, write_merges),
(unsigned long long)disk_stat_read(disk, write_sectors),
- jiffies_to_msec(disk_stat_read(disk, write_ticks)),
+ jiffies_to_msecs(disk_stat_read(disk, write_ticks)),
disk->in_flight,
- jiffies_to_msec(disk_stat_read(disk, io_ticks)),
- jiffies_to_msec(disk_stat_read(disk, time_in_queue)));
+ jiffies_to_msecs(disk_stat_read(disk, io_ticks)),
+ jiffies_to_msecs(disk_stat_read(disk, time_in_queue)));
}
static struct disk_attribute disk_attr_dev = {
.attr = {.name = "dev", .mode = S_IRUGO },
@@ -498,13 +488,13 @@ static int diskstats_show(struct seq_fil
gp->major, n + gp->first_minor, disk_name(gp, n, buf),
disk_stat_read(gp, reads), disk_stat_read(gp, read_merges),
(unsigned long long)disk_stat_read(gp, read_sectors),
- jiffies_to_msec(disk_stat_read(gp, read_ticks)),
+ jiffies_to_msecs(disk_stat_read(gp, read_ticks)),
disk_stat_read(gp, writes), disk_stat_read(gp, write_merges),
(unsigned long long)disk_stat_read(gp, write_sectors),
- jiffies_to_msec(disk_stat_read(gp, write_ticks)),
+ jiffies_to_msecs(disk_stat_read(gp, write_ticks)),
gp->in_flight,
- jiffies_to_msec(disk_stat_read(gp, io_ticks)),
- jiffies_to_msec(disk_stat_read(gp, time_in_queue)));
+ jiffies_to_msecs(disk_stat_read(gp, io_ticks)),
+ jiffies_to_msecs(disk_stat_read(gp, time_in_queue)));
/* now show all non-0 size partitions of it */
for (n = 0; n < gp->minors - 1; n++) {
diff -puN drivers/net/tulip/de2104x.c~msec_to_jiffies-drivers drivers/net/tulip/de2104x.c
--- 25/drivers/net/tulip/de2104x.c~msec_to_jiffies-drivers Thu May 13 15:26:38 2004
+++ 25-akpm/drivers/net/tulip/de2104x.c Thu May 13 15:26:38 2004
@@ -357,13 +357,6 @@ static u16 t21041_csr14[] = { 0xFFFF, 0x
static u16 t21041_csr15[] = { 0x0008, 0x0006, 0x000E, 0x0008, 0x0008, };
-static inline unsigned long
-msec_to_jiffies(unsigned long ms)
-{
- return (((ms)*HZ+999)/1000);
-}
-
-
#define dr32(reg) readl(de->regs + (reg))
#define dw32(reg,val) writel((val), de->regs + (reg))
@@ -1216,7 +1209,7 @@ static void de_adapter_wake (struct de_p
/* de4x5.c delays, so we do too */
current->state = TASK_UNINTERRUPTIBLE;
- schedule_timeout(msec_to_jiffies(10));
+ schedule_timeout(msecs_to_jiffies(10));
}
}
diff -puN drivers/char/watchdog/shwdt.c~msec_to_jiffies-drivers drivers/char/watchdog/shwdt.c
--- 25/drivers/char/watchdog/shwdt.c~msec_to_jiffies-drivers Thu May 13 15:26:38 2004
+++ 25-akpm/drivers/char/watchdog/shwdt.c Thu May 13 15:26:38 2004
@@ -64,7 +64,6 @@
*/
static int clock_division_ratio = WTCSR_CKS_4096;
-#define msecs_to_jiffies(msecs) (jiffies + (HZ * msecs + 9999) / 10000)
#define next_ping_period(cks) msecs_to_jiffies(cks - 4)
static unsigned long shwdt_is_open;
diff -puN drivers/scsi/libata-core.c~msec_to_jiffies-drivers drivers/scsi/libata-core.c
diff -puN drivers/scsi/sata_promise.c~msec_to_jiffies-drivers drivers/scsi/sata_promise.c
diff -puN drivers/block/carmel.c~msec_to_jiffies-drivers drivers/block/carmel.c
--- 25/drivers/block/carmel.c~msec_to_jiffies-drivers Thu May 13 15:26:38 2004
+++ 25-akpm/drivers/block/carmel.c Thu May 13 15:26:38 2004
@@ -438,11 +438,6 @@ static int carm_bdev_ioctl(struct inode
return -EOPNOTSUPP;
}
-static inline unsigned long msecs_to_jiffies(unsigned long msecs)
-{
- return ((HZ * msecs + 999) / 1000);
-}
-
static void msleep(unsigned long msecs)
{
set_current_state(TASK_UNINTERRUPTIBLE);
diff -puN include/linux/libata.h~msec_to_jiffies-drivers include/linux/libata.h
--- 25/include/linux/libata.h~msec_to_jiffies-drivers Thu May 13 15:26:38 2004
+++ 25-akpm/include/linux/libata.h Thu May 13 15:26:38 2004
@@ -408,11 +408,6 @@ extern int ata_std_bios_param(struct scs
extern int ata_scsi_slave_config(struct scsi_device *sdev);
-static inline unsigned long msecs_to_jiffies(unsigned long msecs)
-{
- return ((HZ * msecs + 999) / 1000);
-}
-
static inline unsigned int ata_tag_valid(unsigned int tag)
{
return (tag < ATA_MAX_QUEUE) ? 1 : 0;
_
^ permalink raw reply [flat|nested] 54+ messages in thread
* Re: MSEC_TO_JIFFIES is messed up...
2004-05-13 22:40 ` Andrew Morton
@ 2004-05-13 22:41 ` Andrew Morton
2004-05-13 23:02 ` Jeff Garzik
0 siblings, 1 reply; 54+ messages in thread
From: Andrew Morton @ 2004-05-13 22:41 UTC (permalink / raw)
To: jgarzik, paul, mingo, wli, greg, linux-kernel, netdev, davidel,
Valdis.Kletnieks
Andrew Morton <akpm@osdl.org> wrote:
>
> Andrew Morton <akpm@osdl.org> wrote:
> >
> > Jeff Garzik <jgarzik@pobox.com> wrote:
> > >
> > > For whomever winds up doing this work, I have two requests:
> > >
> > > * use a type-safe inline rather than purely a macro, as some drivers do
> > > * replace msecs_to_jiffies() occurrences as well as MSECS_TO_JIFFIES()
> > > (and ditto for jiffies_to_msecs)
> >
> > ...
> > Drivers need to be fixed up to use this instead of their private versions.
>
> ...
> There are various uppercase versions which should be consolidated.
Switch all users of MSEC[S]_TO_JIFFIES and JIFFIES_TO_MSEC[S] over to use
jiffies_to_msecs() and msecs_to_jiffies(). Withdraw MSECS_TO_JIFFIES() and
JIFFIES_TO_MSECS() from the kernel API.
---
25-akpm/drivers/net/irda/act200l-sir.c | 2 -
25-akpm/drivers/net/irda/act200l.c | 10 ++++-----
25-akpm/drivers/net/irda/actisys.c | 2 -
25-akpm/drivers/net/irda/girbil.c | 10 ++++-----
25-akpm/drivers/net/irda/irda-usb.c | 6 ++---
25-akpm/drivers/net/irda/irport.c | 4 +--
25-akpm/drivers/net/irda/irtty-sir.c | 4 +--
25-akpm/drivers/net/irda/ma600-sir.c | 8 +++----
25-akpm/drivers/net/irda/ma600.c | 16 +++++++--------
25-akpm/drivers/net/irda/mcp2120.c | 8 +++----
25-akpm/drivers/net/irda/sir_dev.c | 2 -
25-akpm/drivers/net/irda/sir_kthread.c | 2 -
25-akpm/drivers/net/irda/stir4200.c | 6 ++---
25-akpm/drivers/net/irda/tekram-sir.c | 2 -
25-akpm/drivers/net/irda/tekram.c | 12 +++++------
25-akpm/include/linux/time.h | 3 --
25-akpm/kernel/sched.c | 2 -
25-akpm/net/irda/ircomm/ircomm_tty.c | 2 -
25-akpm/net/irda/irlap_event.c | 6 ++---
25-akpm/net/sctp/associola.c | 10 ++++-----
25-akpm/net/sctp/chunk.c | 2 -
25-akpm/net/sctp/endpointola.c | 4 +--
25-akpm/net/sctp/socket.c | 34 ++++++++++++++++-----------------
23 files changed, 77 insertions(+), 80 deletions(-)
diff -puN drivers/net/irda/act200l.c~MSEC_TO_JIFFIES-to-msec_to_jiffies drivers/net/irda/act200l.c
--- 25/drivers/net/irda/act200l.c~MSEC_TO_JIFFIES-to-msec_to_jiffies Thu May 13 15:35:15 2004
+++ 25-akpm/drivers/net/irda/act200l.c Thu May 13 15:35:15 2004
@@ -148,7 +148,7 @@ static int act200l_change_speed(struct i
irda_task_next_state(task, IRDA_TASK_CHILD_WAIT);
/* Give reset 1 sec to finish */
- ret = MSECS_TO_JIFFIES(1000);
+ ret = msecs_to_jiffies(1000);
}
break;
case IRDA_TASK_CHILD_WAIT:
@@ -187,7 +187,7 @@ static int act200l_change_speed(struct i
/* Write control bytes */
self->write(self->dev, control, 3);
irda_task_next_state(task, IRDA_TASK_WAIT);
- ret = MSECS_TO_JIFFIES(5);
+ ret = msecs_to_jiffies(5);
break;
case IRDA_TASK_WAIT:
/* Go back to normal mode */
@@ -237,14 +237,14 @@ static int act200l_reset(struct irda_tas
self->set_dtr_rts(self->dev, TRUE, TRUE);
irda_task_next_state(task, IRDA_TASK_WAIT1);
- ret = MSECS_TO_JIFFIES(50);
+ ret = msecs_to_jiffies(50);
break;
case IRDA_TASK_WAIT1:
/* Reset the dongle : set RTS low for 25 ms */
self->set_dtr_rts(self->dev, TRUE, FALSE);
irda_task_next_state(task, IRDA_TASK_WAIT2);
- ret = MSECS_TO_JIFFIES(50);
+ ret = msecs_to_jiffies(50);
break;
case IRDA_TASK_WAIT2:
/* Clear DTR and set RTS to enter command mode */
@@ -253,7 +253,7 @@ static int act200l_reset(struct irda_tas
/* Write control bytes */
self->write(self->dev, control, 9);
irda_task_next_state(task, IRDA_TASK_WAIT3);
- ret = MSECS_TO_JIFFIES(15);
+ ret = msecs_to_jiffies(15);
break;
case IRDA_TASK_WAIT3:
/* Go back to normal mode */
diff -puN drivers/net/irda/act200l-sir.c~MSEC_TO_JIFFIES-to-msec_to_jiffies drivers/net/irda/act200l-sir.c
--- 25/drivers/net/irda/act200l-sir.c~MSEC_TO_JIFFIES-to-msec_to_jiffies Thu May 13 15:35:15 2004
+++ 25-akpm/drivers/net/irda/act200l-sir.c Thu May 13 15:35:15 2004
@@ -178,7 +178,7 @@ static int act200l_change_speed(struct s
/* Write control bytes */
sirdev_raw_write(dev, control, 3);
set_current_state(TASK_UNINTERRUPTIBLE);
- schedule_timeout(MSECS_TO_JIFFIES(5));
+ schedule_timeout(msecs_to_jiffies(5));
/* Go back to normal mode */
sirdev_set_dtr_rts(dev, TRUE, TRUE);
diff -puN drivers/net/irda/actisys.c~MSEC_TO_JIFFIES-to-msec_to_jiffies drivers/net/irda/actisys.c
--- 25/drivers/net/irda/actisys.c~MSEC_TO_JIFFIES-to-msec_to_jiffies Thu May 13 15:35:15 2004
+++ 25-akpm/drivers/net/irda/actisys.c Thu May 13 15:35:15 2004
@@ -238,7 +238,7 @@ static int actisys_reset(struct irda_tas
self->set_dtr_rts(self->dev, TRUE, TRUE);
/* Sleep 50 ms to make sure capacitor is charged */
- ret = MSECS_TO_JIFFIES(50);
+ ret = msecs_to_jiffies(50);
irda_task_next_state(task, IRDA_TASK_WAIT);
break;
case IRDA_TASK_WAIT:
diff -puN drivers/net/irda/girbil.c~MSEC_TO_JIFFIES-to-msec_to_jiffies drivers/net/irda/girbil.c
--- 25/drivers/net/irda/girbil.c~MSEC_TO_JIFFIES-to-msec_to_jiffies Thu May 13 15:35:15 2004
+++ 25-akpm/drivers/net/irda/girbil.c Thu May 13 15:35:15 2004
@@ -119,7 +119,7 @@ static int girbil_change_speed(struct ir
irda_task_next_state(task, IRDA_TASK_CHILD_WAIT);
/* Give reset 1 sec to finish */
- ret = MSECS_TO_JIFFIES(1000);
+ ret = msecs_to_jiffies(1000);
}
break;
case IRDA_TASK_CHILD_WAIT:
@@ -153,7 +153,7 @@ static int girbil_change_speed(struct ir
/* Write control bytes */
self->write(self->dev, control, 2);
irda_task_next_state(task, IRDA_TASK_WAIT);
- ret = MSECS_TO_JIFFIES(100);
+ ret = msecs_to_jiffies(100);
break;
case IRDA_TASK_WAIT:
/* Go back to normal mode */
@@ -194,19 +194,19 @@ static int girbil_reset(struct irda_task
self->set_dtr_rts(self->dev, TRUE, FALSE);
irda_task_next_state(task, IRDA_TASK_WAIT1);
/* Sleep at least 5 ms */
- ret = MSECS_TO_JIFFIES(20);
+ ret = msecs_to_jiffies(20);
break;
case IRDA_TASK_WAIT1:
/* Set DTR and clear RTS to enter command mode */
self->set_dtr_rts(self->dev, FALSE, TRUE);
irda_task_next_state(task, IRDA_TASK_WAIT2);
- ret = MSECS_TO_JIFFIES(20);
+ ret = msecs_to_jiffies(20);
break;
case IRDA_TASK_WAIT2:
/* Write control byte */
self->write(self->dev, &control, 1);
irda_task_next_state(task, IRDA_TASK_WAIT3);
- ret = MSECS_TO_JIFFIES(20);
+ ret = msecs_to_jiffies(20);
break;
case IRDA_TASK_WAIT3:
/* Go back to normal mode */
diff -puN drivers/net/irda/irda-usb.c~MSEC_TO_JIFFIES-to-msec_to_jiffies drivers/net/irda/irda-usb.c
--- 25/drivers/net/irda/irda-usb.c~MSEC_TO_JIFFIES-to-msec_to_jiffies Thu May 13 15:35:15 2004
+++ 25-akpm/drivers/net/irda/irda-usb.c Thu May 13 15:35:15 2004
@@ -268,7 +268,7 @@ static void irda_usb_change_speed_xbofs(
speed_bulk_callback, self);
urb->transfer_buffer_length = USB_IRDA_HEADER;
urb->transfer_flags = URB_ASYNC_UNLINK;
- urb->timeout = MSECS_TO_JIFFIES(100);
+ urb->timeout = msecs_to_jiffies(100);
/* Irq disabled -> GFP_ATOMIC */
if ((ret = usb_submit_urb(urb, GFP_ATOMIC))) {
@@ -412,7 +412,7 @@ static int irda_usb_hard_xmit(struct sk_
* This is how the dongle will detect the end of packet - Jean II */
urb->transfer_flags |= URB_ZERO_PACKET;
/* Timeout need to be shorter than NET watchdog timer */
- urb->timeout = MSECS_TO_JIFFIES(200);
+ urb->timeout = msecs_to_jiffies(200);
/* Generate min turn time. FIXME: can we do better than this? */
/* Trying to a turnaround time at this level is trying to measure
@@ -1311,7 +1311,7 @@ static inline struct irda_class_desc *ir
IU_REQ_GET_CLASS_DESC,
USB_DIR_IN | USB_TYPE_CLASS | USB_RECIP_INTERFACE,
0, intf->altsetting->desc.bInterfaceNumber, desc,
- sizeof(*desc), MSECS_TO_JIFFIES(500));
+ sizeof(*desc), msecs_to_jiffies(500));
IRDA_DEBUG(1, "%s(), ret=%d\n", __FUNCTION__, ret);
if (ret < sizeof(*desc)) {
diff -puN drivers/net/irda/irport.c~MSEC_TO_JIFFIES-to-msec_to_jiffies drivers/net/irda/irport.c
--- 25/drivers/net/irda/irport.c~MSEC_TO_JIFFIES-to-msec_to_jiffies Thu May 13 15:35:15 2004
+++ 25-akpm/drivers/net/irda/irport.c Thu May 13 15:35:15 2004
@@ -452,7 +452,7 @@ int __irport_change_speed(struct irda_ta
task->state = IRDA_TASK_WAIT;
/* Try again later */
- ret = MSECS_TO_JIFFIES(20);
+ ret = msecs_to_jiffies(20);
break;
}
@@ -474,7 +474,7 @@ int __irport_change_speed(struct irda_ta
irda_task_next_state(task, IRDA_TASK_CHILD_WAIT);
/* Give dongle 1 sec to finish */
- ret = MSECS_TO_JIFFIES(1000);
+ ret = msecs_to_jiffies(1000);
} else
/* Child finished immediately */
irda_task_next_state(task, IRDA_TASK_CHILD_DONE);
diff -puN drivers/net/irda/irtty-sir.c~MSEC_TO_JIFFIES-to-msec_to_jiffies drivers/net/irda/irtty-sir.c
--- 25/drivers/net/irda/irtty-sir.c~MSEC_TO_JIFFIES-to-msec_to_jiffies Thu May 13 15:35:15 2004
+++ 25-akpm/drivers/net/irda/irtty-sir.c Thu May 13 15:35:15 2004
@@ -93,12 +93,12 @@ static void irtty_wait_until_sent(struct
tty = priv->tty;
if (tty->driver->wait_until_sent) {
lock_kernel();
- tty->driver->wait_until_sent(tty, MSECS_TO_JIFFIES(100));
+ tty->driver->wait_until_sent(tty, msecs_to_jiffies(100));
unlock_kernel();
}
else {
set_task_state(current, TASK_UNINTERRUPTIBLE);
- schedule_timeout(MSECS_TO_JIFFIES(USBSERIAL_TX_DONE_DELAY));
+ schedule_timeout(msecs_to_jiffies(USBSERIAL_TX_DONE_DELAY));
}
}
diff -puN drivers/net/irda/ma600.c~MSEC_TO_JIFFIES-to-msec_to_jiffies drivers/net/irda/ma600.c
--- 25/drivers/net/irda/ma600.c~MSEC_TO_JIFFIES-to-msec_to_jiffies Thu May 13 15:35:15 2004
+++ 25-akpm/drivers/net/irda/ma600.c Thu May 13 15:35:15 2004
@@ -184,7 +184,7 @@ static int ma600_change_speed(struct ird
if (self->speed_task && self->speed_task != task) {
IRDA_DEBUG(0, "%s(), busy!\n", __FUNCTION__);
- return MSECS_TO_JIFFIES(10);
+ return msecs_to_jiffies(10);
} else {
self->speed_task = task;
}
@@ -202,7 +202,7 @@ static int ma600_change_speed(struct ird
irda_task_next_state(task, IRDA_TASK_CHILD_WAIT);
/* give 1 second to finish */
- ret = MSECS_TO_JIFFIES(1000);
+ ret = msecs_to_jiffies(1000);
} else {
irda_task_next_state(task, IRDA_TASK_CHILD_DONE);
}
@@ -217,7 +217,7 @@ static int ma600_change_speed(struct ird
/* Set DTR, Clear RTS */
self->set_dtr_rts(self->dev, TRUE, FALSE);
- ret = MSECS_TO_JIFFIES(1); /* Sleep 1 ms */
+ ret = msecs_to_jiffies(1); /* Sleep 1 ms */
irda_task_next_state(task, IRDA_TASK_WAIT);
break;
@@ -231,7 +231,7 @@ static int ma600_change_speed(struct ird
irda_task_next_state(task, IRDA_TASK_WAIT1);
/* Wait at least 10 ms */
- ret = MSECS_TO_JIFFIES(15);
+ ret = msecs_to_jiffies(15);
break;
case IRDA_TASK_WAIT1:
@@ -258,7 +258,7 @@ static int ma600_change_speed(struct ird
irda_task_next_state(task, IRDA_TASK_WAIT2);
/* Wait at least 10 ms */
- ret = MSECS_TO_JIFFIES(10);
+ ret = msecs_to_jiffies(10);
break;
case IRDA_TASK_WAIT2:
@@ -298,7 +298,7 @@ int ma600_reset(struct irda_task *task)
if (self->reset_task && self->reset_task != task) {
IRDA_DEBUG(0, "%s(), busy!\n", __FUNCTION__);
- return MSECS_TO_JIFFIES(10);
+ return msecs_to_jiffies(10);
} else
self->reset_task = task;
@@ -307,13 +307,13 @@ int ma600_reset(struct irda_task *task)
/* Clear DTR and Set RTS */
self->set_dtr_rts(self->dev, FALSE, TRUE);
irda_task_next_state(task, IRDA_TASK_WAIT1);
- ret = MSECS_TO_JIFFIES(10); /* Sleep 10 ms */
+ ret = msecs_to_jiffies(10); /* Sleep 10 ms */
break;
case IRDA_TASK_WAIT1:
/* Set DTR and RTS */
self->set_dtr_rts(self->dev, TRUE, TRUE);
irda_task_next_state(task, IRDA_TASK_WAIT2);
- ret = MSECS_TO_JIFFIES(10); /* Sleep 10 ms */
+ ret = msecs_to_jiffies(10); /* Sleep 10 ms */
break;
case IRDA_TASK_WAIT2:
irda_task_next_state(task, IRDA_TASK_DONE);
diff -puN drivers/net/irda/ma600-sir.c~MSEC_TO_JIFFIES-to-msec_to_jiffies drivers/net/irda/ma600-sir.c
--- 25/drivers/net/irda/ma600-sir.c~MSEC_TO_JIFFIES-to-msec_to_jiffies Thu May 13 15:35:15 2004
+++ 25-akpm/drivers/net/irda/ma600-sir.c Thu May 13 15:35:15 2004
@@ -192,7 +192,7 @@ static int ma600_change_speed(struct sir
/* Wait at least 10ms: fake wait_until_sent - 10 bits at 9600 baud*/
set_current_state(TASK_UNINTERRUPTIBLE);
- schedule_timeout(MSECS_TO_JIFFIES(15)); /* old ma600 uses 15ms */
+ schedule_timeout(msecs_to_jiffies(15)); /* old ma600 uses 15ms */
#if 1
/* read-back of the control byte. ma600 is the first dongle driver
@@ -216,7 +216,7 @@ static int ma600_change_speed(struct sir
/* Wait at least 10ms */
set_current_state(TASK_UNINTERRUPTIBLE);
- schedule_timeout(MSECS_TO_JIFFIES(10));
+ schedule_timeout(msecs_to_jiffies(10));
/* dongle is now switched to the new speed */
dev->speed = speed;
@@ -246,12 +246,12 @@ int ma600_reset(struct sir_dev *dev)
/* Reset the dongle : set DTR low for 10 ms */
sirdev_set_dtr_rts(dev, FALSE, TRUE);
set_current_state(TASK_UNINTERRUPTIBLE);
- schedule_timeout(MSECS_TO_JIFFIES(10));
+ schedule_timeout(msecs_to_jiffies(10));
/* Go back to normal mode */
sirdev_set_dtr_rts(dev, TRUE, TRUE);
set_current_state(TASK_UNINTERRUPTIBLE);
- schedule_timeout(MSECS_TO_JIFFIES(10));
+ schedule_timeout(msecs_to_jiffies(10));
dev->speed = 9600; /* That's the dongle-default */
diff -puN drivers/net/irda/mcp2120.c~MSEC_TO_JIFFIES-to-msec_to_jiffies drivers/net/irda/mcp2120.c
--- 25/drivers/net/irda/mcp2120.c~MSEC_TO_JIFFIES-to-msec_to_jiffies Thu May 13 15:35:15 2004
+++ 25-akpm/drivers/net/irda/mcp2120.c Thu May 13 15:35:15 2004
@@ -99,7 +99,7 @@ static int mcp2120_change_speed(struct i
irda_task_next_state(task, IRDA_TASK_CHILD_WAIT);
/* Give reset 1 sec to finish */
- ret = MSECS_TO_JIFFIES(1000);
+ ret = msecs_to_jiffies(1000);
}
break;
case IRDA_TASK_CHILD_WAIT:
@@ -140,7 +140,7 @@ static int mcp2120_change_speed(struct i
self->write(self->dev, control, 2);
irda_task_next_state(task, IRDA_TASK_WAIT);
- ret = MSECS_TO_JIFFIES(100);
+ ret = msecs_to_jiffies(100);
//printk("mcp2120_change_speed irda_child_done\n");
break;
case IRDA_TASK_WAIT:
@@ -189,14 +189,14 @@ static int mcp2120_reset(struct irda_tas
/* Reset dongle by setting RTS*/
self->set_dtr_rts(self->dev, TRUE, TRUE);
irda_task_next_state(task, IRDA_TASK_WAIT1);
- ret = MSECS_TO_JIFFIES(50);
+ ret = msecs_to_jiffies(50);
break;
case IRDA_TASK_WAIT1:
//printk("mcp2120_reset irda_task_wait1\n");
/* clear RTS and wait for at least 30 ms. */
self->set_dtr_rts(self->dev, FALSE, FALSE);
irda_task_next_state(task, IRDA_TASK_WAIT2);
- ret = MSECS_TO_JIFFIES(50);
+ ret = msecs_to_jiffies(50);
break;
case IRDA_TASK_WAIT2:
//printk("mcp2120_reset irda_task_wait2\n");
diff -puN drivers/net/irda/sir_dev.c~MSEC_TO_JIFFIES-to-msec_to_jiffies drivers/net/irda/sir_dev.c
--- 25/drivers/net/irda/sir_dev.c~MSEC_TO_JIFFIES-to-msec_to_jiffies Thu May 13 15:35:15 2004
+++ 25-akpm/drivers/net/irda/sir_dev.c Thu May 13 15:35:15 2004
@@ -74,7 +74,7 @@ int sirdev_raw_write(struct sir_dev *dev
while (dev->tx_buff.len > 0) { /* wait until tx idle */
spin_unlock_irqrestore(&dev->tx_lock, flags);
set_current_state(TASK_UNINTERRUPTIBLE);
- schedule_timeout(MSECS_TO_JIFFIES(10));
+ schedule_timeout(msecs_to_jiffies(10));
spin_lock_irqsave(&dev->tx_lock, flags);
}
diff -puN drivers/net/irda/sir_kthread.c~MSEC_TO_JIFFIES-to-msec_to_jiffies drivers/net/irda/sir_kthread.c
--- 25/drivers/net/irda/sir_kthread.c~MSEC_TO_JIFFIES-to-msec_to_jiffies Thu May 13 15:35:15 2004
+++ 25-akpm/drivers/net/irda/sir_kthread.c Thu May 13 15:35:15 2004
@@ -415,7 +415,7 @@ static void irda_config_fsm(void *data)
fsm->state = next_state;
} while(!delay);
- irda_queue_delayed_request(&fsm->rq, MSECS_TO_JIFFIES(delay));
+ irda_queue_delayed_request(&fsm->rq, msecs_to_jiffies(delay));
}
/* schedule some device configuration task for execution by kIrDAd
diff -puN drivers/net/irda/stir4200.c~MSEC_TO_JIFFIES-to-msec_to_jiffies drivers/net/irda/stir4200.c
--- 25/drivers/net/irda/stir4200.c~MSEC_TO_JIFFIES-to-msec_to_jiffies Thu May 13 15:35:15 2004
+++ 25-akpm/drivers/net/irda/stir4200.c Thu May 13 15:35:15 2004
@@ -208,7 +208,7 @@ static int write_reg(struct stir_cb *sti
REQ_WRITE_SINGLE,
USB_DIR_OUT|USB_TYPE_VENDOR|USB_RECIP_DEVICE,
value, reg, NULL, 0,
- MSECS_TO_JIFFIES(CTRL_TIMEOUT));
+ msecs_to_jiffies(CTRL_TIMEOUT));
}
/* Send control message to read multiple registers */
@@ -221,7 +221,7 @@ static inline int read_reg(struct stir_c
REQ_READ_REG,
USB_DIR_IN | USB_TYPE_VENDOR | USB_RECIP_DEVICE,
0, reg, data, count,
- MSECS_TO_JIFFIES(CTRL_TIMEOUT));
+ msecs_to_jiffies(CTRL_TIMEOUT));
}
static inline int isfir(u32 speed)
@@ -745,7 +745,7 @@ static void stir_send(struct stir_cb *st
if (usb_bulk_msg(stir->usbdev, usb_sndbulkpipe(stir->usbdev, 1),
stir->io_buf, wraplen,
- NULL, MSECS_TO_JIFFIES(TRANSMIT_TIMEOUT)))
+ NULL, msecs_to_jiffies(TRANSMIT_TIMEOUT)))
stir->stats.tx_errors++;
}
diff -puN drivers/net/irda/tekram.c~MSEC_TO_JIFFIES-to-msec_to_jiffies drivers/net/irda/tekram.c
--- 25/drivers/net/irda/tekram.c~MSEC_TO_JIFFIES-to-msec_to_jiffies Thu May 13 15:35:15 2004
+++ 25-akpm/drivers/net/irda/tekram.c Thu May 13 15:35:15 2004
@@ -113,7 +113,7 @@ static int tekram_change_speed(struct ir
if (self->speed_task && self->speed_task != task) {
IRDA_DEBUG(0, "%s(), busy!\n", __FUNCTION__ );
- return MSECS_TO_JIFFIES(10);
+ return msecs_to_jiffies(10);
} else
self->speed_task = task;
@@ -150,7 +150,7 @@ static int tekram_change_speed(struct ir
irda_task_next_state(task, IRDA_TASK_CHILD_WAIT);
/* Give reset 1 sec to finish */
- ret = MSECS_TO_JIFFIES(1000);
+ ret = msecs_to_jiffies(1000);
} else
irda_task_next_state(task, IRDA_TASK_CHILD_DONE);
break;
@@ -171,7 +171,7 @@ static int tekram_change_speed(struct ir
irda_task_next_state(task, IRDA_TASK_WAIT);
/* Wait at least 100 ms */
- ret = MSECS_TO_JIFFIES(150);
+ ret = msecs_to_jiffies(150);
break;
case IRDA_TASK_WAIT:
/* Set DTR, Set RTS */
@@ -214,7 +214,7 @@ int tekram_reset(struct irda_task *task)
if (self->reset_task && self->reset_task != task) {
IRDA_DEBUG(0, "%s(), busy!\n", __FUNCTION__ );
- return MSECS_TO_JIFFIES(10);
+ return msecs_to_jiffies(10);
} else
self->reset_task = task;
@@ -227,7 +227,7 @@ int tekram_reset(struct irda_task *task)
irda_task_next_state(task, IRDA_TASK_WAIT1);
/* Sleep 50 ms */
- ret = MSECS_TO_JIFFIES(50);
+ ret = msecs_to_jiffies(50);
break;
case IRDA_TASK_WAIT1:
/* Clear DTR, Set RTS */
@@ -236,7 +236,7 @@ int tekram_reset(struct irda_task *task)
irda_task_next_state(task, IRDA_TASK_WAIT2);
/* Should sleep 1 ms */
- ret = MSECS_TO_JIFFIES(1);
+ ret = msecs_to_jiffies(1);
break;
case IRDA_TASK_WAIT2:
/* Set DTR, Set RTS */
diff -puN drivers/net/irda/tekram-sir.c~MSEC_TO_JIFFIES-to-msec_to_jiffies drivers/net/irda/tekram-sir.c
--- 25/drivers/net/irda/tekram-sir.c~MSEC_TO_JIFFIES-to-msec_to_jiffies Thu May 13 15:35:15 2004
+++ 25-akpm/drivers/net/irda/tekram-sir.c Thu May 13 15:35:15 2004
@@ -211,7 +211,7 @@ static int tekram_reset(struct sir_dev *
/* Should sleep 1 ms */
set_current_state(TASK_UNINTERRUPTIBLE);
- schedule_timeout(MSECS_TO_JIFFIES(1));
+ schedule_timeout(msecs_to_jiffies(1));
/* Set DTR, Set RTS */
sirdev_set_dtr_rts(dev, TRUE, TRUE);
diff -puN include/linux/time.h~MSEC_TO_JIFFIES-to-msec_to_jiffies include/linux/time.h
--- 25/include/linux/time.h~MSEC_TO_JIFFIES-to-msec_to_jiffies Thu May 13 15:35:15 2004
+++ 25-akpm/include/linux/time.h Thu May 13 15:35:15 2004
@@ -205,9 +205,6 @@ static inline unsigned long msecs_to_jif
#endif
}
-#define JIFFIES_TO_MSECS(j) jiffies_to_msecs(j)
-#define MSECS_TO_JIFFIES(m) msecs_to_jiffies(m)
-
/*
* The TICK_NSEC - 1 rounds up the value to the next resolution. Note
* that a remainder subtract here would not do the right thing as the
diff -puN kernel/sched.c~MSEC_TO_JIFFIES-to-msec_to_jiffies kernel/sched.c
--- 25/kernel/sched.c~MSEC_TO_JIFFIES-to-msec_to_jiffies Thu May 13 15:35:15 2004
+++ 25-akpm/kernel/sched.c Thu May 13 15:35:15 2004
@@ -1873,7 +1873,7 @@ static void rebalance_tick(int this_cpu,
interval *= sd->busy_factor;
/* scale ms to jiffies */
- interval = MSECS_TO_JIFFIES(interval);
+ interval = msecs_to_jiffies(interval);
if (unlikely(!interval))
interval = 1;
diff -puN net/irda/ircomm/ircomm_tty.c~MSEC_TO_JIFFIES-to-msec_to_jiffies net/irda/ircomm/ircomm_tty.c
--- 25/net/irda/ircomm/ircomm_tty.c~MSEC_TO_JIFFIES-to-msec_to_jiffies Thu May 13 15:35:15 2004
+++ 25-akpm/net/irda/ircomm/ircomm_tty.c Thu May 13 15:35:15 2004
@@ -873,7 +873,7 @@ static void ircomm_tty_wait_until_sent(s
orig_jiffies = jiffies;
/* Set poll time to 200 ms */
- poll_time = IRDA_MIN(timeout, MSECS_TO_JIFFIES(200));
+ poll_time = IRDA_MIN(timeout, msecs_to_jiffies(200));
spin_lock_irqsave(&self->spinlock, flags);
while (self->tx_skb && self->tx_skb->len) {
diff -puN net/irda/irlap_event.c~MSEC_TO_JIFFIES-to-msec_to_jiffies net/irda/irlap_event.c
--- 25/net/irda/irlap_event.c~MSEC_TO_JIFFIES-to-msec_to_jiffies Thu May 13 15:35:15 2004
+++ 25-akpm/net/irda/irlap_event.c Thu May 13 15:35:15 2004
@@ -627,7 +627,7 @@ static int irlap_state_query(struct irla
if (irda_device_is_receiving(self->netdev) && !self->add_wait) {
IRDA_DEBUG(2, "%s(), device is slow to answer, "
"waiting some more!\n", __FUNCTION__);
- irlap_start_slot_timer(self, MSECS_TO_JIFFIES(10));
+ irlap_start_slot_timer(self, msecs_to_jiffies(10));
self->add_wait = TRUE;
return ret;
}
@@ -849,7 +849,7 @@ static int irlap_state_setup(struct irla
* 1.5 times the time taken to transmit a SNRM frame. So this time should
* between 15 msecs and 45 msecs.
*/
- irlap_start_backoff_timer(self, MSECS_TO_JIFFIES(20 +
+ irlap_start_backoff_timer(self, msecs_to_jiffies(20 +
(jiffies % 30)));
} else {
/* Always switch state before calling upper layers */
@@ -1506,7 +1506,7 @@ static int irlap_state_nrm_p(struct irla
if (irda_device_is_receiving(self->netdev) && !self->add_wait) {
IRDA_DEBUG(1, "FINAL_TIMER_EXPIRED when receiving a "
"frame! Waiting a little bit more!\n");
- irlap_start_final_timer(self, MSECS_TO_JIFFIES(300));
+ irlap_start_final_timer(self, msecs_to_jiffies(300));
/*
* Don't allow this to happen one more time in a row,
diff -puN net/sctp/associola.c~MSEC_TO_JIFFIES-to-msec_to_jiffies net/sctp/associola.c
--- 25/net/sctp/associola.c~MSEC_TO_JIFFIES-to-msec_to_jiffies Thu May 13 15:35:15 2004
+++ 25-akpm/net/sctp/associola.c Thu May 13 15:35:15 2004
@@ -142,9 +142,9 @@ struct sctp_association *sctp_associatio
* socket values.
*/
asoc->max_retrans = sp->assocparams.sasoc_asocmaxrxt;
- asoc->rto_initial = MSECS_TO_JIFFIES(sp->rtoinfo.srto_initial);
- asoc->rto_max = MSECS_TO_JIFFIES(sp->rtoinfo.srto_max);
- asoc->rto_min = MSECS_TO_JIFFIES(sp->rtoinfo.srto_min);
+ asoc->rto_initial = msecs_to_jiffies(sp->rtoinfo.srto_initial);
+ asoc->rto_max = msecs_to_jiffies(sp->rtoinfo.srto_max);
+ asoc->rto_min = msecs_to_jiffies(sp->rtoinfo.srto_min);
asoc->overall_error_count = 0;
@@ -170,7 +170,7 @@ struct sctp_association *sctp_associatio
asoc->max_init_attempts = sp->initmsg.sinit_max_attempts;
asoc->max_init_timeo =
- MSECS_TO_JIFFIES(sp->initmsg.sinit_max_init_timeo);
+ msecs_to_jiffies(sp->initmsg.sinit_max_init_timeo);
/* Allocate storage for the ssnmap after the inbound and outbound
* streams have been negotiated during Init.
@@ -507,7 +507,7 @@ struct sctp_transport *sctp_assoc_add_pe
/* Initialize the peer's heartbeat interval based on the
* sock configured value.
*/
- peer->hb_interval = MSECS_TO_JIFFIES(sp->paddrparam.spp_hbinterval);
+ peer->hb_interval = msecs_to_jiffies(sp->paddrparam.spp_hbinterval);
/* Set the path max_retrans. */
peer->max_retrans = asoc->max_retrans;
diff -puN net/sctp/chunk.c~MSEC_TO_JIFFIES-to-msec_to_jiffies net/sctp/chunk.c
--- 25/net/sctp/chunk.c~MSEC_TO_JIFFIES-to-msec_to_jiffies Thu May 13 15:35:15 2004
+++ 25-akpm/net/sctp/chunk.c Thu May 13 15:35:15 2004
@@ -186,7 +186,7 @@ struct sctp_datamsg *sctp_datamsg_from_u
if (sinfo->sinfo_timetolive) {
/* sinfo_timetolive is in milliseconds */
msg->expires_at = jiffies +
- MSECS_TO_JIFFIES(sinfo->sinfo_timetolive);
+ msecs_to_jiffies(sinfo->sinfo_timetolive);
msg->can_abandon = 1;
SCTP_DEBUG_PRINTK("%s: msg:%p expires_at: %ld jiffies:%ld\n",
__FUNCTION__, msg, msg->expires_at, jiffies);
diff -puN net/sctp/endpointola.c~MSEC_TO_JIFFIES-to-msec_to_jiffies net/sctp/endpointola.c
--- 25/net/sctp/endpointola.c~MSEC_TO_JIFFIES-to-msec_to_jiffies Thu May 13 15:35:15 2004
+++ 25-akpm/net/sctp/endpointola.c Thu May 13 15:35:15 2004
@@ -129,7 +129,7 @@ struct sctp_endpoint *sctp_endpoint_init
ep->timeouts[SCTP_EVENT_TIMEOUT_T1_INIT] =
SCTP_DEFAULT_TIMEOUT_T1_INIT;
ep->timeouts[SCTP_EVENT_TIMEOUT_T2_SHUTDOWN] =
- MSECS_TO_JIFFIES(sp->rtoinfo.srto_initial);
+ msecs_to_jiffies(sp->rtoinfo.srto_initial);
ep->timeouts[SCTP_EVENT_TIMEOUT_T3_RTX] = 0;
ep->timeouts[SCTP_EVENT_TIMEOUT_T4_RTO] = 0;
@@ -138,7 +138,7 @@ struct sctp_endpoint *sctp_endpoint_init
* recommended value of 5 times 'RTO.Max'.
*/
ep->timeouts[SCTP_EVENT_TIMEOUT_T5_SHUTDOWN_GUARD]
- = 5 * MSECS_TO_JIFFIES(sp->rtoinfo.srto_max);
+ = 5 * msecs_to_jiffies(sp->rtoinfo.srto_max);
ep->timeouts[SCTP_EVENT_TIMEOUT_HEARTBEAT] =
SCTP_DEFAULT_TIMEOUT_HEARTBEAT;
diff -puN net/sctp/socket.c~MSEC_TO_JIFFIES-to-msec_to_jiffies net/sctp/socket.c
--- 25/net/sctp/socket.c~MSEC_TO_JIFFIES-to-msec_to_jiffies Thu May 13 15:35:15 2004
+++ 25-akpm/net/sctp/socket.c Thu May 13 15:36:40 2004
@@ -1224,7 +1224,7 @@ SCTP_STATIC int sctp_sendmsg(struct kioc
}
if (sinit->sinit_max_init_timeo) {
asoc->max_init_timeo =
- MSECS_TO_JIFFIES(sinit->sinit_max_init_timeo);
+ msecs_to_jiffies(sinit->sinit_max_init_timeo);
}
}
@@ -1662,7 +1662,7 @@ static int sctp_setsockopt_peer_addr_par
if (params.spp_hbinterval) {
trans->hb_allowed = 1;
trans->hb_interval =
- MSECS_TO_JIFFIES(params.spp_hbinterval);
+ msecs_to_jiffies(params.spp_hbinterval);
} else
trans->hb_allowed = 0;
}
@@ -1835,11 +1835,11 @@ static int sctp_setsockopt_rtoinfo(struc
if (asoc) {
if (rtoinfo.srto_initial != 0)
asoc->rto_initial =
- MSECS_TO_JIFFIES(rtoinfo.srto_initial);
+ msecs_to_jiffies(rtoinfo.srto_initial);
if (rtoinfo.srto_max != 0)
- asoc->rto_max = MSECS_TO_JIFFIES(rtoinfo.srto_max);
+ asoc->rto_max = msecs_to_jiffies(rtoinfo.srto_max);
if (rtoinfo.srto_min != 0)
- asoc->rto_min = MSECS_TO_JIFFIES(rtoinfo.srto_min);
+ asoc->rto_min = msecs_to_jiffies(rtoinfo.srto_min);
} else {
/* If there is no association or the association-id = 0
* set the values to the endpoint.
@@ -2379,14 +2379,14 @@ SCTP_STATIC int sctp_init_sock(struct so
sp->initmsg.sinit_num_ostreams = sctp_max_outstreams;
sp->initmsg.sinit_max_instreams = sctp_max_instreams;
sp->initmsg.sinit_max_attempts = sctp_max_retrans_init;
- sp->initmsg.sinit_max_init_timeo = JIFFIES_TO_MSECS(sctp_rto_max);
+ sp->initmsg.sinit_max_init_timeo = jiffies_to_msecs(sctp_rto_max);
/* Initialize default RTO related parameters. These parameters can
* be modified for with the SCTP_RTOINFO socket option.
*/
- sp->rtoinfo.srto_initial = JIFFIES_TO_MSECS(sctp_rto_initial);
- sp->rtoinfo.srto_max = JIFFIES_TO_MSECS(sctp_rto_max);
- sp->rtoinfo.srto_min = JIFFIES_TO_MSECS(sctp_rto_min);
+ sp->rtoinfo.srto_initial = jiffies_to_msecs(sctp_rto_initial);
+ sp->rtoinfo.srto_max = jiffies_to_msecs(sctp_rto_max);
+ sp->rtoinfo.srto_min = jiffies_to_msecs(sctp_rto_min);
/* Initialize default association related parameters. These parameters
* can be modified with the SCTP_ASSOCINFO socket option.
@@ -2396,7 +2396,7 @@ SCTP_STATIC int sctp_init_sock(struct so
sp->assocparams.sasoc_peer_rwnd = 0;
sp->assocparams.sasoc_local_rwnd = 0;
sp->assocparams.sasoc_cookie_life =
- JIFFIES_TO_MSECS(sctp_valid_cookie_life);
+ jiffies_to_msecs(sctp_valid_cookie_life);
/* Initialize default event subscriptions. By default, all the
* options are off.
@@ -2406,7 +2406,7 @@ SCTP_STATIC int sctp_init_sock(struct so
/* Default Peer Address Parameters. These defaults can
* be modified via SCTP_PEER_ADDR_PARAMS
*/
- sp->paddrparam.spp_hbinterval = JIFFIES_TO_MSECS(sctp_hb_interval);
+ sp->paddrparam.spp_hbinterval = jiffies_to_msecs(sctp_hb_interval);
sp->paddrparam.spp_pathmaxrxt = sctp_max_retrans_path;
/* If enabled no SCTP message fragmentation will be performed.
@@ -2552,7 +2552,7 @@ static int sctp_getsockopt_sctp_status(s
status.sstat_primary.spinfo_state = transport->active;
status.sstat_primary.spinfo_cwnd = transport->cwnd;
status.sstat_primary.spinfo_srtt = transport->srtt;
- status.sstat_primary.spinfo_rto = JIFFIES_TO_MSECS(transport->rto);
+ status.sstat_primary.spinfo_rto = jiffies_to_msecs(transport->rto);
status.sstat_primary.spinfo_mtu = transport->pmtu;
if (put_user(len, optlen)) {
@@ -2607,7 +2607,7 @@ static int sctp_getsockopt_peer_addr_inf
pinfo.spinfo_state = transport->active;
pinfo.spinfo_cwnd = transport->cwnd;
pinfo.spinfo_srtt = transport->srtt;
- pinfo.spinfo_rto = JIFFIES_TO_MSECS(transport->rto);
+ pinfo.spinfo_rto = jiffies_to_msecs(transport->rto);
pinfo.spinfo_mtu = transport->pmtu;
if (put_user(len, optlen)) {
@@ -2811,7 +2811,7 @@ static int sctp_getsockopt_peer_addr_par
if (!trans->hb_allowed)
params.spp_hbinterval = 0;
else
- params.spp_hbinterval = JIFFIES_TO_MSECS(trans->hb_interval);
+ params.spp_hbinterval = jiffies_to_msecs(trans->hb_interval);
/* spp_pathmaxrxt contains the maximum number of retransmissions
* before this address shall be considered unreachable.
@@ -3168,9 +3168,9 @@ static int sctp_getsockopt_rtoinfo(struc
/* Values corresponding to the specific association. */
if (asoc) {
- rtoinfo.srto_initial = JIFFIES_TO_MSECS(asoc->rto_initial);
- rtoinfo.srto_max = JIFFIES_TO_MSECS(asoc->rto_max);
- rtoinfo.srto_min = JIFFIES_TO_MSECS(asoc->rto_min);
+ rtoinfo.srto_initial = jiffies_to_msecs(asoc->rto_initial);
+ rtoinfo.srto_max = jiffies_to_msecs(asoc->rto_max);
+ rtoinfo.srto_min = jiffies_to_msecs(asoc->rto_min);
} else {
/* Values corresponding to the endpoint. */
struct sctp_opt *sp = sctp_sk(sk);
_
^ permalink raw reply [flat|nested] 54+ messages in thread
* Re: MSEC_TO_JIFFIES is messed up...
2004-05-13 22:41 ` Andrew Morton
@ 2004-05-13 23:02 ` Jeff Garzik
0 siblings, 0 replies; 54+ messages in thread
From: Jeff Garzik @ 2004-05-13 23:02 UTC (permalink / raw)
To: Andrew Morton
Cc: paul, mingo, wli, greg, linux-kernel, netdev, davidel, Valdis.Kletnieks
Patches look good to me...
^ permalink raw reply [flat|nested] 54+ messages in thread
* Re: MSEC_TO_JIFFIES is messed up...
2004-05-12 21:55 ` Andreas Schwab
2004-05-12 22:07 ` J. Bruce Fields
@ 2004-05-16 3:48 ` Chris Wedgwood
2004-05-16 12:10 ` Paul Wagland
1 sibling, 1 reply; 54+ messages in thread
From: Chris Wedgwood @ 2004-05-16 3:48 UTC (permalink / raw)
To: Andreas Schwab
Cc: J. Bruce Fields, Davide Libenzi, Ingo Molnar, Jeff Garzik,
Greg KH, Andrew Morton, Linux Kernel Mailing List, Netdev
On Wed, May 12, 2004 at 11:55:18PM +0200, Andreas Schwab wrote:
> Signed integer overflow is undefined in C, so the compiler is
> allowed to assume it does not happen.
Really?
Just because something is undefined assuming it never happens is a bit
of a leap of faith IMO.
--cw
^ permalink raw reply [flat|nested] 54+ messages in thread
* Re: MSEC_TO_JIFFIES is messed up...
2004-05-16 3:48 ` Chris Wedgwood
@ 2004-05-16 12:10 ` Paul Wagland
0 siblings, 0 replies; 54+ messages in thread
From: Paul Wagland @ 2004-05-16 12:10 UTC (permalink / raw)
To: Chris Wedgwood
Cc: Andrew Morton, Davide Libenzi, Netdev, Jeff Garzik,
J. Bruce Fields, Andreas Schwab, Linux Kernel Mailing List,
Ingo Molnar, Greg KH
[-- Attachment #1: Type: text/plain, Size: 801 bytes --]
On May 16, 2004, at 5:48, Chris Wedgwood wrote:
> On Wed, May 12, 2004 at 11:55:18PM +0200, Andreas Schwab wrote:
>
>> Signed integer overflow is undefined in C, so the compiler is
>> allowed to assume it does not happen.
>
> Really?
>
> Just because something is undefined assuming it never happens is a bit
> of a leap of faith IMO.
More precisely, if something has undefined semantics then the compiler
is allowed to do whatever it likes. Normally the compiler will try to
do "what's right", but if they have an optimisation opportunity then
they will normally take it.
In other words by assuming it "doesn't happen" they get to perform an
optimisation that they could not do otherwise, and they get to perform
"correctly" in an undefined way when the overflow would happen.
Cheers,
Paul
[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 186 bytes --]
^ permalink raw reply [flat|nested] 54+ messages in thread
* Re: MSEC_TO_JIFFIES is messed up...
2004-05-12 20:40 Jan Olderdissen
2004-05-12 20:46 ` Jeff Garzik
@ 2004-05-12 20:49 ` Andreas Schwab
1 sibling, 0 replies; 54+ messages in thread
From: Andreas Schwab @ 2004-05-12 20:49 UTC (permalink / raw)
To: Jan Olderdissen; +Cc: linux-kernel, netdev
Jan Olderdissen <jan@ixiacom.com> writes:
> Couple nitpicks:
>
>> #define MSEC_TO_JIFFIES(msec) (msec * 10)
#define MSEC_TO_JIFFIES(msec) ((msec) * 10)
>> #define JIFFIES_TO_MESC(jiffies) (jiffies / 10)
>
> #define JIFFIES_TO_MSEC(jiffies) (jiffies / 10)
#define JIFFIES_TO_MSEC(jiffies) ((jiffies) / 10)
Andreas.
--
Andreas Schwab, SuSE Labs, schwab@suse.de
SuSE Linux AG, Maxfeldstraße 5, 90409 Nürnberg, Germany
Key fingerprint = 58CA 54C7 6D53 942B 1756 01D3 44D5 214B 8276 4ED5
"And now for something completely different."
^ permalink raw reply [flat|nested] 54+ messages in thread
* Re: MSEC_TO_JIFFIES is messed up...
2004-05-12 20:40 Jan Olderdissen
@ 2004-05-12 20:46 ` Jeff Garzik
2004-05-12 20:49 ` Andreas Schwab
1 sibling, 0 replies; 54+ messages in thread
From: Jeff Garzik @ 2004-05-12 20:46 UTC (permalink / raw)
To: Jan Olderdissen
Cc: 'Andrew Morton',
Ingo Molnar, davidel, greg, linux-kernel, netdev
Jan Olderdissen wrote:
> Couple nitpicks:
>
>
>>#if HZ=1000
>
>
> #if HZ==1000
>
>
>>#define MSEC_TO_JIFFIES(msec) (msec)
>>#define JIFFIES_TO_MESC(jiffies) (jiffies)
>>#elif HZ=100
>
>
> #elif HZ==100
>
>
>>#define MSEC_TO_JIFFIES(msec) (msec * 10)
>>#define JIFFIES_TO_MESC(jiffies) (jiffies / 10)
>
>
> #define JIFFIES_TO_MSEC(jiffies) (jiffies / 10)
>
>
>>#else
>>#define MSEC_TO_JIFFIES(msec) ((HZ * (msec) + 999) / 1000)
>>#define JIFFIES_TO_MSEC(jiffies) ...
>>#endif
And let's use something other than the name of a global variable in the
macros... it hurts my brain, at least... :)
Jeff
^ permalink raw reply [flat|nested] 54+ messages in thread
* RE: MSEC_TO_JIFFIES is messed up...
@ 2004-05-12 20:40 Jan Olderdissen
2004-05-12 20:46 ` Jeff Garzik
2004-05-12 20:49 ` Andreas Schwab
0 siblings, 2 replies; 54+ messages in thread
From: Jan Olderdissen @ 2004-05-12 20:40 UTC (permalink / raw)
To: 'Andrew Morton', Ingo Molnar
Cc: davidel, jgarzik, greg, linux-kernel, netdev
Couple nitpicks:
> #if HZ=1000
#if HZ==1000
> #define MSEC_TO_JIFFIES(msec) (msec)
> #define JIFFIES_TO_MESC(jiffies) (jiffies)
> #elif HZ=100
#elif HZ==100
> #define MSEC_TO_JIFFIES(msec) (msec * 10)
> #define JIFFIES_TO_MESC(jiffies) (jiffies / 10)
#define JIFFIES_TO_MSEC(jiffies) (jiffies / 10)
> #else
> #define MSEC_TO_JIFFIES(msec) ((HZ * (msec) + 999) / 1000)
> #define JIFFIES_TO_MSEC(jiffies) ...
> #endif
Jan
^ permalink raw reply [flat|nested] 54+ messages in thread
end of thread, other threads:[~2004-05-16 12:12 UTC | newest]
Thread overview: 54+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
[not found] <20040512020700.6f6aa61f.akpm@osdl.org>
2004-05-12 18:19 ` MSEC_TO_JIFFIES is messed up Greg KH
2004-05-12 18:42 ` Jeff Garzik
2004-05-12 19:33 ` Ingo Molnar
2004-05-12 19:47 ` Valdis.Kletnieks
2004-05-12 19:56 ` Davide Libenzi
2004-05-12 20:07 ` Valdis.Kletnieks
2004-05-12 20:28 ` Ingo Molnar
2004-05-12 20:35 ` Ingo Molnar
2004-05-12 20:50 ` Ingo Molnar
2004-05-12 21:03 ` Valdis.Kletnieks
2004-05-12 21:33 ` Davide Libenzi
2004-05-12 21:07 ` Andrew Morton
2004-05-12 21:17 ` Ingo Molnar
2004-05-12 22:18 ` William Lee Irwin III
2004-05-13 17:38 ` Paul Wagland
2004-05-13 19:11 ` Andrew Morton
2004-05-13 19:19 ` Jeff Garzik
2004-05-13 22:40 ` Andrew Morton
2004-05-13 22:40 ` Andrew Morton
2004-05-13 22:41 ` Andrew Morton
2004-05-13 23:02 ` Jeff Garzik
2004-05-13 19:50 ` Paul Wagland
2004-05-12 23:33 ` Peter Williams
2004-05-12 19:49 ` Davide Libenzi
2004-05-12 20:03 ` Ingo Molnar
2004-05-12 20:18 ` Valdis.Kletnieks
2004-05-12 20:20 ` Andrew Morton
2004-05-12 20:24 ` Jeff Garzik
2004-05-12 20:35 ` Andrew Morton
2004-05-12 20:44 ` Jeff Garzik
2004-05-12 21:03 ` Sridhar Samudrala
2004-05-12 20:32 ` Greg KH
2004-05-12 20:38 ` William Lee Irwin III
2004-05-12 20:47 ` Andrew Morton
2004-05-12 20:58 ` Jeff Garzik
2004-05-12 20:59 ` William Lee Irwin III
2004-05-12 20:55 ` Ingo Molnar
2004-05-12 21:01 ` Davide Libenzi
2004-05-12 21:12 ` Ingo Molnar
2004-05-12 21:40 ` Davide Libenzi
2004-05-12 21:49 ` Zan Lynx
2004-05-12 22:05 ` Roland Dreier
2004-05-12 21:56 ` Zan Lynx
2004-05-12 21:39 ` J. Bruce Fields
2004-05-12 21:55 ` Andreas Schwab
2004-05-12 22:07 ` J. Bruce Fields
2004-05-16 3:48 ` Chris Wedgwood
2004-05-16 12:10 ` Paul Wagland
2004-05-12 20:17 ` Jeff Garzik
2004-05-12 20:54 ` Bill Rugolsky Jr.
2004-05-12 22:44 ` Bill Rugolsky Jr.
2004-05-12 20:40 Jan Olderdissen
2004-05-12 20:46 ` Jeff Garzik
2004-05-12 20:49 ` Andreas Schwab
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).