[lkml]   [2005]   [Apr]   [18]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
Messages in this thread
Patch in this message
Subject[2.6 PATCH] include/linux/jiffies.h cputime miscalculation
static inline clock_t jiffies_to_clock_t(long x)
uses a signed long as input (jiffies) while the return value of
static inline unsigned long clock_t_to_jiffies(unsigned long x)
is an unsigned long.

As long as x is <= 0x7FFFFFFF everything is fine in jiffies_to_clock_t()
but when x is >= 0x80000000 the return value of the function is

I've noticed this while watching the stats of long running processes
(/proc/<PID>/stat) on i386 machines. Up to ~35785 minutes of consumed
CPU-time for a process it's ok but only one minute later there's a huge
jump in the reported CPU-time to ~319786 minutes.

With the Patch you can get straight up to ~71571 minutes of CPU time
you'll restart at 0 (jiffies 32bit wrap around from (2**32)-1 to 0)

For non-i386 you may get other periods of time until the overflow

Signed-off-by: Oliver Weihe <>

Patch based on

--- include/linux/jiffies.h.orig 2005-04-18 14:57:42.000000000 +0200
+++ include/linux/jiffies.h 2005-04-18 14:58:05.000000000 +0200
@@ -380,7 +380,7 @@ jiffies_to_timeval(const unsigned long j
* Convert jiffies/jiffies_64 to clock_t and back.
-static inline clock_t jiffies_to_clock_t(long x)
+static inline clock_t jiffies_to_clock_t(unsigned long x)
return x / (HZ / USER_HZ);
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to
More majordomo info at
Please read the FAQ at

 \ /
  Last update: 2005-04-18 15:22    [W:0.035 / U:1.056 seconds]
©2003-2018 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site