Re: [RFC PATCH 2/3] sched: add yield_to function

Chris Wright
2010-12-03T19:30:08Z

* Rik van Riel (riel@redhat.com) wrote:
> On 12/02/2010 07:50 PM, Chris Wright wrote:
> >>+/*
> >>+ * Yield the CPU, giving the remainder of our time slice to task p.
> >>+ * Typically used to hand CPU time to another thread inside the same
> >>+ * process, eg. when p holds a resource other threads are waiting for.
> >>+ * Giving priority to p may help get that resource released sooner.
> >>+ */
> >>+void yield_to(struct task_struct *p)
> >>+{
> >>+ unsigned long flags;
> >>+ struct sched_entity *se =&p->se;
> >>+ struct rq *rq;
> >>+ struct cfs_rq *cfs_rq;
> >>+ u64 remain = slice_remain(current);
> >>+
> >>+ rq = task_rq_lock(p,&flags);
> >>+ if (task_running(rq, p) || task_has_rt_policy(p))
> >>+ goto out;
> >>+ cfs_rq = cfs_rq_of(se);
> >>+ se->vruntime -= remain;
> >>+ if (se->vruntime< cfs_rq->min_vruntime)
> >>+ se->vruntime = cfs_rq->min_vruntime;
> >
> >Should these details all be in sched_fair? Seems like the wrong layer
> >here. And would that condition go the other way? If new vruntime is
> >smaller than min, then it becomes new cfs_rq->min_vruntime?
>
> That would be nice. Unfortunately, EXPORT_SYMBOL() does
> not seem to work right from sched_fair.c, which is included
> from sched.c instead of being built from the makefile!

add a ->yield_to() to properly isolate (only relevant then in
sched_fair)?