Messages in this thread | | | Date | Thu, 4 Oct 2012 11:43:49 +0200 | From | Andrea Righi <> | Subject | Re: [PATCH RFC 1/3] sched: introduce distinct per-cpu load average |
| |
On Thu, Oct 04, 2012 at 10:59:46AM +0200, Peter Zijlstra wrote: > On Thu, 2012-10-04 at 01:05 +0200, Andrea Righi wrote: > > +++ b/kernel/sched/core.c > > @@ -727,15 +727,17 @@ static void dequeue_task(struct rq *rq, struct task_struct *p, int flags) > > void activate_task(struct rq *rq, struct task_struct *p, int flags) > > { > > if (task_contributes_to_load(p)) > > - rq->nr_uninterruptible--; > > + cpu_rq(p->on_cpu_uninterruptible)->nr_uninterruptible--; > > > > enqueue_task(rq, p, flags); > > } > > That's completely broken, you cannot do non-atomic cross-cpu > modifications like that. Also, adding an atomic op to the wakeup/sleep > paths isn't going to be popular at all.
Right, the update must be atomic to have a coherent nr_uninterruptible value. And AFAICS the only way to account a coherent nr_uninterruptible value per-cpu is to go with atomic ops... mmh... I'll think more on this.
> > > void deactivate_task(struct rq *rq, struct task_struct *p, int flags) > > { > > - if (task_contributes_to_load(p)) > > - rq->nr_uninterruptible++; > > + if (task_contributes_to_load(p)) { > > + task_rq(p)->nr_uninterruptible++; > > + p->on_cpu_uninterruptible = task_cpu(p); > > + } > > > > dequeue_task(rq, p, flags); > > } > > This looks pointless, at deactivate time task_rq() had better be rq or > something is terribly broken.
Correct, I didn't realize that, sorry.
Many thanks for your review, Peter.
-Andrea
| |