lkml.org 
[lkml]   [2011]   [Feb]   [3]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
SubjectRe: [RFC][PATCH 14/18] sched: Remove rq->lock from the first half of ttwu()
From
Date
On Fri, 2011-01-28 at 17:05 -0800, Frank Rowand wrote:
>
> The deadlock can occur if __ARCH_WANT_UNLOCKED_CTXSW and
> __ARCH_WANT_INTERRUPTS_ON_CTXSW are defined.
>
> A task sets p->state = TASK_UNINTERRUPTIBLE, then calls schedule().
>
> schedule()
> prev->on_rq = 0
> context_switch()
> prepare_task_switch()
> prepare_lock_switch()
> raw_spin_unlock_irq(&rq->lock)
>
> At this point, a pending interrupt (on this same cpu) is handled.
> The interrupt handling results in a call to try_to_wake_up() on the
> current process. The try_to_wake_up() gets into:
>
> while (p->on_cpu)
> cpu_relax();
>
> and spins forever. This is because "prev->on_cpu = 0" slightly
> after this point at:
>
> finish_task_switch()
> finish_lock_switch()
> prev->on_cpu = 0

Right, very good spot!

>
> One possible fix would be to get rid of __ARCH_WANT_INTERRUPTS_ON_CTXSW.
> I don't suspect the reaction to that suggestion will be very positive...

:-), afaik some architectures requires this, ie. removing this would
require dropping whole architectures.

> Another fix might be:
>
> while (p->on_cpu) {
> if (p == current)
> goto out_activate;
> cpu_relax();
> }
>
> Then add back in the out_activate label.
>
> I don't know if the second fix is good -- I haven't thought out how
> it impacts the later patches in the series.

Right, I've done something similar to this, simply short-circuit the cpu
selection to force it to activate the task on the local cpu.


\
 
 \ /
  Last update: 2011-02-03 18:19    [W:0.112 / U:0.164 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site