From: Sridhar Samudrala <sri@us.ibm.com>
To: Andrew Morton <akpm@osdl.org>
Cc: Jeff Garzik <jgarzik@pobox.com>,
mingo@elte.hu, davidel@xmailserver.org, greg@kroah.com,
linux-kernel@vger.kernel.org, netdev@oss.sgi.com
Subject: Re: MSEC_TO_JIFFIES is messed up...
Date: Wed, 12 May 2004 14:03:24 -0700 (PDT) [thread overview]
Message-ID: <Pine.LNX.4.58.0405121352060.8535@localhost.localdomain> (raw)
In-Reply-To: <20040512133520.44fbfd39.akpm@osdl.org>
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.
>
>
next prev parent reply other threads:[~2004-05-12 21:10 UTC|newest]
Thread overview: 54+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20040512020700.6f6aa61f.akpm@osdl.org>
2004-05-12 18:19 ` 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 [this message]
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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=Pine.LNX.4.58.0405121352060.8535@localhost.localdomain \
--to=sri@us.ibm.com \
--cc=akpm@osdl.org \
--cc=davidel@xmailserver.org \
--cc=greg@kroah.com \
--cc=jgarzik@pobox.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@elte.hu \
--cc=netdev@oss.sgi.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®