linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Ingo Molnar <mingo@kernel.org>
To: John Stultz <john.stultz@linaro.org>
Cc: lkml <linux-kernel@vger.kernel.org>,
	Catalin Marinas <catalin.marinas@arm.com>,
	Andrew Morton <akpm@linux-foundation.org>,
	Richard Cochran <richardcochran@gmail.com>,
	Prarit Bhargava <prarit@redhat.com>,
	Thomas Gleixner <tglx@linutronix.de>
Subject: Re: [PATCH 1/2] jiffies: Allow CLOCK_TICK_RATE to be undefined
Date: Thu, 19 Jul 2012 11:37:04 +0200	[thread overview]
Message-ID: <20120719093704.GB27086@gmail.com> (raw)
In-Reply-To: <1342660753-10382-2-git-send-email-john.stultz@linaro.org>


* John Stultz <john.stultz@linaro.org> wrote:

> 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 tweaks]
> Signed-off-by: John Stultz <john.stultz@linaro.org>
> ---
>  include/linux/jiffies.h |   10 +++++++---
>  1 file 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

The ACTHZ naming ugliness slipped past me. 'ACT' can mean so 
many things - please improve it to something more obvious, like 
'REAL_HZ' or 'KERNEL_HZ'.

Also, we tend to write such #if/#else/#endif patterns as:

#if FOO
# define BAR 
#else
# define BAZ
#endif

Thanks,

	Ingo

  reply	other threads:[~2012-07-19  9:37 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-07-19  1:19 [PATCH 0/2] Additional time changes for 3.6 John Stultz
2012-07-19  1:19 ` [PATCH 1/2] jiffies: Allow CLOCK_TICK_RATE to be undefined John Stultz
2012-07-19  9:37   ` Ingo Molnar [this message]
2012-07-23 19:37     ` John Stultz
2012-07-26 12:56       ` Ingo Molnar
2012-07-19  1:19 ` [PATCH 2/2] time: Cleanup offs_real/wall_to_mono and offs_boot/total_sleep_time updates John Stultz
2012-07-19  9:33   ` Ingo Molnar
2012-07-23 19:31     ` John Stultz
2012-07-26 12:57       ` Ingo Molnar
2012-07-19 12:37   ` Prarit Bhargava

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20120719093704.GB27086@gmail.com \
    --to=mingo@kernel.org \
    --cc=akpm@linux-foundation.org \
    --cc=catalin.marinas@arm.com \
    --cc=john.stultz@linaro.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=prarit@redhat.com \
    --cc=richardcochran@gmail.com \
    --cc=tglx@linutronix.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).