Re: broken behavior in cfs when moving threads between cgroups

From: Mike Galbraith
Date: Tue Sep 28 2010 - 22:53:14 EST


On Tue, 2010-09-28 at 15:57 -0700, Dima Zavin wrote:

> Hmm. Would we really want to give the sleeping task such a bump in the
> new group? Why not just start it off at min_vruntime and let
> place_entity do it's thing? Something like...

No, I wouldn't want to give it anything, just enter at zero lag..

> diff --git a/kernel/sched_fair.c b/kernel/sched_fair.c
> index a7be83c..4656231 100644
> --- a/kernel/sched_fair.c
> +++ b/kernel/sched_fair.c
> @@ -3622,10 +3622,15 @@ static void set_curr_task_fair(struct rq *rq)
> static void moved_group_fair(struct task_struct *p, int on_rq)
> {
> struct cfs_rq *cfs_rq = task_cfs_rq(p);
> + struct sched_entity *se = &p->se;
>
> update_curr(cfs_rq);
> - if (!on_rq)
> + if (on_rq) {
> + se->vruntime = 0;
> + } else {
> + se->vruntime = cfs_rq->min_vruntime;
> place_entity(cfs_rq, &p->se, 1);
> + }
> }
> #endif

(Why penalize the sleeper?)

..but, as you noted, moving out then _back_ at forced 0 lag would result
in bogus vruntime deltas, so lag must be preserved. The sleeper's
vruntime has to be set to relative before it's cfs_rq is changed, then
back to absolute in moved_group_fair() I suppose.

-Mike

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