linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] Allow CLOCK_TICK_RATE to be undefined
@ 2012-07-17 16:41 Catalin Marinas
  2012-07-18 22:51 ` Andrew Morton
  0 siblings, 1 reply; 4+ messages in thread
From: Catalin Marinas @ 2012-07-17 16:41 UTC (permalink / raw)
  To: linux-kernel; +Cc: John Stultz, Andrew Morton, Arnd Bergmann

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: John Stultz <john.stultz@linaro.org>
Cc: Andrew Morton <akpm@linux-foundation.org>
---
 include/linux/jiffies.h |   10 +++++++---
 1 files changed, 7 insertions(+), 3 deletions(-)

diff --git a/include/linux/jiffies.h b/include/linux/jiffies.h
index 265e2c3..a2134be 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))
+#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))


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] Allow CLOCK_TICK_RATE to be undefined
  2012-07-17 16:41 [PATCH] Allow CLOCK_TICK_RATE to be undefined Catalin Marinas
@ 2012-07-18 22:51 ` Andrew Morton
  2012-07-18 23:11   ` John Stultz
  0 siblings, 1 reply; 4+ messages in thread
From: Andrew Morton @ 2012-07-18 22:51 UTC (permalink / raw)
  To: Catalin Marinas; +Cc: linux-kernel, John Stultz, Arnd Bergmann

On Tue, 17 Jul 2012 17:41:40 +0100
Catalin Marinas <catalin.marinas@arm.com> wrote:

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

No reason was given for this change.

So those people who are wondering "why don't you just define
CLOCK_TICK_RATE" are made all sad.


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] Allow CLOCK_TICK_RATE to be undefined
  2012-07-18 22:51 ` Andrew Morton
@ 2012-07-18 23:11   ` John Stultz
  2012-07-19  9:22     ` Catalin Marinas
  0 siblings, 1 reply; 4+ messages in thread
From: John Stultz @ 2012-07-18 23:11 UTC (permalink / raw)
  To: Andrew Morton; +Cc: Catalin Marinas, linux-kernel, Arnd Bergmann

On 07/18/2012 03:51 PM, Andrew Morton wrote:
> On Tue, 17 Jul 2012 17:41:40 +0100
> Catalin Marinas <catalin.marinas@arm.com> wrote:
>
>> This patch allows an architecture to not define CLOCK_TICK_RATE, in
>> which case ACTHZ defaults to (HZ << 8).
> No reason was given for this change.
>
> So those people who are wondering "why don't you just define
> CLOCK_TICK_RATE" are made all sad.

I just queued this patch with a revised commit message:

     jiffies: Allow CLOCK_TICK_RATE to be undefined

     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).


Let me know if you'd like to see further improvements.

thanks
-john


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] Allow CLOCK_TICK_RATE to be undefined
  2012-07-18 23:11   ` John Stultz
@ 2012-07-19  9:22     ` Catalin Marinas
  0 siblings, 0 replies; 4+ messages in thread
From: Catalin Marinas @ 2012-07-19  9:22 UTC (permalink / raw)
  To: John Stultz; +Cc: Andrew Morton, linux-kernel@vger.kernel.org, Arnd Bergmann

On Thu, Jul 19, 2012 at 12:11:03AM +0100, John Stultz wrote:
> On 07/18/2012 03:51 PM, Andrew Morton wrote:
> > On Tue, 17 Jul 2012 17:41:40 +0100
> > Catalin Marinas <catalin.marinas@arm.com> wrote:
> >
> >> This patch allows an architecture to not define CLOCK_TICK_RATE, in
> >> which case ACTHZ defaults to (HZ << 8).
> > No reason was given for this change.
> >
> > So those people who are wondering "why don't you just define
> > CLOCK_TICK_RATE" are made all sad.
> 
> I just queued this patch with a revised commit message:
> 
>      jiffies: Allow CLOCK_TICK_RATE to be undefined
> 
>      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).
> 
> 
> Let me know if you'd like to see further improvements.

Looks good. Thanks for picking this up.

-- 
Catalin

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2012-07-19  9:23 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-07-17 16:41 [PATCH] Allow CLOCK_TICK_RATE to be undefined Catalin Marinas
2012-07-18 22:51 ` Andrew Morton
2012-07-18 23:11   ` John Stultz
2012-07-19  9:22     ` Catalin Marinas

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).