netdev
[Top] [All Lists]

Re: MSEC_TO_JIFFIES is messed up...

To: Jeff Garzik <jgarzik@xxxxxxxxx>
Subject: Re: MSEC_TO_JIFFIES is messed up...
From: "Bill Rugolsky Jr." <brugolsky@xxxxxxxxxxxxxxxxxxxxxxxxx>
Date: Wed, 12 May 2004 16:54:07 -0400
Cc: Greg KH <greg@xxxxxxxxx>, Andrew Morton <akpm@xxxxxxxx>, mingo@xxxxxxx, linux-kernel@xxxxxxxxxxxxxxx, Netdev <netdev@xxxxxxxxxxx>, Sridhar Samudrala <sri@xxxxxxxxxx>, davem@xxxxxxxxxx, George Anzinger <george@xxxxxxxxxx>
In-reply-to: <40A26FFA.4030701@xxxxxxxxx>
Mail-followup-to: "Bill Rugolsky Jr." <brugolsky@xxxxxxxxxxxxxxxxxxxxxxxxx>, Jeff Garzik <jgarzik@xxxxxxxxx>, Greg KH <greg@xxxxxxxxx>, Andrew Morton <akpm@xxxxxxxx>, mingo@xxxxxxx, linux-kernel@xxxxxxxxxxxxxxx, Netdev <netdev@xxxxxxxxxxx>, Sridhar Samudrala <sri@xxxxxxxxxx>, davem@xxxxxxxxxx, George Anzinger <george@xxxxxxxxxx>
References: <20040512020700.6f6aa61f.akpm@xxxxxxxx> <20040512181903.GG13421@xxxxxxxxx> <40A26FFA.4030701@xxxxxxxxx>
Sender: netdev-bounce@xxxxxxxxxxx
User-agent: Mutt/1.4.1i
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@xxxxxxxxxx>.  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: linux-2.6.6-rc3-bk3-msecs-to-jiffies.patch
Description: Text document

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