On Thu, Dec 14, 2006 at 12:13:16AM +0100, Ingo Molnar wrote:
> there's another bug as well: in schedule() resched_cpu() is called with 
> the current runqueue held in two places, which is deadlock potential. 

resched_cpu() was getting called after prepare_task_switch() which
releases the current runqueue lock. Isn't it?

> The easiest fix for this is to use trylock - find the patch for that. 
> This is a hint only anyway - and if a CPU is idle its runqueue will be 

Though I don't see a potential deadlock, I like this optimization.

thanks,
suresh

> lockable. (fixing it via double-locking is easy in the first call site, 
> but the second one looks harder)
> 
>       Ingo
> 
> Index: linux/kernel/sched.c
> ===================================================================
> --- linux.orig/kernel/sched.c
> +++ linux/kernel/sched.c
> @@ -1167,12 +1167,14 @@ static void resched_task(struct task_str
>       if (!tsk_is_polling(p))
>               smp_send_reschedule(cpu);
>  }
> +
>  static void resched_cpu(int cpu)
>  {
>       struct rq *rq = cpu_rq(cpu);
> -     unsigned int flags;
> +     unsigned long flags;
>  
> -     spin_lock_irqsave(&rq->lock, flags);
> +     if (!spin_trylock_irqsave(&rq->lock, flags))
> +             return;
>       resched_task(cpu_curr(cpu));
>       spin_unlock_irqrestore(&rq->lock, flags);
>  }
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Reply via email to