From: tip-bot for Catalin Marinas <catalin.marinas@arm.com>
To: linux-tip-commits@vger.kernel.org
Cc: linux-kernel@vger.kernel.org, hpa@zytor.com, mingo@kernel.org,
catalin.marinas@arm.com, richardcochran@gmail.com,
john.stultz@linaro.org, arnd@arndb.de, akpm@linux-foundation.org,
tglx@linutronix.de, prarit@redhat.com
Subject: [tip:timers/urgent] time/jiffies: Allow CLOCK_TICK_RATE to be undefined
Date: Tue, 31 Jul 2012 10:59:22 -0700 [thread overview]
Message-ID: <tip-a7ea3bbf5d58f4df2265d312f91d5769eabc8144@git.kernel.org> (raw)
In-Reply-To: <1343414893-45779-2-git-send-email-john.stultz@linaro.org>
Commit-ID: a7ea3bbf5d58f4df2265d312f91d5769eabc8144
Gitweb: http://git.kernel.org/tip/a7ea3bbf5d58f4df2265d312f91d5769eabc8144
Author: Catalin Marinas <catalin.marinas@arm.com>
AuthorDate: Fri, 27 Jul 2012 14:48:09 -0400
Committer: Ingo Molnar <mingo@kernel.org>
CommitDate: Tue, 31 Jul 2012 17:09:12 +0200
time/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).
Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>
Acked-by: Arnd Bergmann <arnd@arndb.de>
Cc: Richard Cochran <richardcochran@gmail.com>
Cc: Prarit Bhargava <prarit@redhat.com>
Cc: Andrew Morton <akpm@linux-foundation.org>
[ Commit log & intention tweaks ]
Signed-off-by: John Stultz <john.stultz@linaro.org>
Link: http://lkml.kernel.org/r/1343414893-45779-2-git-send-email-john.stultz@linaro.org
Signed-off-by: Ingo Molnar <mingo@kernel.org>
---
include/linux/jiffies.h | 12 ++++++++----
1 files 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))
next prev parent reply other threads:[~2012-07-31 17:59 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-07-27 18:48 [PATCH 0/5] time/jiffies changes for tip/timers/core John Stultz
2012-07-27 18:48 ` [PATCH 1/5] jiffies: Allow CLOCK_TICK_RATE to be undefined John Stultz
2012-07-31 17:59 ` tip-bot for Catalin Marinas [this message]
2012-07-27 18:48 ` [PATCH 2/5] jiffies: Rename ACTHZ to SHIFTED_HZ John Stultz
2012-07-31 18:00 ` [tip:timers/urgent] time/jiffies: " tip-bot for John Stultz
2012-07-27 18:48 ` [PATCH 3/5] time: Stray newline cleanups John Stultz
2012-07-31 18:01 ` [tip:timers/urgent] time: Clean up stray newlines tip-bot for John Stultz
2012-07-27 18:48 ` [PATCH 4/5] time: Cleanup offs_real/wall_to_mono and offs_boot/total_sleep_time updates John Stultz
2012-07-31 18:02 ` [tip:timers/urgent] time: Clean up offs_real/ wall_to_mono " tip-bot for John Stultz
2012-07-27 18:48 ` [PATCH 5/5] time: Remove all direct references to timekeeper John Stultz
2012-07-31 18:02 ` [tip:timers/urgent] " tip-bot for John Stultz
2012-07-31 17:45 ` [PATCH 0/5] time/jiffies changes for tip/timers/core Ingo Molnar
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=tip-a7ea3bbf5d58f4df2265d312f91d5769eabc8144@git.kernel.org \
--to=catalin.marinas@arm.com \
--cc=akpm@linux-foundation.org \
--cc=arnd@arndb.de \
--cc=hpa@zytor.com \
--cc=john.stultz@linaro.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-tip-commits@vger.kernel.org \
--cc=mingo@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