Commit b2b5ce02 authored by Peter Zijlstra's avatar Peter Zijlstra Committed by Ingo Molnar

sched, cgroup: Fixup broken cgroup movement

Dima noticed that we fail to correct the ->vruntime of sleeping tasks
when we move them between cgroups.
Reported-by: default avatarDima Zavin <dima@android.com>
Signed-off-by: default avatarPeter Zijlstra <a.p.zijlstra@chello.nl>
Tested-by: default avatarMike Galbraith <efault@gmx.de>
LKML-Reference: <1287150604.29097.1513.camel@twins>
Signed-off-by: default avatarIngo Molnar <mingo@elte.hu>
parent b7dadc38
...@@ -1073,7 +1073,7 @@ struct sched_class { ...@@ -1073,7 +1073,7 @@ struct sched_class {
struct task_struct *task); struct task_struct *task);
#ifdef CONFIG_FAIR_GROUP_SCHED #ifdef CONFIG_FAIR_GROUP_SCHED
void (*moved_group) (struct task_struct *p, int on_rq); void (*task_move_group) (struct task_struct *p, int on_rq);
#endif #endif
}; };
......
...@@ -8498,12 +8498,12 @@ void sched_move_task(struct task_struct *tsk) ...@@ -8498,12 +8498,12 @@ void sched_move_task(struct task_struct *tsk)
if (unlikely(running)) if (unlikely(running))
tsk->sched_class->put_prev_task(rq, tsk); tsk->sched_class->put_prev_task(rq, tsk);
set_task_rq(tsk, task_cpu(tsk));
#ifdef CONFIG_FAIR_GROUP_SCHED #ifdef CONFIG_FAIR_GROUP_SCHED
if (tsk->sched_class->moved_group) if (tsk->sched_class->task_move_group)
tsk->sched_class->moved_group(tsk, on_rq); tsk->sched_class->task_move_group(tsk, on_rq);
else
#endif #endif
set_task_rq(tsk, task_cpu(tsk));
if (unlikely(running)) if (unlikely(running))
tsk->sched_class->set_curr_task(rq); tsk->sched_class->set_curr_task(rq);
......
...@@ -3866,13 +3866,26 @@ static void set_curr_task_fair(struct rq *rq) ...@@ -3866,13 +3866,26 @@ static void set_curr_task_fair(struct rq *rq)
} }
#ifdef CONFIG_FAIR_GROUP_SCHED #ifdef CONFIG_FAIR_GROUP_SCHED
static void moved_group_fair(struct task_struct *p, int on_rq) static void task_move_group_fair(struct task_struct *p, int on_rq)
{ {
struct cfs_rq *cfs_rq = task_cfs_rq(p); /*
* If the task was not on the rq at the time of this cgroup movement
update_curr(cfs_rq); * it must have been asleep, sleeping tasks keep their ->vruntime
* absolute on their old rq until wakeup (needed for the fair sleeper
* bonus in place_entity()).
*
* If it was on the rq, we've just 'preempted' it, which does convert
* ->vruntime to a relative base.
*
* Make sure both cases convert their relative position when migrating
* to another cgroup's rq. This does somewhat interfere with the
* fair sleeper stuff for the first placement, but who cares.
*/
if (!on_rq)
p->se.vruntime -= cfs_rq_of(&p->se)->min_vruntime;
set_task_rq(p, task_cpu(p));
if (!on_rq) if (!on_rq)
place_entity(cfs_rq, &p->se, 1); p->se.vruntime += cfs_rq_of(&p->se)->min_vruntime;
} }
#endif #endif
...@@ -3924,7 +3937,7 @@ static const struct sched_class fair_sched_class = { ...@@ -3924,7 +3937,7 @@ static const struct sched_class fair_sched_class = {
.get_rr_interval = get_rr_interval_fair, .get_rr_interval = get_rr_interval_fair,
#ifdef CONFIG_FAIR_GROUP_SCHED #ifdef CONFIG_FAIR_GROUP_SCHED
.moved_group = moved_group_fair, .task_move_group = task_move_group_fair,
#endif #endif
}; };
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment