[lkml]   [2010]   [Dec]   [13]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
Messages in this thread
SubjectRe: [PATCH RFC] reduce runqueue lock contention
On 06/21/10 06:04, Peter Zijlstra wrote:
> On Mon, 2010-06-21 at 12:54 +0200, Peter Zijlstra wrote:
>>> It looses the ttwu task_running() check, as I must admit I'm not quite
>>> sure what it does.. Ingo?
> I think I figured out what its for, its for when p is prev in schedule()
> after deactivate_task(), we have to call activate_task() it again, but
> we cannot migrate the task because the CPU its on is still referencing
> it.

I have not been able to make sense of the task_running() check in
try_to_wake_up(), even with that clue. The try_to_wake_up() code in
question is:

rq = task_rq_lock(p, &flags);
if (!(p->state & state))
goto out;

if (p->se.on_rq)
goto out_running;

cpu = task_cpu(p);
orig_cpu = cpu;

if (unlikely(task_running(rq, p)))
goto out_activate;

The relevent code in schedule() executes with the rq lock held (many
lines left out to emphasize the key lines):


if (prev->state && !(preempt_count() & PREEMPT_ACTIVE)) {

deactivate_task(rq, prev, DEQUEUE_SLEEP);

if (likely(prev != next)) {
rq->curr = next;
context_switch(rq, prev, next); /* unlocks the rq */
} else

If (p->se.on_rq) can becomes false due to deactivate_task()
then task_running() will also become false while the rq lock is still
held (either via "rq->curr = next" or via context_switch() updating
p->oncpu -- which one matters depends on #ifdef __ARCH_WANT_UNLOCKED_CTXSW).

I haven't been able to find any case where task_running() can be true
when (p->se.on_rq) is false, while the rq lock is not being held. Thus
I don't think the branch to out_activate will ever be taken.

What am I missing, or is the task_running() test not needed?



 \ /
  Last update: 2010-12-14 03:45    [W:0.092 / U:0.268 seconds]
©2003-2018 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site