Re: [RFC][PATCH 5/5] sched: Reduce ttwu rq->lock contention

From: Oleg Nesterov
Date: Fri Dec 17 2010 - 14:35:42 EST


On 12/17, Peter Zijlstra wrote:
>
> By fully serializing all wakeups using ->pi_lock it becomes a lot
> simpler

Hmm, yes. Contrary to my expectations ;)

> static int
> try_to_wake_up(struct task_struct *p, unsigned int state, int wake_flags)
> {
> unsigned long flags;
> int cpu, ret = 0;
>
> smp_wmb();
> raw_spin_lock_irqsave(&p->pi_lock, flags);
>
> if (!(p->state & state))
> goto unlock;
>
> ret = 1; /* we qualify as a proper wakeup now */
>
> if (p->se.on_rq && ttwu_force(p, state, wake_flags))
> goto unlock;

Well. All I can say, I'll try to re-read this code with the fresh head ;)
We should ensure that on_rq == 0 can not be racy.

> p->state = TASK_WAKING;
> smp_wmb();
> raw_spin_unlock_wait(&task_rq(p)->lock);

This needs smp_mb(), unlock_wait() reads the memory.

Oleg.

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/