public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Peter Zijlstra <a.p.zijlstra@chello.nl>
To: Ingo Molnar <mingo@elte.hu>
Cc: Andrew Morton <akpm@linux-foundation.org>,
	Russell King - ARM Linux <linux@arm.linux.org.uk>,
	vatsa@linux.vnet.ibm.com, efault@gmx.de,
	linux-kernel@vger.kernel.org, Bill Gatliff <bgat@billgatliff.com>
Subject: Re: Fwd: Commit 76a2a6ee8a0660a29127f05989ac59ae1ce865fa breaks PXA270 (at least)?
Date: Thu, 31 Jul 2008 23:47:55 +0200	[thread overview]
Message-ID: <1217540875.8157.105.camel@twins> (raw)
In-Reply-To: <20080731213741.GJ2729@elte.hu>

On Thu, 2008-07-31 at 23:37 +0200, Ingo Molnar wrote:
> * Andrew Morton <akpm@linux-foundation.org> wrote:
> 
> > On Tue, 29 Jul 2008 23:31:05 +0100
> > Russell King - ARM Linux <linux@arm.linux.org.uk> wrote:
> > 
> > > But then some bright spark thought it would be a good idea to get
> > > rid of printk_clock().
> > 
> > <does git-log, searches for printk_clock>
> 
> i think this is a fresh regression via the introduction of 
> kernel/sched_clock.c. We lost the (known) early-init behavior of 
> cpu_clock() in the !UNSTABLE_SCHED_CLOCK case. The fix would be to 
> restore that, not to reintroduce printk_clock().
> 
> Peter, any ideas?

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
 
 /*



  reply	other threads:[~2008-07-31 21:48 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-07-29 22:31 Fwd: Commit 76a2a6ee8a0660a29127f05989ac59ae1ce865fa breaks PXA270 (at least)? Russell King - ARM Linux
2008-07-29 22:46 ` Andrew Morton
2008-07-29 22:56   ` Russell King - ARM Linux
2008-07-30  7:10     ` Peter Zijlstra
2008-07-30  7:55       ` Peter Zijlstra
2008-07-30  8:00         ` Russell King - ARM Linux
2008-07-30 12:26           ` Bill Gatliff
2008-07-30 12:54           ` Bill Gatliff
2008-07-31 21:37   ` Ingo Molnar
2008-07-31 21:47     ` Peter Zijlstra [this message]
2008-07-31 21:57       ` Russell King - ARM Linux
2008-08-01  3:44         ` Bill Gatliff

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=1217540875.8157.105.camel@twins \
    --to=a.p.zijlstra@chello.nl \
    --cc=akpm@linux-foundation.org \
    --cc=bgat@billgatliff.com \
    --cc=efault@gmx.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@arm.linux.org.uk \
    --cc=mingo@elte.hu \
    --cc=vatsa@linux.vnet.ibm.com \
    /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