Gitweb:     
http://git.kernel.org/git/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=6892b75e60557a48c01d57ba320419a9e2ce9846
Commit:     6892b75e60557a48c01d57ba320419a9e2ce9846
Parent:     bfa274e2436fc7ef72ef51c878083647f1cfd429
Author:     Ingo Molnar <[EMAIL PROTECTED]>
AuthorDate: Wed Feb 13 14:02:36 2008 +0100
Committer:  Ingo Molnar <[EMAIL PROTECTED]>
CommitDate: Mon Feb 25 16:34:16 2008 +0100

    sched: make early bootup sched_clock() use safer
    
    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.
    
    this solves an ia64 early bootup hang with CONFIG_PRINTK_TIME=y.
    
    Tested-by: Tony Luck <[EMAIL PROTECTED]>
    Acked-by: Tony Luck <[EMAIL PROTECTED]>
    Acked-by: David S. Miller <[EMAIL PROTECTED]>
    Signed-off-by: Ingo Molnar <[EMAIL PROTECTED]>
---
 kernel/sched.c |   14 ++++++++++----
 1 files changed, 10 insertions(+), 4 deletions(-)

diff --git a/kernel/sched.c b/kernel/sched.c
index b387a8d..7286ccb 100644
--- a/kernel/sched.c
+++ b/kernel/sched.c
@@ -668,6 +668,8 @@ const_debug unsigned int sysctl_sched_nr_migrate = 32;
  */
 unsigned int sysctl_sched_rt_period = 1000000;
 
+static __read_mostly int scheduler_running;
+
 /*
  * part of the period that we allow rt tasks to run in us.
  * default: 0.95s
@@ -689,14 +691,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);
 
@@ -7284,6 +7288,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
-
To unsubscribe from this list: send the line "unsubscribe git-commits-head" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to