lkml.org 
[lkml]   [2012]   [Jul]   [27]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    From
    Subject[PATCH 1/5] jiffies: Allow CLOCK_TICK_RATE to be undefined
    Date
    From: Catalin Marinas <catalin.marinas@arm.com>

    CLOCK_TICK_RATE is a legacy constant that defines the timer
    device's granularity. On hardware with particularly coarse
    granularity, this constant is used to reduce accumulated
    time error when using jiffies as a clocksource, by calculating
    the hardware's actual tick length rather then just assuming
    it is 1sec/HZ.

    However, for the most part this is unnecessary, as most modern
    systems don't use jiffies for their clocksource, and their
    tick device is sufficiently fine grained to avoid major error.

    Thus, this patch allows an architecture to not define
    CLOCK_TICK_RATE, in which case ACTHZ defaults to (HZ << 8).

    Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>
    Acked-by: Arnd Bergmann <arnd@arndb.de>
    Cc: Andrew Morton <akpm@linux-foundation.org>
    Cc: Ingo Molnar <mingo@kernel.org>
    Cc: Richard Cochran <richardcochran@gmail.com>
    Cc: Prarit Bhargava <prarit@redhat.com>
    Cc: Thomas Gleixner <tglx@linutronix.de>
    [jstultz: commit log & intention tweaks]
    Signed-off-by: John Stultz <john.stultz@linaro.org>
    ---
    include/linux/jiffies.h | 12 ++++++++----
    1 file changed, 8 insertions(+), 4 deletions(-)

    diff --git a/include/linux/jiffies.h b/include/linux/jiffies.h
    index 265e2c3..7d24466 100644
    --- a/include/linux/jiffies.h
    +++ b/include/linux/jiffies.h
    @@ -39,9 +39,6 @@
    # error Invalid value of HZ.
    #endif

    -/* LATCH is used in the interval timer and ftape setup. */
    -#define LATCH ((CLOCK_TICK_RATE + HZ/2) / HZ) /* For divider */
    -
    /* Suppose we want to divide two numbers NOM and DEN: NOM/DEN, then we can
    * improve accuracy by shifting LSH bits, hence calculating:
    * (NOM << LSH) / DEN
    @@ -54,8 +51,15 @@
    #define SH_DIV(NOM,DEN,LSH) ( (((NOM) / (DEN)) << (LSH)) \
    + ((((NOM) % (DEN)) << (LSH)) + (DEN) / 2) / (DEN))

    +#ifdef CLOCK_TICK_RATE
    +/* LATCH is used in the interval timer and ftape setup. */
    +# define LATCH ((CLOCK_TICK_RATE + HZ/2) / HZ) /* For divider */
    +
    /* HZ is the requested value. ACTHZ is actual HZ ("<< 8" is for accuracy) */
    -#define ACTHZ (SH_DIV (CLOCK_TICK_RATE, LATCH, 8))
    +# define ACTHZ (SH_DIV(CLOCK_TICK_RATE, LATCH, 8))
    +#else
    +# define ACTHZ (HZ << 8)
    +#endif

    /* TICK_NSEC is the time between ticks in nsec assuming real ACTHZ */
    #define TICK_NSEC (SH_DIV (1000000UL * 1000, ACTHZ, 8))
    --
    1.7.9.5


    \
     
     \ /
      Last update: 2012-07-27 21:41    [W:0.027 / U:29.560 seconds]
    ©2003-2016 Jasper Spaans. hosted at Digital OceanAdvertise on this site