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

From: Chris Wright
Date: Fri Dec 03 2010 - 14:30:50 EST


* Rik van Riel (riel@xxxxxxxxxx) 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)?
--
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/