public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] U300 sched_clock implementation
@ 2009-08-13 11:49 Linus Walleij
  0 siblings, 0 replies; 11+ messages in thread
From: Linus Walleij @ 2009-08-13 11:49 UTC (permalink / raw)
  To: linux-arm-kernel, linux-kernel; +Cc: Peter Zijlstra, Paul Mundt, Linus Walleij

This adds the long debated sched_clock() override for the weak
in-kernel jiffybased sched_clock(). The implementation is more or
less identical to the one used in arch/arm/plat-omap/common.c
and at last attempt to merge this the merge was postponed at the
request of Peter Zijlstra due to pending discussions regarding
generalized clocksource-based sched_clock() implementations by
adding a flag to the clocksource. However that discussion ended
up with the generic code needing to be rewritten and Paul Mundt
see no reason not to proceed with this for the time being as it
can be easily converted once the generic code is in place.

Signed-off-by: Linus Walleij <linus.walleij@stericsson.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Paul Mundt <lethal@linux-sh.org>
---
 arch/arm/mach-u300/timer.c |   16 ++++++++++++++++
 1 files changed, 16 insertions(+), 0 deletions(-)

diff --git a/arch/arm/mach-u300/timer.c b/arch/arm/mach-u300/timer.c
index cce5320..63b5186 100644
--- a/arch/arm/mach-u300/timer.c
+++ b/arch/arm/mach-u300/timer.c
@@ -346,6 +346,22 @@ static struct clocksource clocksource_u300_1mhz = {
 	.flags          = CLOCK_SOURCE_IS_CONTINUOUS,
 };
 
+/*
+ * Override the global weak sched_clock symbol with this
+ * local implementation which uses the clocksource to get some
+ * better resolution when scheduling the kernel. We accept that
+ * this wraps around for now, since it is just a relative time
+ * stamp. (Inspired by OMAP implementation.)
+ */
+unsigned long long notrace sched_clock(void)
+{
+	unsigned long long ret;
+
+	ret = (unsigned long long) u300_get_cycles(&clocksource_u300_1mhz);
+	ret = (ret * clocksource_u300_1mhz.mult_orig) >>
+		clocksource_u300_1mhz.shift;
+	return ret;
+}
 
 /*
  * This sets up the system timers, clock source and clock event.
-- 
1.6.2.1


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

end of thread, other threads:[~2009-08-13 11:52 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <63386a3d0905112337p2d426481o5f9bf9b9489cc57e@mail.gmail.com>
2009-05-23 21:46 ` [PATCH] U300 sched_clock implementation Linus Walleij
2009-05-24  7:57   ` Peter Zijlstra
2009-05-25 12:13     ` Linus Walleij
2009-05-25 13:01       ` Peter Zijlstra
2009-05-25 13:20         ` Peter Zijlstra
2009-06-01  7:46         ` Linus Walleij
2009-06-02  9:00           ` Peter Zijlstra
2009-07-07  7:42             ` Russell King - ARM Linux
2009-07-07  8:01               ` Linus Walleij
2009-07-08  9:35                 ` Paul Mundt
2009-08-13 11:49 Linus Walleij

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox