From: robherring2@gmail.com (Rob Herring)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH v2 3/3] ARM: arch_timer: use full 64-bit counter for sched_clock
Date: Mon, 1 Apr 2013 15:58:34 -0500 [thread overview]
Message-ID: <1364849914-26420-4-git-send-email-robherring2@gmail.com> (raw)
In-Reply-To: <1364849914-26420-1-git-send-email-robherring2@gmail.com>
From: Rob Herring <rob.herring@calxeda.com>
Only 32-bits of the arch timer were being used and wrapping was needlessly
being done in s/w. By using the full counter (56-64 bits), we don't need
to deal with wrapping and can simplify the implementation when using
arch timer.
Signed-off-by: Rob Herring <rob.herring@calxeda.com>
---
arch/arm/kernel/arch_timer.c | 15 ++++++++++-----
1 file changed, 10 insertions(+), 5 deletions(-)
diff --git a/arch/arm/kernel/arch_timer.c b/arch/arm/kernel/arch_timer.c
index d957a51..a7536d4 100644
--- a/arch/arm/kernel/arch_timer.c
+++ b/arch/arm/kernel/arch_timer.c
@@ -22,9 +22,11 @@ static unsigned long arch_timer_read_counter_long(void)
return arch_timer_read_counter();
}
-static u32 arch_timer_read_counter_u32(void)
+static u32 sched_clock_mult __read_mostly;
+
+static unsigned long long notrace arch_timer_sched_clock(void)
{
- return arch_timer_read_counter();
+ return arch_timer_read_counter() * sched_clock_mult;
}
static struct delay_timer arch_delay_timer;
@@ -52,10 +54,13 @@ int __init arch_timer_of_register(void)
int __init arch_timer_sched_clock_init(void)
{
- if (arch_timer_get_rate() == 0)
+ u32 arch_timer_rate = arch_timer_get_rate();
+
+ if (arch_timer_rate == 0)
return -ENXIO;
- setup_sched_clock(arch_timer_read_counter_u32,
- 32, arch_timer_get_rate());
+ /* Cache the sched_clock multiplier to save a divide in the hot path. */
+ sched_clock_mult = NSEC_PER_SEC / arch_timer_rate;
+ sched_clock_func = arch_timer_sched_clock;
return 0;
}
--
1.7.10.4
next prev parent reply other threads:[~2013-04-01 20:58 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-04-01 20:58 [PATCH v2 0/3] ARM sched_clock selection enhancements Rob Herring
2013-04-01 20:58 ` [PATCH v2 1/3] ARM: sched_clock: allow changing to higher frequency counter Rob Herring
2013-04-01 20:58 ` [PATCH v2 2/3] ARM: make sched_clock just call a function pointer Rob Herring
2013-04-01 20:58 ` Rob Herring [this message]
2013-04-19 16:27 ` [PATCH v2 3/3] ARM: arch_timer: use full 64-bit counter for sched_clock Russell King - ARM Linux
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=1364849914-26420-4-git-send-email-robherring2@gmail.com \
--to=robherring2@gmail.com \
--cc=linux-arm-kernel@lists.infradead.org \
/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).