From: Linus Walleij <linus.ml.walleij@gmail.com>
To: linux-kernel@vger.kernel.org, mingo@elte.hu, peterz@infradead.org
Cc: linux-arm-kernel@lists.arm.linux.org.uk
Subject: [PATCH] U300 sched_clock implementation
Date: Sat, 23 May 2009 23:46:22 +0200 [thread overview]
Message-ID: <63386a3d0905231446h245bb4a9gec111f68a74a44e4@mail.gmail.com> (raw)
In-Reply-To: <63386a3d0905112337p2d426481o5f9bf9b9489cc57e@mail.gmail.com>
This patch was submitted to the ARM Linux maillist, but we need
some scheduler person to have a look at this sched_clock() thing.
The U300 timekeeping code is in the -next tree at:
arch/arm/mach-u300/time.c
The OMAP2 solution is in:
arch/arm/plat-omap/common.c
When I look at it I get the feeling, that if this works at all times, then
anything that has a continous clock source should actually
implement it this way if they have nothing else so schedule with.
I wonder how hard that would be to do in a generic way.
PATCH FOLLOWS
This overrides the global sched_clock() symbol in the Linux
scheduler with a local implementation which takes advantage of
the timesource in U300 giving a scheduling resolution of 1us. The
solution is the same as found in the OMAP2 core code.
Signed-off-by: Linus Walleij <linus.walleij@stericsson.com>
---
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 4bf82f8..222de18 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 sched_clock(void)
+{
+ unsigned long long ret;
+
+ ret = (unsigned long long) u300_get_cycles();
+ 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
next parent reply other threads:[~2009-05-23 21:46 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <63386a3d0905112337p2d426481o5f9bf9b9489cc57e@mail.gmail.com>
2009-05-23 21:46 ` Linus Walleij [this message]
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
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=63386a3d0905231446h245bb4a9gec111f68a74a44e4@mail.gmail.com \
--to=linus.ml.walleij@gmail.com \
--cc=linux-arm-kernel@lists.arm.linux.org.uk \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@elte.hu \
--cc=peterz@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
all inboxes | Powered by JetHome®