Re: Fwd: Commit 76a2a6ee8a0660a29127f05989ac59ae1ce865fa breaks PXA270 (at least)?

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: Peter Zijlstra
Date: Thursday, July 31, 2008 - 2:47 pm

On Thu, 2008-07-31 at 23:37 +0200, Ingo Molnar wrote:

How about something like this, it builds an atificial delay, exactly
like we already have for the HAVE_UNSTABLE_SCHED_CLOCK case.

This keeps cpu_clock() 0 until after sched_clock_init().

Russell, Bill, is this sufficient?

Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
---
diff --git a/include/linux/sched.h b/include/linux/sched.h
index 1b26ed2..d13264b 100644
--- a/include/linux/sched.h
+++ b/include/linux/sched.h
@@ -1550,16 +1550,10 @@ static inline int set_cpus_allowed(struct task_struct *p, cpumask_t new_mask)
 
 extern unsigned long long sched_clock(void);
 
-#ifndef CONFIG_HAVE_UNSTABLE_SCHED_CLOCK
-static inline void sched_clock_init(void)
-{
-}
-
-static inline u64 sched_clock_cpu(int cpu)
-{
-	return sched_clock();
-}
+extern void sched_clock_init(void);
+extern u64 sched_clock_cpu(int cpu);
 
+#ifndef CONFIG_HAVE_UNSTABLE_SCHED_CLOCK
 static inline void sched_clock_tick(void)
 {
 }
@@ -1583,8 +1577,6 @@ static inline void sched_clock_tick_start(int cpu)
 #endif
 
 #else /* CONFIG_HAVE_UNSTABLE_SCHED_CLOCK */
-extern void sched_clock_init(void);
-extern u64 sched_clock_cpu(int cpu);
 extern void sched_clock_tick(void);
 extern void sched_clock_idle_sleep_event(void);
 extern void sched_clock_idle_wakeup_event(u64 delta_ns);
diff --git a/kernel/sched_clock.c b/kernel/sched_clock.c
index 22ed55d..a804582 100644
--- a/kernel/sched_clock.c
+++ b/kernel/sched_clock.c
@@ -32,6 +32,7 @@
 #include <linux/ktime.h>
 #include <linux/module.h>
 
+static __read_mostly int sched_clock_running;
 
 #ifdef CONFIG_HAVE_UNSTABLE_SCHED_CLOCK
 
@@ -71,8 +72,6 @@ static inline struct sched_clock_data *cpu_sdc(int cpu)
 	return &per_cpu(sched_clock_data, cpu);
 }
 
-static __read_mostly int sched_clock_running;
-
 void sched_clock_init(void)
 {
 	u64 ktime_now = ktime_to_ns(ktime_get());
@@ -319,6 +318,21 @@ void sched_clock_idle_wakeup_event(u64 delta_ns)
 }
 EXPORT_SYMBOL_GPL(sched_clock_idle_wakeup_event);
 
+#else /* CONFIG_HAVE_UNSTABLE_SCHED_CLOCK */
+
+void sched_clock_init(void)
+{
+	sched_clock_running = 1;
+}
+
+u64 sched_clock_cpu(int cpu)
+{
+	if (unlikely(!sched_clock_running))
+		return 0;
+
+	return sched_clock();
+}
+
 #endif
 
 /*


--
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
Fwd: Commit 76a2a6ee8a0660a29127f05989ac59ae1ce865fa break ..., Russell King - ARM Linux, (Tue Jul 29, 3:31 pm)
Re: Fwd: Commit 76a2a6ee8a0660a29127f05989ac59ae1ce865fa b ..., Russell King - ARM Linux, (Tue Jul 29, 3:56 pm)
Re: Fwd: Commit 76a2a6ee8a0660a29127f05989ac59ae1ce865fa b ..., Russell King - ARM Linux, (Wed Jul 30, 1:00 am)
Re: Fwd: Commit 76a2a6ee8a0660a29127f05989ac59ae1ce865fa b ..., Peter Zijlstra, (Thu Jul 31, 2:47 pm)
Re: Fwd: Commit 76a2a6ee8a0660a29127f05989ac59ae1ce865fa b ..., Russell King - ARM Linux, (Thu Jul 31, 2:57 pm)