lkml.org 
[lkml]   [2005]   [Apr]   [18]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    Date
    From
    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
    miscalculated.

    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
    until
    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
    happens.

    Signed-off-by: Oliver Weihe <o.weihe@deltacomputer.de>

    Patch based on 2.6.11.7

    --- 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)
    {
    #if (TICK_NSEC % (NSEC_PER_SEC / USER_HZ)) == 0
    return x / (HZ / USER_HZ);
    -
    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-04-18 15:22    [W:0.032 / U:88.380 seconds]
    ©2003-2016 Jasper Spaans. hosted at Digital OceanAdvertise on this site