From: john stultz <johnstul@us.ibm.com>
To: Andrew Morton <akpm@osdl.org>
Cc: Tim Schmielau <tim@physik3.uni-rostock.de>,
george@mvista.com, kaukasoi@elektroni.ee.tut.fi,
linux-kernel@vger.kernel.org, davem@redhat.com
Subject: Re: /proc or ps tools bug? 2.6.3, time is off
Date: Mon, 03 May 2004 19:40:58 -0700 [thread overview]
Message-ID: <1083638458.9664.134.camel@cog.beaverton.ibm.com> (raw)
In-Reply-To: <Pine.LNX.4.53.0405020352480.26994@gockel.physik3.uni-rostock.de>
On Sat, 2004-05-01 at 18:59, Tim Schmielau wrote:
> On Sat, 1 May 2004, Andrew Morton wrote:
>
> > Tim Schmielau <tim@physik3.uni-rostock.de> wrote:
> > >
> > > +#if (TICK_NSEC % (NSEC_PER_SEC / USER_HZ)) == 0
> >
> > I think this has an inclusion ordering problem.
>
> Yep, we'd need to include timex.h for it. This get's messy.
Well, not too messy. Including timex.h looks to resolve the issue
without trouble. Let me know if I somehow stepped over an issue.
DaveM: Do please note the changes to the TCP code. Having
jiffies_to_clock_t be more then just a #define introduced a few cast
warnings, and I believe the fixes are right, but you can't be too sure.
jiffies-to-clockt-fix_A1:
-------------------------
All,
This patch polishes up Tim Schmielau's (tim@physik3.uni-rostock.de) fix
for jiffies_to_clock_t() and jiffies_64_to_clock_t(). The issues
observed was w/ /proc output not matching up to wall time due to
accumulated error caused by HZ not being exactly 1000 on i386 systems.
The solution is to correct that error by using the more accurate
TICK_NSEC in our calculation.
Additionally, this patch corrects 3 warnings in the TCP layer uncovered
by this change.
***DaveM please review!***
thanks
-john
diff -Nru a/include/linux/times.h b/include/linux/times.h
--- a/include/linux/times.h Mon May 3 19:24:14 2004
+++ b/include/linux/times.h Mon May 3 19:24:14 2004
@@ -2,15 +2,21 @@
#define _LINUX_TIMES_H
#ifdef __KERNEL__
+#include <linux/timex.h>
#include <asm/div64.h>
#include <asm/types.h>
#include <asm/param.h>
-#if (HZ % USER_HZ)==0
-# define jiffies_to_clock_t(x) ((x) / (HZ / USER_HZ))
+static inline clock_t jiffies_to_clock_t(long x)
+{
+#if (TICK_NSEC % (NSEC_PER_SEC / USER_HZ)) == 0
+ return x / (HZ / USER_HZ);
#else
-# define jiffies_to_clock_t(x) ((clock_t) jiffies_64_to_clock_t((u64) x))
+ u64 tmp = (u64)x * TICK_NSEC;
+ do_div(tmp, (NSEC_PER_SEC / USER_HZ));
+ return (long)tmp;
#endif
+}
static inline unsigned long clock_t_to_jiffies(unsigned long x)
{
@@ -34,7 +40,7 @@
static inline u64 jiffies_64_to_clock_t(u64 x)
{
-#if (HZ % USER_HZ)==0
+#if (TICK_NSEC % (NSEC_PER_SEC / USER_HZ)) == 0
do_div(x, HZ / USER_HZ);
#else
/*
@@ -42,8 +48,8 @@
* but even this doesn't overflow in hundreds of years
* in 64 bits, so..
*/
- x *= USER_HZ;
- do_div(x, HZ);
+ x *= TICK_NSEC;
+ do_div(x, (NSEC_PER_SEC / USER_HZ));
#endif
return x;
}
diff -Nru a/net/ipv4/tcp_ipv4.c b/net/ipv4/tcp_ipv4.c
--- a/net/ipv4/tcp_ipv4.c Mon May 3 19:24:14 2004
+++ b/net/ipv4/tcp_ipv4.c Mon May 3 19:24:14 2004
@@ -2452,7 +2452,7 @@
int ttd = req->expires - jiffies;
sprintf(tmpbuf, "%4d: %08X:%04X %08X:%04X"
- " %02X %08X:%08X %02X:%08X %08X %5d %8d %u %d %p",
+ " %02X %08X:%08X %02X:%08lX %08X %5d %8d %u %d %p",
i,
req->af.v4_req.loc_addr,
ntohs(inet_sk(sk)->sport),
@@ -2526,7 +2526,7 @@
srcp = ntohs(tw->tw_sport);
sprintf(tmpbuf, "%4d: %08X:%04X %08X:%04X"
- " %02X %08X:%08X %02X:%08X %08X %5d %8d %d %d %p",
+ " %02X %08X:%08X %02X:%08lX %08X %5d %8d %d %d %p",
i, src, srcp, dest, destp, tw->tw_substate, 0, 0,
3, jiffies_to_clock_t(ttd), 0, 0, 0, 0,
atomic_read(&tw->tw_refcnt), tw);
diff -Nru a/net/ipv6/tcp_ipv6.c b/net/ipv6/tcp_ipv6.c
--- a/net/ipv6/tcp_ipv6.c Mon May 3 19:24:14 2004
+++ b/net/ipv6/tcp_ipv6.c Mon May 3 19:24:14 2004
@@ -1933,7 +1933,7 @@
dest = &req->af.v6_req.rmt_addr;
seq_printf(seq,
"%4d: %08X%08X%08X%08X:%04X %08X%08X%08X%08X:%04X "
- "%02X %08X:%08X %02X:%08X %08X %5d %8d %d %d %p\n",
+ "%02X %08X:%08X %02X:%08lX %08X %5d %8d %d %d %p\n",
i,
src->s6_addr32[0], src->s6_addr32[1],
src->s6_addr32[2], src->s6_addr32[3],
@@ -2019,7 +2019,7 @@
seq_printf(seq,
"%4d: %08X%08X%08X%08X:%04X %08X%08X%08X%08X:%04X "
- "%02X %08X:%08X %02X:%08X %08X %5d %8d %d %d %p\n",
+ "%02X %08X:%08X %02X:%08lX %08X %5d %8d %d %d %p\n",
i,
src->s6_addr32[0], src->s6_addr32[1],
src->s6_addr32[2], src->s6_addr32[3], srcp,
next prev parent reply other threads:[~2004-05-04 2:42 UTC|newest]
Thread overview: 36+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-02-25 1:58 David Ford
2004-02-25 1:54 ` Albert Cahalan
2004-02-25 5:10 ` David Ford
2004-02-25 3:27 ` Albert Cahalan
2004-02-25 16:28 ` George Anzinger
2004-02-25 16:04 ` Albert Cahalan
2004-02-25 20:45 ` George Anzinger
2004-02-25 19:16 ` Albert Cahalan
2004-02-25 21:10 ` George Anzinger
2004-02-26 1:52 ` john stultz
2004-02-26 23:06 ` George Anzinger
2004-02-26 23:10 ` john stultz
2004-02-27 0:20 ` George Anzinger
2004-04-13 22:38 ` john stultz
2004-04-13 22:59 ` George Anzinger
2004-04-14 12:10 ` Tim Schmielau
2004-04-14 17:03 ` George Anzinger
2004-04-14 18:28 ` john stultz
2004-04-15 10:37 ` Petri Kaukasoina
2004-04-15 11:05 ` Tim Schmielau
2004-04-15 16:14 ` Petri Kaukasoina
2004-05-01 13:51 ` Tim Schmielau
2004-05-02 1:41 ` Andrew Morton
2004-05-02 1:59 ` Tim Schmielau
2004-05-04 2:40 ` john stultz [this message]
2004-05-04 6:12 ` Tim Schmielau
2004-05-04 14:59 ` john stultz
2004-05-04 16:50 ` Tim Schmielau
2004-05-07 0:33 ` George Anzinger
2004-05-07 1:21 ` john stultz
2004-05-07 20:41 ` George Anzinger
2004-05-07 21:38 ` john stultz
2004-02-26 23:14 ` George Anzinger
2004-02-25 9:14 ` Petri Kaukasoina
2004-02-25 9:18 ` Petri Kaukasoina
2004-02-25 21:39 ` David Ford
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=1083638458.9664.134.camel@cog.beaverton.ibm.com \
--to=johnstul@us.ibm.com \
--cc=akpm@osdl.org \
--cc=davem@redhat.com \
--cc=george@mvista.com \
--cc=kaukasoi@elektroni.ee.tut.fi \
--cc=linux-kernel@vger.kernel.org \
--cc=tim@physik3.uni-rostock.de \
/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®