lkml.org 
[lkml]   [2004]   [May]   [13]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    Date
    From
    SubjectRe: MSEC_TO_JIFFIES is messed up...
    Paul Wagland <paul@wagland.net> wrote:
    >
    > > -#if HZ == 1000
    > > -# define JIFFIES_TO_MSECS(x) (x)
    > > -# define MSECS_TO_JIFFIES(x) (x)
    > > -#elif HZ == 100
    > > -# define JIFFIES_TO_MSECS(x) ((x) * 10)
    > > -# define MSECS_TO_JIFFIES(x) (((x) + 9) / 10)
    > > +#if HZ <= 1000 && !(1000 % HZ)
    > > +# define JIFFIES_TO_MSECS(j) ((1000/HZ)*(j))
    > > +# define MSECS_TO_JIFFIES(m) (((m) + (1000/HZ) - 1)/(1000/HZ))
    > > +#elif HZ > 1000 && !(HZ % 1000)
    > > +# define JIFFIES_TO_MSECS(j) (((j) + (HZ/1000) - 1)/(HZ/1000))
    > > +# define MSECS_TO_JIFFIES(m) ((m)*(HZ/1000))
    > > #else
    > > # define JIFFIES_TO_MSECS(x) (((x) * 1000) / HZ)
    > > # define MSECS_TO_JIFFIES(x) (((x) * HZ + 999) / 1000)
    >
    > Also, can we keep the same parameter name across all of the macros?

    Fair enough.

    --- 25/include/linux/time.h~MSEC_TO_JIFFIES-fixups-tidy 2004-05-13 12:09:27.463273344 -0700
    +++ 25-akpm/include/linux/time.h 2004-05-13 12:09:41.300169816 -0700
    @@ -191,8 +191,8 @@ struct timezone {
    # define JIFFIES_TO_MSECS(j) (((j) + (HZ/1000) - 1)/(HZ/1000))
    # define MSECS_TO_JIFFIES(m) ((m)*(HZ/1000))
    #else
    -# define JIFFIES_TO_MSECS(x) (((x) * 1000) / HZ)
    -# define MSECS_TO_JIFFIES(x) (((x) * HZ + 999) / 1000)
    +# define JIFFIES_TO_MSECS(j) (((j) * 1000) / HZ)
    +# define MSECS_TO_JIFFIES(m) (((m) * HZ + 999) / 1000)
    #endif

    /*
    > This changes behaviour when HZ==(z)000
    >
    > JIFFIES_TO_MSECS goes from
    > ((x) * 1000) / (z)000 to (((x) + (z) - 1)/(z))
    >
    > i.e. for x=1, z=2 this goes from ((1)*1000)/2000)=0 to (((1)+(2)-1)/2)=1

    hm, so you're saying that we now round 0.5 up to 1 rather than down to zero?

    > However, MSECS_TO_JIFFIES remains the same going from
    > (((x) * (z)000 + 999) / 1000) to ((x)*(z))
    >
    > I.e. they basically reduce down to the same thing (modulo overflows)
    >
    > All of the other permuations look correct to me...
    -
    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 14:03    [W:3.222 / U:0.804 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site