Messages in this thread | | | Subject | Re: [patch] sched: fix set_task_cpu() and provide an unlocked runqueue variant | From | Peter Zijlstra <> | Date | Wed, 25 Nov 2009 19:27:52 +0100 |
| |
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?
| |