lkml.org 
[lkml]   [2009]   [Nov]   [25]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
SubjectRe: [patch] sched: fix set_task_cpu() and provide an unlocked runqueue variant
From
Date
On Sun, 2009-11-22 at 13:09 +0100, Mike Galbraith wrote:
> sched: fix set_task_cpu() and provide an unlocked runqueue variant.
>
> set_task_cpu() falsifies migration stats by unconditionally generating migration
> stats whether a task's cpu actually changed or not. As used in copy_process(),
> the runqueue is unlocked, so we need to provide an unlocked variant which does
> the locking to provide a write barrier.
>
> Signed-off-by: Mike Galbraith <efault@gmx.de>
> Cc: Ingo Molnar <mingo@elte.hu>
> Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
> LKML-Reference: <new-submission>
>
> ---

> +void set_task_cpu_unlocked(struct task_struct *p, unsigned int new_cpu)
> +{
> + unsigned long flags;
> + struct rq *rq, *new_rq = cpu_rq(new_cpu);
> +
> + smp_wmb();
> + rq = task_rq_lock(p, &flags);
> + update_rq_clock(rq);
> + if (rq != new_rq)
> + update_rq_clock(new_rq);
> + set_task_cpu(p, new_cpu);
> + task_rq_unlock(rq, &flags);
> +}

I've got to ask, what's that barrier for?





\
 
 \ /
  Last update: 2009-11-25 19:31    [W:0.062 / U:1.052 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site