mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Peter Zijlstra <a.p.zijlstra@chello.nl>
To: bugme-daemon@bugzilla.kernel.org
Cc: Ingo Molnar <mingo@elte.hu>, linux-kernel <linux-kernel@vger.kernel.org>
Subject: Re: [Bug 10648] CONFIG_PRINTK_TIME broken on git HEAD ?
Date: Thu, 15 May 2008 18:48:46 +0200	[thread overview]
Message-ID: <1210870126.6524.16.camel@lappy.programming.kicks-ass.net> (raw)
In-Reply-To: <20080515162703.D4970108060@picon.linux-foundation.org>

Subject: sched: fix sched_clock_cpu()
From: Peter Zijlstra <a.p.zijlstra@chello.nl>

Make sched_clock_cpu() return 0 before it has been initialised and avoid
corrupting its state due to doing so.

Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
---
 kernel/sched_clock.c |   18 ++++++++++++++----
 1 file changed, 14 insertions(+), 4 deletions(-)

Index: linux-2.6/kernel/sched_clock.c
===================================================================
--- linux-2.6.orig/kernel/sched_clock.c	2008-05-13 18:40:35.000000000 +0200
+++ linux-2.6/kernel/sched_clock.c	2008-05-13 18:42:05.000000000 +0200
@@ -60,22 +60,26 @@
 	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());
-	u64 now = 0;
+	unsigned long now_jiffies = jiffies;
 	int cpu;
 
 	for_each_possible_cpu(cpu) {
 		struct sched_clock_data *scd = cpu_sdc(cpu);
 
 		scd->lock = (raw_spinlock_t)__RAW_SPIN_LOCK_UNLOCKED;
-		scd->prev_jiffies = jiffies;
-		scd->prev_raw = now;
-		scd->tick_raw = now;
+		scd->prev_jiffies = now_jiffies;
+		scd->prev_raw = 0;
+		scd->tick_raw = 0;
 		scd->tick_gtod = ktime_now;
 		scd->clock = ktime_now;
 	}
+
+	sched_clock_running = 1;
 }
 
 /*
@@ -137,6 +141,9 @@
 	struct sched_clock_data *scd = cpu_sdc(cpu);
 	u64 now, clock;
 
+	if (unlikely(!sched_clock_running))
+		return 0ull;
+
 	/*
 	 * Normally this is not called in NMI context - but if it is,
 	 * trying to do any locking here is totally lethal.
@@ -182,6 +189,9 @@
 	struct sched_clock_data *scd = this_scd();
 	u64 now, now_gtod;
 
+	if (unlikely(!sched_clock_running))
+		return;
+
 	WARN_ON_ONCE(!irqs_disabled());
 
 	now = sched_clock();



       reply	other threads:[~2008-05-15 16:49 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20080515162703.D4970108060@picon.linux-foundation.org>
2008-05-15 16:48 ` Peter Zijlstra [this message]
2008-05-31 17:44 2.6.26-rc4-git4: Reported regressions from 2.6.25 Rafael J. Wysocki
2008-05-31 17:48 ` [Bug #10648] CONFIG_PRINTK_TIME broken on git HEAD ? Rafael J. Wysocki
2008-06-01  0:45   ` Gabriel C
2008-06-05 21:11     ` Rafael J. Wysocki
  -- strict thread matches above, loose matches on Subject: below --
2008-05-24 20:28 2.6.26-rc3-git7: Reported regressions from 2.6.25 Rafael J. Wysocki
2008-05-24 20:31 ` [Bug #10648] CONFIG_PRINTK_TIME broken on git HEAD ? Rafael J. Wysocki
2008-05-18 11:10 2.6.26-rc2-git5: Reported regressions from 2.6.25 Rafael J. Wysocki
2008-05-18 11:13 ` [Bug #10648] CONFIG_PRINTK_TIME broken on git HEAD ? Rafael J. Wysocki
2008-05-18 17:21   ` Peter Zijlstra
2008-05-18 18:37     ` Peter Zijlstra
2008-05-21  0:38       ` Gabriel C
2008-05-21  1:10         ` Gabriel C
2008-05-11 19:56 2.6.26-rc1-git9: Reported regressions from 2.6.25 Rafael J. Wysocki
2008-05-11 20:04 ` [Bug #10648] CONFIG_PRINTK_TIME broken on git HEAD ? Rafael J. Wysocki

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=1210870126.6524.16.camel@lappy.programming.kicks-ass.net \
    --to=a.p.zijlstra@chello.nl \
    --cc=bugme-daemon@bugzilla.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@elte.hu \
    /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

Powered by JetHome