lkml.org 
[lkml]   [2004]   [May]   [1]   [last100]   RSS Feed
Views: [more markup]  [less markup]  [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
DateSat, 1 May 2004 15:51:32 +0200 (CEST)
FromTim Schmielau <>
SubjectRe: /proc or ps tools bug? 2.6.3, time is off
On Thu, 15 Apr 2004, Petri Kaukasoina wrote:
> On Thu, Apr 15, 2004 at 01:05:17PM +0200, Tim Schmielau wrote:
> > On Thu, 15 Apr 2004, Petri Kaukasoina wrote:
> > 
> > > If we are still talking about the problem with ps showing process start 
> > > times in future, I'm sorry neither of the patches helped. The error grows
> > > here at a rate of 15 seconds in 24 hours as before.
> > 
> > Oops...
> > sure, it cannot. Maybe this one is better...
> > 
> > 
> > --- linux-2.6.5/include/linux/times.h	2004-02-04 04:43:09.000000000 +0100
> > +++ linux-2.6.5-jfix1/include/linux/times.h	2004-04-15 12:59:05.000000000 +0200
> 
> Yes, it seems to have fixed it. There is a small error: ps shows a start
> time of a new minute about four seconds too early, but the error stays
> constant and does not change as a function of uptime any longer. (Actually
> it still does but only at the same rate as ntpd corrects time.)
> 
> -Petri
> 

John, George,

can you take care of the patch so it doesn't get lost?

I don't know how to handle the ntpd issue, which I guess also is the 
reason of the four seconds difference. 

Thanks,
Tim


--- linux-2.6.5/include/linux/times.h	2004-02-04 04:43:09.000000000 +0100
+++ linux-2.6.5-jfix1/include/linux/times.h	2004-04-15 12:59:05.000000000 +0200
@@ -6,11 +6,16 @@
 #include <asm/types.h>
 #include <asm/param.h>
 
-#if (HZ % USER_HZ)==0
-# define jiffies_to_clock_t(x) ((x) / (HZ / USER_HZ))
-#else
-# define jiffies_to_clock_t(x) ((clock_t) jiffies_64_to_clock_t((u64) x))
-#endif
+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
+	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 +39,7 @@ static inline unsigned long clock_t_to_j
 
 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 +47,8 @@ static inline u64 jiffies_64_to_clock_t(
 	 * 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;
 }
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/
\
 
 \ /
  Last update: 2005-03-22 13:02    [from the cache]
©2003-2008