sched/fair: remove printk while schedule is in progress
authorCaesar Wang <wxt@rock-chips.com>
Tue, 23 Aug 2016 10:47:02 +0000 (11:47 +0100)
committerTodd Kjos <tkjos@google.com>
Wed, 21 Sep 2016 17:22:39 +0000 (10:22 -0700)
It will cause deadlock and while(1) if call printk while schedule is in
progress. The block state like as below:

cpu0(hold the console sem):
printk->console_unlock->up_sem->spin_lock(&sem->lock)->wake_up_process(cpu1)
->try_to_wake_up(cpu1)->while(p->on_cpu).

cpu1(request console sem):
console_lock->down_sem->schedule->idle_banlance->update_cpu_capacity->
printk->console_trylock->spin_lock(&sem->lock).

p->on_cpu will be 1 forever, because the task is still running on cpu1,
so cpu0 is blocked in while(p->on_cpu), but cpu1 could not get
spin_lock(&sem->lock), it is blocked too, it means the task will running
on cpu1 forever.

Signed-off-by: Caesar Wang <wxt@rock-chips.com>
kernel/sched/fair.c

index 7e42cd11e430ceefdb48f0c77a38c987c4517393..6b881cf81d79f81a88aae3d7e7697fc31bd461a1 100644 (file)
@@ -7089,7 +7089,8 @@ static void update_cpu_capacity(struct sched_domain *sd, int cpu)
                mcc->cpu = cpu;
 #ifdef CONFIG_SCHED_DEBUG
                raw_spin_unlock_irqrestore(&mcc->lock, flags);
-               pr_info("CPU%d: update max cpu_capacity %lu\n", cpu, capacity);
+               printk_deferred(KERN_INFO "CPU%d: update max cpu_capacity %lu\n",
+                               cpu, capacity);
                goto skip_unlock;
 #endif
        }