Skip to contentSkip to conversation

davinci: Implement sched_clock()

PATCH New Andreas.Gaer at baslerweb.com 3 participants 4 messages Oct 6, 2010 – Oct 8, 2010

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 davinci: Implement sched_clock()

From: Andreas Gaeer <[email protected]>

Overwrite the default implementation of sched_clock that is based on jiffies by something more precise. This improves timestamps in ftrace. Implementation is copied from OMAP platform code.

---
 arch/arm/mach-davinci/time.c |   24 +++++++++++++++++++++++-
 1 files changed, 23 insertions(+), 1 deletions(-)
arch/arm/mach-davinci/time.c +23 -1
index 0f21c36..5d1eea0 100644
@@ -272,15 +272,36 @@ static cycle_t read_cycles(struct clocksource *cs)
 	return (cycles_t)timer32_read(t);
 }
 
+/*
+ * Kernel assumes that sched_clock can be called early but may not have
+ * things ready yet.
+ */
+static cycle_t read_dummy(struct clocksource *cs)
+{
+	return 0;
+}
+
+
 static struct clocksource clocksource_davinci = {
 	.rating		= 300,
-	.read		= read_cycles,
+	.read		= read_dummy,
 	.mask		= CLOCKSOURCE_MASK(32),
 	.shift		= 24,
 	.flags		= CLOCK_SOURCE_IS_CONTINUOUS,
 };
 
 /*
+ * Overwrite weak default sched_clock with something more precise
+ */
+unsigned long long notrace sched_clock(void)
+{
+	const cycle_t cyc = clocksource_davinci.read(&clocksource_davinci);
+
+	return clocksource_cyc2ns(cyc, clocksource_davinci.mult,
+				clocksource_davinci.shift);
+}
+
+/*
  * clockevent
  */
 static int davinci_set_next_event(unsigned long cycles,
@@ -377,6 +398,7 @@ static void __init davinci_timer_init(void)
 	davinci_clock_tick_rate = clk_get_rate(timer_clk);
 
 	/* setup clocksource */
+	clocksource_davinci.read = read_cycles;
 	clocksource_davinci.name = id_to_name[clocksource_id];
 	clocksource_davinci.mult =
 		clocksource_khz2mult(davinci_clock_tick_rate/1000,
Signature · 1 line
1.7.2.2
#1 lore raw

PATCH 1/1 davinci: Implement sched_clock()

Quoted 7 lines · Andreas.Gaer at baslerweb.com

From: Andreas Gaeer <[email protected]>

Overwrite the default implementation of sched_clock that is based on jiffies by something more precise. This improves timestamps in ftrace. Implementation is copied from OMAP platform code.

Thanks, applying to davinci git.

Will queue for 2.6.38 (it's a bit too late for 2.6.37 as Linus only wants real regression fixes after -rc6.)

Kevin

Quoted 54 lines
---
 arch/arm/mach-davinci/time.c |   24 +++++++++++++++++++++++-
 1 files changed, 23 insertions(+), 1 deletions(-)
arch/arm/mach-davinci/time.c +23 -1
index 0f21c36..5d1eea0 100644
@@ -272,15 +272,36 @@ static cycle_t read_cycles(struct clocksource *cs)
 	return (cycles_t)timer32_read(t);
 }
 
+/*
+ * Kernel assumes that sched_clock can be called early but may not have
+ * things ready yet.
+ */
+static cycle_t read_dummy(struct clocksource *cs)
+{
+	return 0;
+}
+
+
 static struct clocksource clocksource_davinci = {
 	.rating		= 300,
-	.read		= read_cycles,
+	.read		= read_dummy,
 	.mask		= CLOCKSOURCE_MASK(32),
 	.shift		= 24,
 	.flags		= CLOCK_SOURCE_IS_CONTINUOUS,
 };
 
 /*
+ * Overwrite weak default sched_clock with something more precise
+ */
+unsigned long long notrace sched_clock(void)
+{
+	const cycle_t cyc = clocksource_davinci.read(&clocksource_davinci);
+
+	return clocksource_cyc2ns(cyc, clocksource_davinci.mult,
+				clocksource_davinci.shift);
+}
+
+/*
  * clockevent
  */
 static int davinci_set_next_event(unsigned long cycles,
@@ -377,6 +398,7 @@ static void __init davinci_timer_init(void)
 	davinci_clock_tick_rate = clk_get_rate(timer_clk);
 
 	/* setup clocksource */
+	clocksource_davinci.read = read_cycles;
 	clocksource_davinci.name = id_to_name[clocksource_id];
 	clocksource_davinci.mult =
 		clocksource_khz2mult(davinci_clock_tick_rate/1000,
#2 lore raw

PATCH 1/1 davinci: Implement sched_clock()

Hello.

Quoted 10 lines · Kevin Hilman
Quoted 5 lines

Overwrite the default implementation of sched_clock that is based on jiffies by something more precise. This improves timestamps in ftrace. Implementation is copied from OMAP platform code.

Thanks, applying to davinci git.

Will queue for 2.6.38 (it's a bit too late for 2.6.37 as Linus only wants real regression fixes after -rc6.)

    Did you mean 2.6.37 and 2.6.36 respecitvely?

WBR, Sergei

#3 lore raw

PATCH 1/1 davinci: Implement sched_clock()

Quoted 8 lines · Sergei Shtylyov

Hello.

Quoted 3 lines · Kevin Hilman
Quoted 3 lines

Overwrite the default implementation of sched_clock that is based on jiffies by something more precise. This improves timestamps in ftrace. Implementation is copied from OMAP platform code.

Quoted 8 lines
Quoted 6 lines
Quoted 1 line

Thanks, applying to davinci git.

Will queue for 2.6.38 (it's a bit too late for 2.6.37 as Linus only wants real regression fixes after -rc6.)

Did you mean 2.6.37 and 2.6.36 respecitvely?

Nope.

IOW, for the upcoming merge window (2.6.37), Linus does not want to see new features done after 2.6.36-rc6. He wants to sure that by the time the merge window opens, that things have received some testing and validation, particularily in linux-next.

This means, that most maintainers (myself included) will not be taking patches/features for 2.6.N merge window after 2.6.(N-1)-rc6 is released, unless they are regression fixes.

Kevin