Re: [RFC][PATCH 2/4] sched: Push put_prev_task() intopick_next_task()

From: Peter Zijlstra
Date: Fri Jun 15 2012 - 06:03:14 EST


On Fri, 2012-06-15 at 13:49 +0400, Glauber Costa wrote:
> On 06/14/2012 05:29 PM, Peter Zijlstra wrote:
> > +static struct task_struct *
> > +pick_next_task_rt(struct rq *rq, struct task_struct *prev)
> > {
> > - struct task_struct *p = _pick_next_task_rt(rq);
> > + struct task_struct *p;
> > + struct rt_rq *rt_rq =&rq->rt;
> > +
> > + if (!rt_rq->rt_nr_running)
> > + return NULL;
> > +
> > + if (rt_rq_throttled(rt_rq))
> > + return NULL;
> > +
> > + if (prev)
> > + prev->sched_class->put_prev_task(rq, prev);
> > +
> it might be me, but this one sounds strange. If the responsibility of
> putting the task now lays with pic_next_task, you can't return NULL
> without doing this first.

Its the responsibility of the sched_class::pick_next_task implementation
that will return the next task. Not of the first one called.

Clearly this needs a comment.. /me adds.

---
--- a/include/linux/sched.h
+++ b/include/linux/sched.h
@@ -1096,6 +1096,11 @@ struct sched_class {

void (*check_preempt_curr) (struct rq *rq, struct task_struct *p, int flags);

+ /*
+ * It is the responsibility of the pick_next_task() method that will
+ * return the next task to call put_prev_task() on the @prev task or
+ * something equivalent.
+ */
struct task_struct * (*pick_next_task) (struct rq *rq,
struct task_struct *prev);
void (*put_prev_task) (struct rq *rq, struct task_struct *p);

--
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/