From: Ingo Molnar <mingo@elte.hu>
To: David Miller <davem@davemloft.net>
Cc: rdreier@cisco.com, linux-kernel@vger.kernel.org
Subject: Re: Strange hang on ia64 with CONFIG_PRINTK_TIME=y
Date: Wed, 13 Feb 2008 13:57:25 +0100 [thread overview]
Message-ID: <20080213125725.GC6344@elte.hu> (raw)
In-Reply-To: <20080212.230156.33759433.davem@davemloft.net>
* David Miller <davem@davemloft.net> wrote:
> The kernel now derefernces per-cpu variables very early, essentially
> in the very first printk() (via printk()'s call to cpu_clock()).
>
> This bit me on sparc64 because of how I do the per-cpu address
> formation. If I booted on a non-zero cpuid things would explode.
>
> You might be hitting something similar.
hm. But the raw sched_clock() use was wrong. We could either go back to
jiffies (which is certainly the simplest and was used before
printk_clock() was introduced which incorrectly relied on sched_clock())
- but that loses precision and the same issue will re-visit us once we
go totally tickless and start to map jiffies to GTOD ...
so .. how about the patch below? Note that we already had an "early
bootup" special (the rq->idle check), it's now just made explicit via
the scheduler_running flag.
Ingo
---------------------->
Subject: sched: make sched_clock() early-bootup capable
From: Ingo Molnar <mingo@elte.hu>
Date: Wed Feb 13 13:49:36 CET 2008
do not call sched_clock() too early. Not only might rq->idle
not be set up - but pure per-cpu data might not be accessible
either.
Signed-off-by: Ingo Molnar <mingo@elte.hu>
---
kernel/sched.c | 14 ++++++++++----
1 file changed, 10 insertions(+), 4 deletions(-)
Index: linux-x86.q/kernel/sched.c
===================================================================
--- linux-x86.q.orig/kernel/sched.c
+++ linux-x86.q/kernel/sched.c
@@ -666,6 +666,8 @@ const_debug unsigned int sysctl_sched_rt
*/
const_debug unsigned int sysctl_sched_rt_ratio = 62259;
+static __readmostly int scheduler_running;
+
/*
* For kernel-internal use: high-speed (but slightly incorrect) per-cpu
* clock constructed from sched_clock():
@@ -676,14 +678,16 @@ unsigned long long cpu_clock(int cpu)
unsigned long flags;
struct rq *rq;
- local_irq_save(flags);
- rq = cpu_rq(cpu);
/*
* Only call sched_clock() if the scheduler has already been
* initialized (some code might call cpu_clock() very early):
*/
- if (rq->idle)
- update_rq_clock(rq);
+ if (unlikely(!scheduler_running))
+ return 0;
+
+ local_irq_save(flags);
+ rq = cpu_rq(cpu);
+ update_rq_clock(rq);
now = rq->clock;
local_irq_restore(flags);
@@ -7255,6 +7259,8 @@ void __init sched_init(void)
* During early bootup we pretend to be a normal task:
*/
current->sched_class = &fair_sched_class;
+
+ scheduler_running = 1;
}
#ifdef CONFIG_DEBUG_SPINLOCK_SLEEP
next prev parent reply other threads:[~2008-02-13 12:57 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-02-13 6:24 Strange hang on ia64 with CONFIG_PRINTK_TIME=y Roland Dreier
2008-02-13 7:01 ` David Miller
2008-02-13 12:57 ` Ingo Molnar [this message]
2008-02-13 13:02 ` Ingo Molnar
2008-02-14 0:26 ` Roland Dreier
2008-02-13 13:03 ` David Miller
2008-02-13 13:06 ` Ingo Molnar
2008-02-14 0:59 ` Tony Luck
2008-02-14 1:04 ` David Miller
2008-02-14 3:33 ` Tony Luck
2008-02-14 3:47 ` Roland Dreier
2008-02-14 18:24 ` Luck, Tony
2008-02-14 21:27 ` Tony Luck
2008-02-14 22:04 ` Roland Dreier
2008-02-14 22:23 ` Luck, Tony
2008-02-15 2:17 ` Tony Luck
2008-02-19 22:40 ` Tony Luck
2008-02-20 8:12 ` Ingo Molnar
2008-02-20 8:15 ` David Miller
2008-02-20 23:35 ` Roland Dreier
2008-02-20 23:36 ` Roland Dreier
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=20080213125725.GC6344@elte.hu \
--to=mingo@elte.hu \
--cc=davem@davemloft.net \
--cc=linux-kernel@vger.kernel.org \
--cc=rdreier@cisco.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