diff options
author | Ingo Molnar <mingo@elte.hu> | 2008-11-12 14:05:50 -0500 |
---|---|---|
committer | Ingo Molnar <mingo@elte.hu> | 2008-11-12 14:05:50 -0500 |
commit | 5cbd54ef470d880fc37fbe4b21eb514806d51e0d (patch) | |
tree | db9a73e605e0a2e7cfa13bd9697a113b5f6649eb /kernel | |
parent | a2d477778e82a60a0b7114cefdb70aa43af28782 (diff) |
sched: fix init_idle()'s use of sched_clock()
Maciej Rutecki reported:
> I have this bug during suspend to disk:
>
> [ 188.592151] Enabling non-boot CPUs ...
> [ 188.592151] SMP alternatives: switching to SMP code
> [ 188.666058] BUG: using smp_processor_id() in preemptible
> [00000000]
> code: suspend_to_disk/2934
> [ 188.666064] caller is native_sched_clock+0x2b/0x80
Which, as noted by Linus, was caused by me, via:
7cbaef9c "sched: optimize sched_clock() a bit"
Move the rq locking a bit earlier in the initialization sequence,
that will make the sched_clock() call in init_idle() non-preemptible.
Reported-by: Maciej Rutecki <maciej.rutecki@gmail.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'kernel')
-rw-r--r-- | kernel/sched.c | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/kernel/sched.c b/kernel/sched.c index 3bafbe350f4f..c94baf2969e7 100644 --- a/kernel/sched.c +++ b/kernel/sched.c | |||
@@ -5870,6 +5870,8 @@ void __cpuinit init_idle(struct task_struct *idle, int cpu) | |||
5870 | struct rq *rq = cpu_rq(cpu); | 5870 | struct rq *rq = cpu_rq(cpu); |
5871 | unsigned long flags; | 5871 | unsigned long flags; |
5872 | 5872 | ||
5873 | spin_lock_irqsave(&rq->lock, flags); | ||
5874 | |||
5873 | __sched_fork(idle); | 5875 | __sched_fork(idle); |
5874 | idle->se.exec_start = sched_clock(); | 5876 | idle->se.exec_start = sched_clock(); |
5875 | 5877 | ||
@@ -5877,7 +5879,6 @@ void __cpuinit init_idle(struct task_struct *idle, int cpu) | |||
5877 | idle->cpus_allowed = cpumask_of_cpu(cpu); | 5879 | idle->cpus_allowed = cpumask_of_cpu(cpu); |
5878 | __set_task_cpu(idle, cpu); | 5880 | __set_task_cpu(idle, cpu); |
5879 | 5881 | ||
5880 | spin_lock_irqsave(&rq->lock, flags); | ||
5881 | rq->curr = rq->idle = idle; | 5882 | rq->curr = rq->idle = idle; |
5882 | #if defined(CONFIG_SMP) && defined(__ARCH_WANT_UNLOCKED_CTXSW) | 5883 | #if defined(CONFIG_SMP) && defined(__ARCH_WANT_UNLOCKED_CTXSW) |
5883 | idle->oncpu = 1; | 5884 | idle->oncpu = 1; |